dart

Flutter firestore getting data receiver: null error

半腔热情 提交于 2021-01-29 19:56:30
问题 I searched a lot but couldn't find a solution. I need your help. In my database model, I have a method like this to get the data: Future<Map<String,dynamic>> getSystemSettings() async { var response = await _firestore.collection("system").doc("settings").get(); return response.data(); } Later, I want to use the data in the form of Map <String, dynamic> from the class I want to get the data from by calling the method as follows. getValues() { database.getSystemSettings().then((value) { print(

Flutter/Firebase - type 'Future<int>' is not a subtype of type 'int'

吃可爱长大的小学妹 提交于 2021-01-29 19:26:47
问题 I'm new to flutter and this is probably a simple question but i'm looking for a bit of an explanation to help me understand futures and future builder more. I am trying to query firebase (depending on what a user clicks on a previous screen) and i'd like to wait for all the data to be loaded before anything is shown. To do this I thought a future builder would be most appropriate as i'm going to be showing some products that won't change a great deal. I created my getData function: Future

How do I can iterate cookie values from http response?

吃可爱长大的小学妹 提交于 2021-01-29 19:17:04
问题 I am using rest API in my flutter app. For further request I need JSESSIONID which I received from my profile API. I successful got response but I need guide to iterate cookie value. I followed following steps: final response = await http.get( strURL, headers: { "Authorization": basicAuth, "Content-Type": "application/json" }, ); String rawCookie = response.headers['set-cookie']; print('rawCookie $rawCookie'); As print raw cookie it is printing details: flutter: rawCookie __cfduid

Managing exception in dart

拈花ヽ惹草 提交于 2021-01-29 18:58:23
问题 I'm trying to fetch an image from the internet, and display a profile photo. If there is an error while displaying the pic (maybe it doesnt exist at that location), I want to display a stock icon. My code: class AvatarWidget extends StatelessWidget { const AvatarWidget({ Key key, }) : super(key: key); @override Widget build(BuildContext context) { return ClipOval( child: CircleAvatar( child: ProfilePicWidget(), radius: 70, backgroundColor: Colors.grey, ), ); } } class ProfilePicWidget extends

What does error code 2 in beacon_broadcast flutter package mean?

佐手、 提交于 2021-01-29 18:42:09
问题 I am making a beacon broadcast app using Flutter. The library I am using is "beacon_broadcast" at pub.dev. When I try to start it, the console says: D/BeaconParser( 7318): Parsing beacon layout: m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25 D/BluetoothAdapter( 7318): isLeEnabled(): ON D/BluetoothAdapter( 7318): isLeEnabled(): ON E/BeaconTransmitter( 7318): Advertisement start failed, code: 2 What does error code 2 mean? I don't need any other help, I just want the meaning, so I think I

Flutter readAsBytesSync file read incomplete to encode base64

白昼怎懂夜的黑 提交于 2021-01-29 18:20:02
问题 List item I'm trying to send a JPG image (captured by ImagePicker in emulator) via HTTP POST with base64 encoding to an AWS REST API. But readAsBytesSync() operation only reads a (head) part of the image (I've tested it printing to the string as bytes) thus base64 can only encode that small part. What may be the reason, many thanks for your help in advance. Future<void> captureImage(ImageSource imageSource) async { try { ImagePicker picker = ImagePicker(); final pickedFile = await picker

'A non-null String must be provided to a Text widget' (Flutter)

半世苍凉 提交于 2021-01-29 18:12:15
问题 I've tried to fix this with the following code but I'm afraid the error is still prevalent: The following assertion was thrown building: A non-null String must be provided to a Text widget. 'package:flutter/src/widgets/text.dart': Failed assertion: line 360 pos 10: 'data != null' child: Row( children: [ Text( (contact.data()['rating'] == null) ? "n/a" : contact.data()['rating'].toString(), style: TextStyle( fontWeight: FontWeight.bold, color: Colors.tealAccent)), Padding( padding: const

Flutter Riverpod StateNotifierProvider: only watch changes for part of a model

风流意气都作罢 提交于 2021-01-29 18:12:14
问题 I have a model like this: class TimerModel { const TimerModel(this.timeLeft, this.buttonState); final String timeLeft; final ButtonState buttonState; } enum ButtonState { initial, started, paused, finished, } And here is the StateNotifierProvider: class TimerNotifier extends StateNotifier<TimerModel> { TimerNotifier() : super(_initialState); static const int _initialDuration = 10; static final _initialState = TimerModel( _durationString(_initialDuration), ButtonState.initial, ); final Ticker

Flutter shows blank screen for GridView/Listview in production build

天大地大妈咪最大 提交于 2021-01-29 17:52:23
问题 I created a simple flutter app which basically shows grid items. In debug mode, the grid items shows normally. However, in production mode, flutter just shows blank screen. I even implemented pull to refresh. Now, when I pull to refresh the page, it still doesn't show. In debug mode, both emulator and real device works fine. I use the following code to build the app for Android: flutter build apk --target-platform android-arm,android-arm64 --split-per-abi Here's my code: https://github.com

How can I use multiple order by in real time database flutter to order data by specific field? [duplicate]

我的未来我决定 提交于 2021-01-29 17:31:13
问题 This question already has answers here : Query based on multiple where clauses in Firebase (6 answers) Closed 20 days ago . I am trying to short "realtime database" result according to "date" in flutter . But I cant use multiple orderByChild('child_name') . It throw an error. My code is final String path = 'jsondata'; final _dbRef = FirebaseDatabase.instance.reference(); _dbRef.child(path) .orderByChild('trade_code').equalTo('GP') .once() .then((DataSnapshot snapshot) { snapshot.value.forEach