dart

How can I put retrieved data from firebase to a widget in Flutter?

旧街凉风 提交于 2021-01-29 13:56:12
问题 final String uid; final firestoreInstance = Firestore.instance; void printData() async{ var firebaseUser = await FirebaseAuth.instance.currentUser(); firestoreInstance.collection("users").document(firebaseUser.uid).get().then((value){ print(value.data); }); } So this function prints to console the retrieved data from firebase firestore when I press the button. But I want to put them into a widget and display them in my app. For ex: Text(printData()) - but it's not allowed. How can I do that?

Flutter making a directory index [closed]

对着背影说爱祢 提交于 2021-01-29 13:55:12
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 months ago . Improve this question Im facing challenge creating a directory with alphabet index. I have List<Map<String, dynamic>> of shops like below: var shops = [ {'name':'Thrifty','products':'cars', 'delivery':'no'}, {'name':'Pizza Express','products':'pizza', 'delivery':'yes'}, {'name':'Fastmart',

Flutter - How to prevent ScrollView scroll when I drag a slider on it?

ε祈祈猫儿з 提交于 2021-01-29 13:54:08
问题 I put a slider on a CustomScollView, When I drag the slider, the scrollview will scroll up and down slightly, so my question is When I drag the slider, how to fibidden scroll of the scrollview? This slider is custom slider which extends RenderConstrainedBox class _RenderCupertinoSlider extends RenderConstrainedBox { _RenderCupertinoSlider(){ _drag = new HorizontalDragGestureRecognizer() ..onStart = _handleDragStart ..onUpdate = _handleDragUpdate ..onEnd = _handleDragEnd; }

In flutter, how can I “merge” Firebase onAuthStateChanged with user.getTokenId() to return a Stream?

為{幸葍}努か 提交于 2021-01-29 13:41:55
问题 In flutter, I'm trying to access Custom Claims to decide which Widget I will show, I was able to get the user as Stream and convert it to a Class doing: Stream<User> get user { return _auth.onAuthStateChanged .map(_userFromFirebaseUser); } User _userFromFirebaseUser(FirebaseUser user) { return user != null ? User(uid: user.uid) : null; } I would like to add the user.getIdToken() claims['role'] to the User object (i.e.: User(uid: user.uid, role: token.claims['role']), but I'm not sure how to

why the assert function was disabled in dart?

僤鯓⒐⒋嵵緔 提交于 2021-01-29 13:36:12
问题 import 'dart:io'; main() { print("Enter an even number : "); int evenNo = int.parse(stdin.readLineSync()); assert(evenNo % 2 == 0, 'wrong input'); print("You have entered : $evenNo"); } to get this code to work properly I had to run the dart file with '--enable-asserts' tag and before assert function was executed without passing the '--enable-asserts' tag. why was this function disabled ? 回答1: What is an assertion? In many languages, including Dart, "assertions" specifically are meant to

Flutter Mailer isn't working due to these errors

丶灬走出姿态 提交于 2021-01-29 13:30:28
问题 I am trying to send a form from flutter app to my email automatically when the user submit the form. here's the code : import 'package:flutter/material.dart'; import 'dart:async'; import 'dart:convert'; import 'package:url_launcher/url_launcher.dart'; import 'package:mailer/mailer.dart'; import 'package:mailer/smtp_server.dart'; import 'package:http/http.dart' as http; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_speed_dial/flutter_speed_dial.dart

Flutter: How to code the following ExpansionPanel

主宰稳场 提交于 2021-01-29 13:26:37
问题 Good day! I am trying to find a solution for the following design: Layout Image (Note: LightGrey Lines are just to point out the Layout. They should not be visible later on) An ExpansionPanel shall contain 2 Columns, where Column A expands over the whole height (which Column B needs) but only uses a certain width. In Column A (left side), I want to draw a start and end point, connected with a line, and text next to those points. In Column B (right side), I want to show detailed information.

Hot to refresh actions of appBar on tab change?

喜夏-厌秋 提交于 2021-01-29 13:18:21
问题 I'm looking for a way to hide/change appBar actions when specific tab from tabBar is pressed. Calling setState(() { }) method redrawing entire widget and so all the TabController children/screens, which is real bad. Below is my code: enum SelectedTab { items, sales, raw_items, orders } class _MyHomePageState extends State<MyHomePage> { Widget rightActionButton(BuildContext context) { //This is the widget which is expected to be update upon tab change SelectedTab currentTab = Globals.instance

Is there a better way to compare a date against another?

杀马特。学长 韩版系。学妹 提交于 2021-01-29 13:12:16
问题 My code is: for (var rt in list) { if (rt.date.day == date2.day && rt.date.month == date2.month && rt.date.year == date2.year) { ... } } Is there a better way to compare a date against another? 回答1: You can make a helper function to strip off the time: DateTime dateOnly(DateTime dateTime) => DateTime(dateTime.year, dateTime.month, dateTime.day); and then you can use DateTime 's normal operator ==: if (dateOnly(rt.date) == dateOnly(date2)) { ... } Note that the above example assumes both dates

Does Code Coverage support DART 2 for Flutter projects?

家住魔仙堡 提交于 2021-01-29 13:10:59
问题 On the Official Flutter Packages website, it is written that the plugin for Code Coverage, dart_codecov_generator (https://pub.dev/packages/dart_codecov_generator), is DART 2 INCOMPATIBLE . So, is there a way we can use Code Coverage for Flutter projects? 回答1: Yes it possible to get the code coverage for a flutter project. if you run flutter test --coverage , it will output a file (lcov.info) in the coverage folder and then multiple solution are possible: you can use genhtml program on this