Flutter

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

“MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)” when i use floor database

风流意气都作罢 提交于 2021-02-10 14:48:46
问题 I'm trying to use floor database but when i want to build database i got below error : E/flutter (26007): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite) E/flutter (26007): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7) E/flutter (26007): <asynchronous suspension> E/flutter (26007): #1 MethodChannel.invokeMethod (package

Flutter display nested json in ListView return type String is not a subtype of type 'Map<String, dynamic>' in type cast

╄→гoц情女王★ 提交于 2021-02-10 14:44:22
问题 I' m going on with my journey in Flutter. I' m able to display a simple json in a ListView. Now I' m trying with a json with nested objects but everytime I run the app I get the error I' m generating the code for json model classes like suggested in Flutter official documentation. The error seems to happen when I' m parsing the User. While debugging, I see that name and surname are successfully parsed, but when I jump to the details object in user.g.dart at the row: json['details'] == null ?

Flutter display nested json in ListView return type String is not a subtype of type 'Map<String, dynamic>' in type cast

爷,独闯天下 提交于 2021-02-10 14:42:36
问题 I' m going on with my journey in Flutter. I' m able to display a simple json in a ListView. Now I' m trying with a json with nested objects but everytime I run the app I get the error I' m generating the code for json model classes like suggested in Flutter official documentation. The error seems to happen when I' m parsing the User. While debugging, I see that name and surname are successfully parsed, but when I jump to the details object in user.g.dart at the row: json['details'] == null ?

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

Flutter ListView.builder() widget's cross Axis is taking up the entire Screen height

半腔热情 提交于 2021-02-10 14:33:32
问题 I am using ListView.builder (scrollDirection: Horizontal) widget inside a Container in Flutter. The main Axis of the ListView is taking up the entire screen width which is expected. I want the ListView's crossAxis(vertical direction) to take up the ListView's Item height (only wrapping the content), but it is taking up the entire screen height. I have created the DartPard to explain the Issue. I want the ListView to take up the Item height and not the entire screen height. Dart Pad Link :

About Android Studio and Flutter Inspector

无人久伴 提交于 2021-02-10 14:21:45
问题 So I normally use Flutter Inspector on a daily basis and lately, after some updates which I cannot distinguish, Flutter Inspector stopped working. Here's what I get when I open it: Setting up DevTools Failed Error Setting up DevTools Failed It is probably related to some versioning, but I can't figure it out how to fix this. Here are my results for: Flutter Doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10

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