dart

currentUser() is not working type why I am seeing the expression doesn't evaluate to a function, so it can't be invoked

岁酱吖の 提交于 2021-02-16 20:25:38
问题 I'm new in Flutter, I'm working on a simple authentication app when I registered i should navigate to the chat screen and i want to grab current user but when i call FireBaseAuth.instance.currentUser() I got an exception "the expression doesn't evaluate to a function, so it can't be invoked." Why I'm seeing this? Please Help import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flash_chat/constants.dart'; class ChatScreen extends

How do I get the directory of the current script, in Dart?

和自甴很熟 提交于 2021-02-16 16:06:45
问题 I want to know what the script's directory is. I have a command-line Dart script. 回答1: If you're doing this for a console based app (e.g. in a unit test) and intend to use the output to open a file for reading or writing, it's more helpful to use Platform.script.path : import "package:path/path.dart" show dirname, join; import 'dart:io' show Platform; main() { print(join(dirname(Platform.script.path), 'test_data_file.dat'); } The result of that command can be used with a File object and be

Dart Convert IEEE-11073 32-bit FLOAT to a simple double

纵然是瞬间 提交于 2021-02-16 15:34:07
问题 I don't have much experience working with these low level bytes and numbers, so I've come here for help. I'm connecting to a bluetooth thermometer in my Flutter app, and I get an array of numbers formatted like this according to their documentation. I'm attempting to convert these numbers to a plain temperature double, but can't figure out how. This is the "example" the company gives me. However when I get a reading of 98.5 on the thermometer I get a response as an array of [113, 14, 0, 254]

Persisting data in a flutter application

天涯浪子 提交于 2021-02-16 15:32:13
问题 I am building an app and in it, I have the names of people in a list from which I could add/delete, etc.. The problem is this list is not saved when I close the app, which is inconvenient. I heard you can use shared Preferences to save simple objects like this, without complicating things like using SQLite and json. So I'd like to know what's the suggested way to persist this data and load it etc. Thanks in Advance and have a great day :) Here is the code: import 'package:flutter/material

How to fix this nullOk error when using the flutter_svg package?

佐手、 提交于 2021-02-16 15:15:08
问题 I connected the package, added it to main.dart, I try to compile the application, but I get this error. Help! What should I do about it? error Launching lib\main.dart on XT1562 in debug mode... Running Gradle task 'assembleDebug'... /D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name 'nullOk'. context != null ? Localizations.localeOf(context, nullOk: true) : null, ^^^^^^ /D:/flutter/packages/flutter/lib

Understanding Brackets in Dart (Flutter)

时光毁灭记忆、已成空白 提交于 2021-02-16 15:13:11
问题 I have many confusion about Brackets in Dart (Flutter). Which bracket "(), {}, []" is used for what? 回答1: () can group expressions: var x = (1 + 2) * 3; or can designate parameter lists for functions: var getAnswer = () => 42; int square(int x) => x * x; or can designate function calls: var answer = getAnswer(); var squared = square(4); or is part of the syntax to some keywords. This includes (but is not limited to) if , assert , for , while , switch , catch : if (condition) { ... } assert

How to fix this nullOk error when using the flutter_svg package?

可紊 提交于 2021-02-16 15:13:07
问题 I connected the package, added it to main.dart, I try to compile the application, but I get this error. Help! What should I do about it? error Launching lib\main.dart on XT1562 in debug mode... Running Gradle task 'assembleDebug'... /D:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name 'nullOk'. context != null ? Localizations.localeOf(context, nullOk: true) : null, ^^^^^^ /D:/flutter/packages/flutter/lib

How to enable Null-Safety in Flutter?

本秂侑毒 提交于 2021-02-16 10:25:57
问题 I tried to use null safety, but it's giving me this error: This requires the 'non-nullable' language feature to be enabled. Try updating your pubspec.yaml to set the minimum SDK constraint to 2.10.0 or higher, and running 'pub get'. I changed my Dart SDK constraint from 2.7.0 to 2.10.0 , but it's still showing this error. Also I upgraded my Dart and Flutter SDK: dart-sdk v2.10.2 is the latest version available based on your source(s). Flutter (Channel stable, 1.22.3, ... 回答1: Null safety is

Passing class static factory as method parameter in Dart

独自空忆成欢 提交于 2021-02-16 06:43:07
问题 I'm currently attempting to abstract making different HTTP requests by using generics. I'm using json_serializale for generating fromJson() and toJson() methods. Here is a simple model file: import 'package:json_annotation/json_annotation.dart'; part 'article.g.dart'; @JsonSerializable() class Article { int id = 0; String title = ""; Article({this.id, this.title}); factory Article.fromJson(Map<String, dynamic> json) => _$ArticleFromJson(json); Map<String, dynamic> toJson() => _$ArticleToJson

Google Drive Consent Screen Stuck

被刻印的时光 ゝ 提交于 2021-02-16 05:21:00
问题 I am trying to backup the application data of my android app on Google Drive. Therefore I request access to the https://www.googleapis.com/auth/drive.appdata, https://www.googleapis.com/auth/drive.file scopes using the google_sign_in package. I created a project on the Google Developer Console, enabled the Drive API and added the scopes to the OAuth Consent Screen and added an OAuth Client ID with the package name and the SHA-1 of the debug key. The application works fine if I don't request