dart

Run Flutter builder runner in compiled app

不羁的心 提交于 2021-02-10 14:59:51
问题 I have an idiot question. is it possible to run the build runner in an application compiled for dynamic code generation? 回答1: In a Flutter application, no. Flutter apps neither have the ability to dynamically evaluate Dart code, nor do they have access to the tools needed to parse and generate source code. 来源: https://stackoverflow.com/questions/61015321/run-flutter-builder-runner-in-compiled-app

How to save List<List<String>> with SharedPreferences in Flutter

拜拜、爱过 提交于 2021-02-10 14:53:17
问题 I am trying to save a List of List but I don't know how to do that. So I have List<List> _randList = new List(); 回答1: See, there is no way that we can use Shared Preferences in order store List<List<String>> . However, we can always use a workaround. Since, we already that we can store the List<String> only in the Shared Preferences, it is best to store the nested lists in the form of String , like below List<String> _arr = ["['a', 'b', 'c'], ['d', 'e', 'f']"]; In this way, you will be having

Cast “Map<String, List<dynamic>>” to “Map<String, List<String>>”

↘锁芯ラ 提交于 2021-02-10 14:51:51
问题 I want to cast a Map<String, dynamic> to Map<String, List<String>> . I have tried the following in Flutter: Map<String, dynamic> dynamicMap = { 'a': ['1', '2', '3'], 'b': ['1', '2', '3'], 'c': ['1', '2', '3'], }; Map<String, List<String>> typedMap = dynamicMap; But get the following error: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, List<String>>' I then tried: Map<String, List<String>> typedMap = dynamicMap.cast<String, List<String>>(); which seems to

Returning List from Firestore Listen callback

这一生的挚爱 提交于 2021-02-10 14:39:34
问题 I have a function in firebase that is intended to get all documents in a collection called history and add it to a list intended to be returned. The problem is, and I think this is because .listen() is async, the list returned is always empty. I know the data is queried correctly because I can print the doc in the forEach function, but adding to a list outside doesn't work. By the way, myStream is a snapshot of the history collection in FireStore. Does my function need to be a Future? How can

Draw dashed arc with flutter

匆匆过客 提交于 2021-02-10 14:36:34
问题 Is there some way to draw a dashed arc in Flutter? At the moment I'm using canvas.drawArc but I don't know how to get the correct result. canvas.drawArc( rectangle, startAngle, fullArcRadius, false, Paint() ..color = Colors.black ..strokeCap = StrokeCap.round ..style = PaintingStyle.stroke ..strokeWidth = 2.0, ); dashed-arc 回答1: Unfortunately, flutter doesn't handle dashes all that well. There is a plugin that helps with it though: path_drawing Using that, you can draw any path dashed simply

dart: access function from list

▼魔方 西西 提交于 2021-02-10 14:19:12
问题 Edit: i know, always call the first element on list, it isnt the point. i want to call numbers[0] func. and it regenerate new int.actually codes are not same which mine, i have a custom class which based on functions with random int and i need to use list of my custom class , so if i use func in list it will be awesome, how can i make new numbers list each time. when app start list regenerated, but i want when i call the list, it will regenerated i want to print new int for each print but it

Update the Map field - Flutter

痞子三分冷 提交于 2021-02-10 14:16:25
问题 How to update data of isVerified (Boolean) field. Personal Info is Map contains address and then isVerified. 回答1: To update isVerified , you have to do the following: Firestore.instance.collection("collection Name").document("documentId").updateData({ "Personal Info.address.isVerified": true, }).then((_) { print("success!"); }); 回答2: Since you did not provide your collection or document name I would just form one So lets assume every time we click a button the value should be changed to true

stream builder is not updating after navigation

二次信任 提交于 2021-02-10 12:43:56
问题 I am using a stream builder to detect if user logged in or not. return StreamBuilder<User>( stream: AuthService().user, builder: (context, snapshot) { if (snapshot.hasData) return SectionWrapper(); else return Authentication(); }); and this is the stream I am using Stream<User> get user { return _auth.onAuthStateChanged.map(_userFromFirebaseUser); } //create user object based on firebase user User _userFromFirebaseUser(FirebaseUser user) { return user != null ? User(uid: user.uid, email: user

stream builder is not updating after navigation

回眸只為那壹抹淺笑 提交于 2021-02-10 12:43:33
问题 I am using a stream builder to detect if user logged in or not. return StreamBuilder<User>( stream: AuthService().user, builder: (context, snapshot) { if (snapshot.hasData) return SectionWrapper(); else return Authentication(); }); and this is the stream I am using Stream<User> get user { return _auth.onAuthStateChanged.map(_userFromFirebaseUser); } //create user object based on firebase user User _userFromFirebaseUser(FirebaseUser user) { return user != null ? User(uid: user.uid, email: user

How do I use custom font with a set size in flutter/dart?

↘锁芯ラ 提交于 2021-02-10 12:15:58
问题 I'm trying to use color , fontWeight and fontFamily with style: style.copyWith , the custom font I'm trying to use is Vonique , I've imported it like so into pubspec.yaml fonts: - family: Vonique fonts: - assets: fonts/Vonique-64-Bold-Italic.ttf - assets: fonts/Vonique-64-Italic.ttf - assets: fonts/Vonique-64-Bold.ttf - assets: fonts/Vonique-64.ttf Is this the correct way to import it? I've tried it both was with '' and without '', still doesn't change the text font. Text('Login', style: