dart

flutter run failed: A problem occurred configuring project ':shared_preferences'

拜拜、爱过 提交于 2021-01-28 03:33:45
问题 I am Using flutter 1.2 and my project runs successfully before I add shared_preferences package to it.I am using shared_preferences: ^0.5.1+2. after I add it, flutter run command creates this error: Error running Gradle: ProcessException: Process "/home//Desktop/projects/fycx/android/gradlew" exited abnormally: Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details Configure project :shared_preferences Project evaluation failed including an error in

Why List() constructor is not accessible in Dart's null safety?

余生长醉 提交于 2021-01-28 02:46:16
问题 With NNBD, you're not allowed to initialise the list using the default constructor: List<int> foo = List(); // Compile time error However, you can still do: List<int> foo = []; // No error So, what's the difference between the two? Either both of them should show the error or none of them. 回答1: The List constructor had two uses: new List() to create an empty growable list, equivalent to [] . new List(n) to create a fixed-length list of length n filled with null values With null safety, the

flutter firebase how do I get all the children of a node

馋奶兔 提交于 2021-01-28 01:57:35
问题 I am not very familiar with using dart and firebase and I was wondering how I could get all the children of a certain node and how I could check if a node exists 回答1: Something like this should you get the list of users: static Future<int> getUserAmount() async { final response = await FirebaseDatabase.instance .reference() .child("Users") .once(); var users = []; reponse.value.forEach((v) => users.add(v)); print(users); return users.length; } You can check with users what you need to check

flutter/dart: How to use async callback with Dart FFI?

独自空忆成欢 提交于 2021-01-28 01:12:27
问题 My app's backend is written in C++ and the frontend in Dart/flutter. I'd love to have the backend notify frontend whenever data is ready. This requires implementing an async callback scheme between Dart and C++. Environment $ flutter doctor -v [✓] Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.5 19F101, locale en-CN) • Flutter version 1.20.1 at /Applications/Android/flutter • Framework revision 2ae34518b8 (2 days ago), 2020-08-05 19:53:19 -0700 • Engine revision c8e3b94853 • Dart version

Flutter: Schedule notification not working

烈酒焚心 提交于 2021-01-28 00:34:18
问题 I am developing a app using Flutter. To show notification I an using flutter_local_notifications package. I am getting notification, but schedule notification is not working. Similar question was asked here How do I schedule a notification in Flutter?, but my receiver is already inside the application tag. Here is my manifest <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.folk.gayatrimonitor"> <!-- The INTERNET

Flutter FutureBuilder Not Updating

喜欢而已 提交于 2021-01-28 00:12:08
问题 I have a Flutter FutureBuilder that needs to be updated with new data given by the user. However, the UI elements in the FutureBuilder do not update and still contain the old values. I have checked through print statements that the new data is correctly loaded. The issue seems to be with FutureBuilder rebuilding the widget when the new data is loaded. Any help is appreciated. Future<List<PollItem>> fetchPost(String loc) async { return new Future(() async { final response = await http .post

How to highlight only numbers and special characters inside Text in Flutter?

試著忘記壹切 提交于 2021-01-27 23:08:16
问题 I'm trying to highlight any numbers & special characters like '%' from a String that comes dynamically from JSON. This is my current implementation but I can't understand how to change it dynamically. RichText( overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, maxLines: 4, text: TextSpan( children: <TextSpan>[ TextSpan( text: 'Hey I\'m', style: TextStyle( color: kDarkBlue, fontSize: 21)), TextSpan( text: '1234 ', style: TextStyle( fontWeight: FontWeight.w800, fontSize: 24)),

Simple expandable column on Flutter wont have Title > expandable too

混江龙づ霸主 提交于 2021-01-27 22:51:52
问题 I'm trying to make an Expandable Column. That is, it has 2 children: the child and the expanded child that appears when the widget is expanded. In the picture below, you see the child (blue) and expanded child (red) which should only appear when the Expand > button is clicked. Everything is working, but no mater what I do, I cannot get the Expand > button to work like this: Expand > when not expanded, and Expand (lots of spaces) < when expanded. This is the code of the Expand button: Row(

Flutter AnimatedList still janky?

岁酱吖の 提交于 2021-01-27 22:13:22
问题 I'm currently using an AnimatedList in my Flutter app and having problems with the way removed list items are animated out. The animation itself works as expected but once the removed item finishes animating, it just disappears causing the other widgets to jump into its place. I had expected the other items to transition into the place of the removed item ... I tried wrapping my list items with a ScaleTransition but that didn't help - the other list items still do not react to the removed

Flutter DIO: upload image using binary body with Dio package

百般思念 提交于 2021-01-27 21:43:35
问题 With thwe http package I can send an image to a server by putting te binary data in the body of a post call like in the snippet of this code: var response = await http.post('My_url', body: File(path).readAsBytesSync(), headers: { 'apikey': 'myAPIKEY', 'Content-Type': 'image/*', // set content-length }); I can't do the same thing by using Dio, I don't know how to put directly the binary data in the body (like i can do it with postman) 回答1: Just putting my solution if someone stumbles upon the