我正在尝试在 Flutter for Web 应用程序中使用 Firebase 身份验证实现登录功能。我已经可以使用 Firestore 在同一个应用程序中存储/提取数据而无需登录。
执行应用程序时,它显示错误“NoSuchMethodError:试图调用非函数,例如null:'dart.global.firebase.auth'”
我认为错误是由调用auth()方法引起的。
你能建议我应该如何解决吗?或者,Firebase 身份验证不支持 Flutter for web 吗??
导入的 firebase.dart。 https://firebase.google.com/docs/reference/js/firebase
import 'package:firebase/firebase.dart';
使用 auth() 初始化对象并从参数调用登录方法。
final Auth _auth = auth();
Future<UserCredential> signIn(String email, String password) async {
final UserCredential user = await _auth.signInAndRetrieveDataWithEmailAndPassword(email, password);
return user;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用向上和向下箭头按钮创建一个数字输入字段,以增加和减少其值。我想知道是否有任何内置小部件已经提供了此功能。我必须在我的 UI 中创建几个这样的字段,创建这么多有状态的小部件让我想知道是否有更简单的方法。
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final title = 'Increment Decrement Demo';
return MaterialApp(
title: title,
home: NumberInputWithIncrementDecrement(),
);
}
}
class NumberInputWithIncrementDecrement extends StatefulWidget {
@override
_NumberInputWithIncrementDecrementState createState() =>
_NumberInputWithIncrementDecrementState();
}
class _NumberInputWithIncrementDecrementState
extends State<NumberInputWithIncrementDecrement> {
TextEditingController _controller = TextEditingController();
@override
void initState() {
super.initState();
_controller.text = "0"; // Setting the initial value for the field.
}
@override
Widget build(BuildContext context) {
return Scaffold( …Run Code Online (Sandbox Code Playgroud) 我正在尝试让我的 Flutter 应用程序在浏览器中运行,这取决于 firebase_database。没有任何关于如何做到这一点的文档,但我根据 firebase_core 和 firebase_auth 文档做出了一些假设:
https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_core/firebase_core_web
https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth_web
我的应用程序在 iOS 和 android 上运行,但我无法让数据库在 flutter web 中运行。
我已经设置了我的 index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flutter WebRTC Demo</title>
</head>
<body>
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase-database.js"></script>
<script>
const firebaseConfig = {
apiKey: '...',
authDomain: '...',
databaseURL: '...',
projectId: '...',
storageBucket: '...',
messagingSenderId: '...',
appId: '...'
};
firebase.initializeApp(firebaseConfig);
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用 firebase 数据库时,日志中出现错误:
MissingPluginException(No implementation found for method DatabaseReference#set on channel plugins.flutter.io/firebase_database)
package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 196:49 throw_
package:flutter/src/services/platform_channel.dart 319:7 …Run Code Online (Sandbox Code Playgroud) 我想用 Flutter web 创建一个简单的 web 应用程序,但是在我用这个文档创建了一些简单的应用程序后,我遇到了一些关于路由地址的问题,它会自动向地址栏上的 URL 添加一个哈希“#”符号,我想知道如何我可以从 URL 中删除这个标志,事实上,现在我在浏览器地址栏上看到这样的东西:http://[::1]:54587/#/register但我想实现这样的http: //[::1]:54587/注册。
我正在使用 Flutter Web 和 RESTful API 作为后端开发一个 Web 应用程序。因此,我尝试从 api 获取数据,使用 Flutter 模型对其进行序列化,然后返回结果。
问题是,我得到这个结果
Expected a value of type 'Map<String, dynamic>', but got one of type 'List<dynamic>'
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
这是我的颤振代码:
楷模
// To parse this JSON data, do
//
// final medicalRecordsModel = medicalRecordsModelFromJson(jsonString);
import 'dart:convert';
class MedicalRecordsModel {
MedicalRecordsModel({
this.id,
this.category,
this.fileName,
this.dateTimestamp,
this.description,
this.upload,
this.patientName,
this.age,
this.address,
this.userId,
this.patientId,
this.isActive,
});
final String id;
final String category;
final String fileName;
final String dateTimestamp;
final String description;
final String upload; …Run Code Online (Sandbox Code Playgroud) 我仅在使用 Flutter Web 版本时遇到此问题。2.8 和 2.10 ,当我尝试使用 Flutter 2.5.3 和其他早期版本时,问题不会发生。
列内的小部件示例:
SelectableText("'Lorem Ipsum is simply dummy '",)),
SizedBox(height: 20),
Divider(),
SelectableText("'Lorem Ipsum is simply dummy text '",)),
Run Code Online (Sandbox Code Playgroud)
输出:
当我单击可选文本旁边的底部可选或其他小部件时,它不会取消选择先前选择的文本,而且当我在另一个可选文本上选择新文本时,顶部的先前选择仍然突出显示,这不是我期望的行为。
最新版本的这个小部件是否有一些我没有注意到的变化?谢谢
嗨,我是一名移动应用程序开发人员,对 Web 开发不太熟悉,在加载 Flutter Web 应用程序(如 Gmail 加载屏幕)之前,我正在寻找任何实现进度指示器的方法。Flutter web 很酷,但加载应用程序需要一些时间。我们可以为此加载持续时间添加任何指标吗?在 flutter 中实现的任何代码都将是 flutter app 的一部分,它不会工作,应该有另一种方法来实现这一点。
我是 Flutter 的新手,正在使用 Flutter Web 应用程序,我的要求是创建和下载文本文件。像下面。
void getData() {
List<int> bytes = utf8.encode('this is the text file');
print(bytes); // Need to download this with txt file.
}
Run Code Online (Sandbox Code Playgroud)
谁能帮我实现这一目标
我是 flutter 的初学者,我已经学会了当屏幕大小从桌面到平板电脑再到移动设备时如何处理大小和文本渲染。但我想了解当我在同一屏幕模式下减小屏幕尺寸时,如何更改尺寸或调整内容。
例如 -
return Container(
child: new Row(
children: <Widget>[
new Column(
children: <Widget>[new Text("Hello World")],
),
new Column(
children: <Widget>[
new Text(
"This is a long text this is a long test this is This is a long text this is a long test this is This is a long text this is a long test this is This is a long text this is a long test this is This is a long text this is …Run Code Online (Sandbox Code Playgroud) 我有一个 Flutter Web 应用程序,它在本地运行良好,但在使用部署后
firebase deploy
Run Code Online (Sandbox Code Playgroud)
图像未显示在网站上,我检查了资产是否已通过跟踪上传,例如 my_app.firebaseapp.com/assets/assets/card.jpg。(并且图像在那里,所以它已经正确上传,但由于某种原因它没有显示在主页本身上)。
网址:https : //websitehostingtry.web.app/#/
https://websitehostingtry.web.app/assets/images/card.jpg
在本地运行相同时:
flutter run -d chrome --release
Run Code Online (Sandbox Code Playgroud)
我的 Pubspec.yaml 文件:
name: website_try
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- images/
Run Code Online (Sandbox Code Playgroud)
在我的飞镖代码中,我只是更改了默认代码以在计数器之后添加图像...
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
Expanded(
child: Image.network('assets/images/card.jpg'),
)
],
), …Run Code Online (Sandbox Code Playgroud)