Flutter

flutter bloc and how a bloc state change can then trigger a 2nd async call before updating the Widget/UI with both? (code attached)

此生再无相见时 提交于 2021-01-29 15:32:52
问题 How would one load a set of local images for display in a widget (noting this is async - see function below) triggered by (based on) a change in state from a flutter_bloc for “settings”? Noting this bloc is persisted too via hydrated_bloc. So the use case for which I’m asking how do I code this in flutter (noting I’m using flutter_bloc) is: Use Case - Render different set of images on the same Widget I have for dynamically displaying a room for a 2D point & click adventure type game, BASED ON

Duplicate Keys Error in Flutter List View

不问归期 提交于 2021-01-29 15:22:04
问题 I have this form that is filled out and then when submitted, it makes a separate List Tile in List View in Nosql. Here is the part where I make the 'food' item and on 'submit' button clicked, it makes the item and sends it to list view on the next screen. Notice how each food item has a uniqueID which is Uuid random string. class FoodForm extends StatefulWidget { final Food food; final int foodIndex; FoodForm({this.food, this.foodIndex}); @override State<StatefulWidget> createState() { return

How to read Http response from flutter?

六月ゝ 毕业季﹏ 提交于 2021-01-29 14:44:58
问题 I'm trying to read reponse from HTTP in flutter but I didnt read. I posted the request. Can anyone know, what is wrong ? final http.Client client; Future<http.Response> post( Uri uri, { Map<String, dynamic> postParams, String accessToken, }) async { log.info(uri.toString()); log.info('postParams: ${postParams?.toString()}'); ///Encode map to bytes String jsonString = json.encode(postParams); List<int> bodyBytes = utf8.encode(jsonString); Map headers = { HttpHeaders.contentTypeHeader:

Rendering issue while centering Font Awesome icon

前提是你 提交于 2021-01-29 14:34:34
问题 I don't understand why this FAB doesn't center it's child. I've tried different things but cannot make it to center perfectly. Because adding for example padding only bottom to the icon could make it center on a Device but maybe not for all. this is my code Theme( data: Theme.of(context).copyWith( highlightColor: Colors.red, splashColor: Colors.red), child: SizedBox( height: MediaQuery.of(context).size.height / 7, width: MediaQuery.of(context).size.height / 7, child: FloatingActionButton(

Flutter assets image not find

好久不见. 提交于 2021-01-29 14:27:04
问题 I use Visual studio code and Andriod studio IDE and different AVD managers but when I run app with Image asset get an error No file or variants found for asset: assets/puffin.jpeg. Simple example: main.dart import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { var title = 'Web Images'; return MaterialApp( title: title, home: Scaffold( appBar: AppBar( title: Text(title), ), body: Container(

Align Scrollable Tabs On Left

我只是一个虾纸丫 提交于 2021-01-29 14:09:12
问题 When i set my tabs to scrollable, it will set all my tabs to the center. But i want to find a way that i can align all the tabs to the left. Is there a way for me align the tabs on the left instead of center? Here is my code. Thank you. class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: colorPrimary, accentColor: colorAccent,

Get list of documents inside different collections with Firestore in Flutter

烈酒焚心 提交于 2021-01-29 14:01:10
问题 I have a list of users with different portfolios. Each portfolio has the same properties but also a collection of investments. It'd be something like this: Map user = { "name": "John", "portfolios": [ // collection { "title": "My portfolio 1", "investments": [ // collection {"title": "My investment 1.2"}, {"title": "My investment 1.2"} ] }, { "title": "My portfolio 2", "investments": [ // collection {"title": "My investment 2.1"}, {"title": "My investment 2.2"}, {"title": "My investment 2.3"}

How can I put retrieved data from firebase to a widget in Flutter?

旧街凉风 提交于 2021-01-29 13:56:12
问题 final String uid; final firestoreInstance = Firestore.instance; void printData() async{ var firebaseUser = await FirebaseAuth.instance.currentUser(); firestoreInstance.collection("users").document(firebaseUser.uid).get().then((value){ print(value.data); }); } So this function prints to console the retrieved data from firebase firestore when I press the button. But I want to put them into a widget and display them in my app. For ex: Text(printData()) - but it's not allowed. How can I do that?

Flutter making a directory index [closed]

对着背影说爱祢 提交于 2021-01-29 13:55:12
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 months ago . Improve this question Im facing challenge creating a directory with alphabet index. I have List<Map<String, dynamic>> of shops like below: var shops = [ {'name':'Thrifty','products':'cars', 'delivery':'no'}, {'name':'Pizza Express','products':'pizza', 'delivery':'yes'}, {'name':'Fastmart',

Flutter - How to prevent ScrollView scroll when I drag a slider on it?

ε祈祈猫儿з 提交于 2021-01-29 13:54:08
问题 I put a slider on a CustomScollView, When I drag the slider, the scrollview will scroll up and down slightly, so my question is When I drag the slider, how to fibidden scroll of the scrollview? This slider is custom slider which extends RenderConstrainedBox class _RenderCupertinoSlider extends RenderConstrainedBox { _RenderCupertinoSlider(){ _drag = new HorizontalDragGestureRecognizer() ..onStart = _handleDragStart ..onUpdate = _handleDragUpdate ..onEnd = _handleDragEnd; }