dart

Flutter - How to format title and body of notification in background?

十年热恋 提交于 2021-02-11 14:59:19
问题 I am trying to display localized notification in flutter using firebase_messaging, I am getting a json with 3 language strings in body of a notification like so: {"it": "italian text", "de": "german text", "en": "english text"} As of now, it is showing the whole json string in the notification tray. How can I select the appropriate language text from the json and show in notification when app is in background? myBackgroundMessageHandler this function is never called. Thanks. 回答1: I could not

Remove dynamically a widget from a dynamically created list flutter

不羁岁月 提交于 2021-02-11 14:46:55
问题 I followed this example to remove a desired element from a list, and it worked fine. I then made some changes as the size of my list is not predefined (aka 5 in the example), but changes through a button. After adapting the code to my needs, I observed two problems: The elements hash codes changes everytime I hit + to add a new element. Is this correct as it's redrawing the list, or is incorrect? When deleting an element, besides changing the hash codes of all the other elements, only the

Json parsing in dart (flutter)

守給你的承諾、 提交于 2021-02-11 14:30:40
问题 I'm new to Flutter and doesn't know much about complex json parsing. I've consulted few online articles but didn't find any suitable solution. My json is as follows { "EmployeeName":"EmployeeName", "Incidents" : [ { "Id":"1", "Text":"Text", "Photos":[ { "PhotoUrl" : "http://myphoto.com" }, { "PhotoUrl" : "http://myphoto.com" } ], "Notes" : [ { "Note":"Note" }, { "Note":"Note" } ] } ] } Any help would be great. 回答1: import 'package:flutter/material.dart'; import 'package:flutter/services.dart'

Flutter display sql data in ListTile instead of DataCell

时光总嘲笑我的痴心妄想 提交于 2021-02-11 14:24:03
问题 I am displaying a list of data fetched from my sql database using DataCell , but I don't really like how it looks and want to switch it to display it using ListTile , this is the code that I am using to display it using DataCell : return SingleChildScrollView( scrollDirection: Axis.vertical, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: DataTable( columns: [ DataColumn( label: Text(''), ) ], rows: _chatUsers .map( (user) => DataRow(cells: [ DataCell( Text(user

same Firestore realtime database for client and user

妖精的绣舞 提交于 2021-02-11 14:23:13
问题 I want to make a Flutter app for showing shop details. I stored data in the Firestore real-time database. It's working perfectly. What I want to do now is make another app for the owner, then he can change data in Firestore and also send push notifications to shop app users. Is this possible? It would be helpful If you have any tutorials or videos.I haven't tried cloud functions because they need a credit card, Which I don't have. 来源: https://stackoverflow.com/questions/65352286/same

Flutter Getx - “Xxx” not found. You need to call “Get.put(Xxx())” - But i have called Get.put(Xxx())

醉酒当歌 提交于 2021-02-11 14:16:48
问题 I have this global bindings class to initialise some services and I need it to be initialised straight away: import 'package:get/get.dart'; import 'package:vepo/data/data_provider/local_data_provider.dart'; import 'package:vepo/data/data_source/local_data_source.dart'; import 'services/authentication_service.dart'; class GlobalBindings extends Bindings { final LocalDataProvider _localDataProvider = LocalDataProvider(); @override void dependencies() { Get.put<AuthenticationService>

How to create a toggle/switch button in Flutter?

≡放荡痞女 提交于 2021-02-11 14:15:17
问题 I'm looking for a way to add a toggel / switch button in Flutter but so far haven't found the desired result. I'm creating the layout for an APP as it's in the attached screenshot but stuck on the toggle / switch button part which will switch the language of the APP . 回答1: Here's how you can implement the toggle design you wanted : import 'package:flutter/material.dart'; import 'package:get/get.dart'; class AnimatedToggle extends StatefulWidget { final List<String> values; final ValueChanged

Flutter Firebase How to make Sequential Query

喜欢而已 提交于 2021-02-11 14:13:59
问题 I am developing a forum application. There are two collections related to user information and topic information in my Firebase database. In the forumTopics collection, I keep the data on each forum topic. When I make a Firebase query, I want to get the data of this topic along with the data of the user corresponding to the topicAuthorUID value. For example, I want to extract the name, avatar information from the document of the user whose topicAuthorUID value is XXX in the userData

DataTable: Get the value of the first cell from a selected row

末鹿安然 提交于 2021-02-11 14:01:33
问题 I'm trying to delete a selected row from a DataTable by retrieving the value of the first cell (id) and passing it to the deleteRow function. How do I get this value? child: DataTable( columns: data.first.keys .map((dynamic keys) => DataColumn(label: Text(keys.toString()))) .toList(), rows: data.map((map) { return DataRow( onSelectChanged: (bool selected) { if (selected) { try { //determine the id of the selected row int selectedId = /*get index of selected row and return value of the first

Flutter Firebase Loop over collection in a document [duplicate]

自作多情 提交于 2021-02-11 14:01:10
问题 This question already has an answer here : Using Flutter Firestore plug in, do something for each sub collection in a document (1 answer) Closed last year . I have this path in my Database: /messages/tT2Q16n1FMZoTNZQOejtWuJdCmD2/ZqihbgR7skcytLAe88fQecmxcIc2-tT2Q16n1FMZoTNZQOejtWuJdCmD2/1579626761580 and from here I have to get content . I am trying this: var snapshot = Firestore.instance.collection('messages').document(user.id).snapshots(); but how can I loop over these items and get content