Flutter

Flutter Await not waiting

北城余情 提交于 2021-02-11 18:00:43
问题 Why won't the program wait for the function to return the list before going to the print statement? I think it's because I made the forEach loop async but I need it to be async to get the newSummary which is a Future. Future syncToCloud() async{ final List<Map<String,dynamic>> _events = await events(); print(_events.length); } Future<List<Map<String, dynamic>>> events() async { List<Map<String, dynamic>> maps = await db.query('data'); List<Map<String, dynamic>> newMaps=[]; maps.forEach(

Flutter- Getting and error when asking for Nearbyplaces

≡放荡痞女 提交于 2021-02-11 17:52:50
问题 Hi I want to implement Google Map and nearby Search in Flutter and I almost did it but I don't understand the error that I'm getting while trying to fetch the places near my position. I searched online but I couldn't figure it out, can anyone tell me what is wrong please. I lost almost 2h searching the web for the fix but nothing. This is the code : import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart

Flutter how can i round a container from middle

落爺英雄遲暮 提交于 2021-02-11 17:52:24
问题 I have 2 containers I need to round 1 container from mid-bottom and other from mid-top so it will create a circle between 2 containers so I can add Text here. Can anyone please tell how it's possible body: Container( child: Column( children: <Widget>[ SizedBox(height: (MediaQuery.of(context).size.height - appBar.preferredSize.height - MediaQuery.of(context).padding.top) * 0.05, ), Center( child: Container( width: MediaQuery.of(context).size.width * 0.9, color: Colors.red, height: (MediaQuery

how to create a list from json string in flutter

可紊 提交于 2021-02-11 17:51:36
问题 this question is already asked in here (convert JSON String to the list object in flutter) by someone else.. but right now.. I don't get the answer yet.. so is there a way to call List<LoginRespon> ... I have converted from json respond using https://app.quicktype.io/ and here is the code import 'dart:convert'; LoginRespon loginResponFromJson(String str) => LoginRespon.fromJson(json.decode(str)); String loginResponToJson(LoginRespon data) => json.encode(data.toJson()); class LoginRespon {

Flutter Flare, Rive, is it able to use for background?

帅比萌擦擦* 提交于 2021-02-11 17:38:55
问题 I just succeed flutter-flare for my flutter widgets but I could not find a example to use it for background (Container) is this possible? 回答1: Use official example code https://github.com/2d-inc/Flare-Flutter/tree/stable/example/teddy/lib with a little modification, you can use Stack and Positioned and change attribute value like top code snippet return Scaffold( backgroundColor: Color.fromRGBO(93, 142, 155, 1.0), body: Container( child: Stack( children: <Widget>[ Positioned( top: 50, left:0,

array of items as state in a StatefulWidget & ensuring “setState” only triggers updates for items in the array that has changed?

寵の児 提交于 2021-02-11 17:35:46
问题 Background - want to utilise a dynamic list of items for a StatefulWidget. In my usecase the widget will be calling a CustomePainter (canvas) so sometimes there will be a varying number of images to be drawn on the canvas, hence within parent StatefulWidget would like to have an "array of images". Question - if using an array as the state variable what do I need to do programmtically (if anything) to ensure only the items that have changed within the array do infact get "redrawn", in

How to update a single field of all documents in firestore using flutter?

北慕城南 提交于 2021-02-11 17:14:55
问题 I have a 100 user documents in database, and I have to update one field to 0 in all documents. How do we do it? 回答1: Firestore doesn't offer a SQL-like "update where" command that updates everything at once, so you will have to: Query for the documents to update Iterate each DocumentSnapshot and get its DocumentReference object using the reference property For each document, update the field with its new value 回答2: Try doing the following Query the documents to update Go through each

How to update a single field of all documents in firestore using flutter?

百般思念 提交于 2021-02-11 17:12:56
问题 I have a 100 user documents in database, and I have to update one field to 0 in all documents. How do we do it? 回答1: Firestore doesn't offer a SQL-like "update where" command that updates everything at once, so you will have to: Query for the documents to update Iterate each DocumentSnapshot and get its DocumentReference object using the reference property For each document, update the field with its new value 回答2: Try doing the following Query the documents to update Go through each

Flutter: Unable to make the Form scroll when the Keyboard is open

自闭症网瘾萝莉.ら 提交于 2021-02-11 16:57:42
问题 In my application, I am using a stack and a container . Within the container i have a form and its fields. Below is my code import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; class Login extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: LoginUI(), ); } } class LoginUI extends StatefulWidget { @override State<StatefulWidget> createState() { // TODO:

OAuth2: No login dialog after log out, direct log in of last user

喜夏-厌秋 提交于 2021-02-11 16:57:01
问题 I am building a flutter app that needs the user to authenticate against an identity provider in order to user the app. I am using the package simple_auth_flutter to do the authentication stuff. So far this works as expected: When clicking on the log in button, the users is queried for its credentials and after passing the correct credentials I get a valid token. I only got an issue, when the user logs out from the identity provider. When the user clicks on the log in button he gets