Flutter

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

Listview builder scrolling in Flutter not smooth when combining futurebuilder and streambuilder

早过忘川 提交于 2021-01-29 18:33:52
问题 I have a comment page for each post in my app that I use streambuilder to fetch the comments from Firebase database. For each comment, I am displaying user's image and their comment. To get the user's image, I need to use a futurebuilder to find the user in the userData document and then grab the image url and display it (users can change their image profile, name, etc. at any time and I have to grab the updated one from the userData document every time I want to display their name or image

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

Flutter : How to change format dateTime with mounth in String?

北慕城南 提交于 2021-01-29 18:19:45
问题 hello I don't succeded to output this code in this format ( 04 Juin 2019 ) var now = new DateTime.now(); var daysfromnow = now.add(new Duration(days: changedate)); RegExp regExp = new RegExp( r"(^\S*)", ); var match = regExp.firstMatch("$daysfromnow"); daysfromnow_modify = match.group(1); current outpub : 2019-06-04 expected output : 04 juin 2019 Update: I tried to format but I don't succeded to change days when I press button... here is the new code new IconButton( icon: Icon(Icons.keyboard

'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

what expected have getExternalStorageDirectory() of path_provider dependency?

让人想犯罪 __ 提交于 2021-01-29 17:52:03
问题 I have an application that i develop with flutter and i need to acces local storage. what is expected return of that code? i use the package path_provider:^1.2.2 var directory=await getExternalStorageDirectory(); print(directory.path) I obtains: /storage/emulated/0/Android/data/com.myapplication.application/files while i expect to have /storage/emulated/0/ . I want to know if is not an error. 回答1: Remove the .getAbsolutePath() and it will be fine. Environment.getExternalStoreDirectory() will

SharedPreferences not working on real device FLUTTER

蹲街弑〆低调 提交于 2021-01-29 17:42:05
问题 I used SharedPreferences to make remember username and password to log in next time without asking a password. It was working well when I debug using my real device with USB cable. But it's not working in my device when I build APK and install it. I don't know what I'm missing. I save data in login page like this` Future<Null> loginUser(isLogin, name, fac, year, gender) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('Name', name); prefs