Flutter

Dart/Flutter Not converting local date time to UTC correctly

梦想的初衷 提交于 2021-02-11 15:14:30
问题 I am building a flutter/firebase chat app and storing timestamps of messages in UTC. I am using this line of code to convert local time to UTC. 'time': DateTime.now().toUtc().toString(), When I tested this with two users one is in Virginia, US, and the other one in Sri Lanka. The timestamp of the user in Sri Lanka is converted correctly to UTC, but for user in Virginia time is correct but the date as of yesterday. Sri Lanka Time: 2020-06-21 20:50:48 UTC converted: 2020-06-21 15:20:48.027446Z

Flutter how to detect device language?

感情迁移 提交于 2021-02-11 15:14:15
问题 I have a question how can i detect device language and according to that when app starts initially give a proper language ? Please if possible provide an example with code. 回答1: Calling Localizations.localeOf(context).languageCode should return you the languageCode. MaterialApp creates and uses a default Localization if not provided and then you can call it after the MaterialApp to know the language it's currently using the device and update your app with that information with your State

Flutter - How to Show Today, Tommorow after comparing the date in db with present date?

♀尐吖头ヾ 提交于 2021-02-11 15:08:39
问题 Show day for ex:- today, tommorow, 28 Dec 2020 etc after comparing date from sqlite db in a list tile with present date. And also delete a particular item from list on app start if the day was yesterday. In present it is showing like 21-11-2020 and if the date has expired also it still continues to show. This is my Code List<Note2> items2 = new List(); DatabaseHelper2 db2 = new DatabaseHelper2(); db2.getAllNotes2().then((notes2) { setState(() { notes2.forEach((note2) { items2.add(Note2

Can't pick image from gallery

丶灬走出姿态 提交于 2021-02-11 15:08:06
问题 I am coding an application for recognizing plant species. I want to pick an image and show that on screen but i can't. Image returns null. Although i choose photo from gallery, it still says "no image selected". I also added read_external_storage permission to android manifests. import 'dart:io'; import 'package:tflite/tflite.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; class PlantSpeciesRecognition extends StatefulWidget { var model;

Flutter - How to Show Today, Tommorow after comparing the date in db with present date?

回眸只為那壹抹淺笑 提交于 2021-02-11 15:04:38
问题 Show day for ex:- today, tommorow, 28 Dec 2020 etc after comparing date from sqlite db in a list tile with present date. And also delete a particular item from list on app start if the day was yesterday. In present it is showing like 21-11-2020 and if the date has expired also it still continues to show. This is my Code List<Note2> items2 = new List(); DatabaseHelper2 db2 = new DatabaseHelper2(); db2.getAllNotes2().then((notes2) { setState(() { notes2.forEach((note2) { items2.add(Note2

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

百般思念 提交于 2021-02-11 15:01:42
问题 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

Android resource linking failed Flutter

杀马特。学长 韩版系。学妹 提交于 2021-02-11 15:01:34
问题 I am running into this weird issue where I am getting this error. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > Android resource linking failed C:\Users\live\project_backup\build\file_picker\intermediates\library_manifest\debug\AndroidManifest.xml:9:5-15:15: AAPT: error: unexpected element <queries> found in <manifest>. * Try

Connecting Flask Socket.IO Server and Flutter

。_饼干妹妹 提交于 2021-02-11 14:59:50
问题 Basically, I have a socket io flask code: import cv2 import numpy as np from flask import Flask, render_template from flask_socketio import SocketIO, emit from threading import Lock,Timer as tmr from engineio.payload import Payload import base64 from PIL import Image import io app = Flask(__name__) app.config['SECRET_KEY'] = 'secret!' socketio = SocketIO(app) @socketio.on('connect') def connect(): print("a client connected") @socketio.on('disconnect') def disconnect(): print('Client

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

How to use the same Firebase Auth for Two different Flutter apps?

喜夏-厌秋 提交于 2021-02-11 14:59:03
问题 I developed two different Flutter applications. An Admin Version and another Client Version. I would like to use the same login (auth) and access to Storage for both Apps. 回答1: It's definitely possible to access the same Firebase project from two different apps. In fact, when these apps are locally part of the same "application", that is actually an intended use-case. A few things to keep in mind though: Firebase Authentication does not have the concept of an administrator user. It "merely"