- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个代码,在该代码中我正在使用 firebase 进行注册。包括个人资料图像在内的数据将被存储到 Firestore。但问题是我遇到了多个我无法解决的错误。我的应用程序甚至还没有运行一次。其中一个错误是 "import:dart:html",我检查了所有 dart 文件,但没有找到任何未使用的 dart:html 导入。我使用 import"dart.io"作为术语“late File”。我也通过导入 dart:html 进行了尝试,但错误仍然存在。我还尝试删除 ProfileImage 的所有代码,但错误也仍然存在。以下是带有错误的 y 代码的所有文件:
错误
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
Invalid depfile: D:\Noum\Data\Uni Data\Codes\Android Studio\Flutter\firebase_flutter_app\.dart_tool\flutter_build\040ba043425f685efe2a35025cf4d63f\kernel_snapshot.d
Invalid depfile: D:\Noum\Data\Uni Data\Codes\Android Studio\Flutter\firebase_flutter_app\.dart_tool\flutter_build\040ba043425f685efe2a35025cf4d63f\kernel_snapshot.d
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-9.0.1/lib/src/storage.dart:2:8: Error: Not found: 'dart:html'
import 'dart:html';
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-9.0.1/lib/src/utils.dart:2:8: Error: Not found: 'dart:html'
import 'dart:html';
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.3/lib/js.dart:8:1: Error: Not found: 'dart:js'
export 'dart:js' show allowInterop, allowInteropCaptureThis;
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.3/lib/js_util.dart:8:1: Error: Not found: 'dart:js_util'
export 'dart:js_util';
^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-9.0.1/lib/src/auth.dart:340:25: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase/src/auth.dart' ('/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-9.0.1/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final nextWrapper = allowInterop((firebase_interop.UserJsImpl? user) {
^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-9.0.1/lib/src/auth.dart:344:26: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase/src/auth.dart' ('/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-9.0.1/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
final errorWrapper = allowInterop((e) => changeController.addError(e));
^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-9.0.1/lib/src/auth.dart:374:9: Error: The method 'allowInterop' isn't defined for the class 'Auth'.
- 'Auth' is from 'package:firebase/src/auth.dart' ('/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase-9.0.1/lib/src/auth.dart').
Try correcting the name to the name of an existing method, or defining a method named 'allowInterop'.
allowInterop((firebase_interop.UserJsImpl? user) {
^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 43s
Exception: Gradle task assembleDebug failed with exit code 1
flutter 医生
PS C:\Users\Nouma> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19042.1052], locale en-PK)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.57.1)
[√] Connected device (2 available)
• No issues found!
PS C:\Users\Nouma>
依赖
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_auth: ^2.0.0
firebase_core: ^1.3.0
auth_buttons: ^1.0.1+4
cloud_firestore: ^2.3.0
firebase_storage: ^9.0.0
google_sign_in: ^5.0.4
firebase_analytics: ^8.1.2
image_picker: ^0.8.1+3
shared_preferences: ^2.0.6
Register.dart ,这是编写所有代码的文件
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase/firebase.dart';
import 'package:firebase_auth/firebase_auth.dart' as route;
import 'package:firebase_flutter_app/ErrorAlertDialog.dart';
import 'package:firebase_flutter_app/StoreHome.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:image_picker/image_picker.dart';
import 'package:flutter/material.dart';
import 'CustomTextField.dart';
import 'LoadingDialog.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Register extends StatefulWidget {
const Register({Key? key}) : super(key: key);
@override
_RegisterState createState() => _RegisterState();
}
class _RegisterState extends State<Register> {
final TextEditingController _nametextEditingController=TextEditingController();
final TextEditingController _emailtextEditingController=TextEditingController();
final TextEditingController _passwordtextEditingController=TextEditingController();
final TextEditingController _cPasswordEditingController=TextEditingController();
final GlobalKey<FormState> _globalKey=GlobalKey<FormState>();
String userImageurl="";
late File _imagefile;
final _picker=ImagePicker();
static final String userID='uid';
static final String userName='name';
static final String userEmail='email';
static final String userAvatar='url';
static final String userPhotoUrl='photoUrl';
static final String userCartList='userCart';
SharedPreferences sharedPreferences=SharedPreferences.getInstance() as SharedPreferences;
@override
Widget build(BuildContext context) {
double _screenwidth=MediaQuery.of(context).size.width;
return SingleChildScrollView(
child: Container(
child: Column(
mainAxisSize:MainAxisSize.max,
children: [
SizedBox(height: 10.0,),
InkWell(
onTap:(){},
child: CircleAvatar(
radius: _screenwidth *0.15,
backgroundColor: Colors.white30,
// ignore: unnecessary_null_comparison
child: Icon(Icons.add_a_photo_outlined,size: _screenwidth *0.15,color: Colors.grey,),
//backgroundImage: _imagefile==null ? null: FileImage(_imagefile),
// ignore: unnecessary_null_comparison
// child: _imagefile==null ? Icon(Icons.add_a_photo_outlined,size: _screenwidth *0.15,color: Colors.grey,)
// :null,
),
),
SizedBox(height: 8.0,),
Form(
key: _globalKey,
child:Column(
children: [
CustomTextField(
controller: _nametextEditingController,
data: Icons.person,
hintText: 'Name',
isObsecure: false,
),
CustomTextField(
controller: _emailtextEditingController,
data: Icons.email,
hintText: 'Email',
isObsecure: false,
),
CustomTextField(
controller: _passwordtextEditingController,
data: Icons.password,
hintText: 'Password',
isObsecure: true,
),
CustomTextField(
controller: _cPasswordEditingController,
data: Icons.password,
hintText: 'Confirm Password',
isObsecure: true,
),
],
)
),
RaisedButton(
onPressed: ()
{
// uploadAndSaveImage();
},
color: Colors.blueGrey,
child: Text('Sign Up',style: TextStyle(color: Colors.white30),),
),
SizedBox(
height: 30.0,
),
Container(
height: 4.0,
width: _screenwidth* 0.8,
color: Colors.cyan,
),
SizedBox(
height: 15.0,
),
],
),
),
);
}
Future<void> _selectAndPickImage() async // ignore: unused_element
{
_imagefile = (await _picker.getImage(source: ImageSource.gallery) )as File;
}
Future<void> uploadAndSaveImage()async
{
// ignore: unnecessary_null_comparison
if(_imagefile==null)
{
showDialog(
context: context,
builder:(c)
{
return ErrorAlertDialog(message: 'Please Select an Image');
}
);
}
else
{
_passwordtextEditingController.text==_cPasswordEditingController.text
// ? is an 'if' condition
//if all these are true we will upload the image
? _emailtextEditingController.text.isNotEmpty
&& _passwordtextEditingController.text.isNotEmpty
&& _cPasswordEditingController.text.isNotEmpty
&&_nametextEditingController.text.isNotEmpty
? uploadToStorage()
//this dialogue is for the upper fields if they remains somehow empty
:displayDialog('Please fill the empty fields in form...')
:displayDialog('Password do not match');
}
}
displayDialog(String msg)
{
showDialog(context: context,
builder: (C)
{
return ErrorAlertDialog(message: msg);
}
);
}
uploadToStorage()async
{
showDialog(
context: context,
builder: (c){
return LoadingDialog(mesage: 'Authenticating, Please Wait!...',);
}
);
//unique name to upload it to firestore,and we will use datetime sp it won't repeat again
String imageFileName=DateTime.now().millisecondsSinceEpoch.toString();
StorageReference storageReference=FirebaseStorage.instance.ref().child(imageFileName) as StorageReference;
var uploadTask=storageReference.put(_imagefile);
UploadTaskSnapshot taskSnapshot=await uploadTask.future;
await taskSnapshot.ref.getDownloadURL().then((urlimage){
userImageurl=urlimage as String;
_registerUser();
});
}
route.FirebaseAuth _auth=route.FirebaseAuth.instance;
void _registerUser() async
{
route.User? userr;
await _auth.createUserWithEmailAndPassword(
email: _emailtextEditingController.text.trim(),
password: _passwordtextEditingController.text.trim(),
).then((auth) {
userr = auth.user!;
}).catchError((error) {
Navigator.pop(context);
showDialog(
context: context,
builder: (c) {
return ErrorAlertDialog(message: error.toString(),);
}
);
});
if (userr != null)
{
saveUserInfoToFirestore(userr!).then((value){
Navigator.pop(context);
//if the user registration gets successful we will send it to store home
Route route=MaterialPageRoute(builder: (c)=>StoreHome());
Navigator.pushReplacement(context, route);
});
}
}
Future saveUserInfoToFirestore(route.User firebaseUser) async
{
FirebaseFirestore.instance.collection('users').doc(firebaseUser.uid).set({
'uid':firebaseUser.uid,
'email':firebaseUser.email,
'name':_nametextEditingController.text.trim(),
'url':userImageurl,
});
await sharedPreferences.setString('uid', firebaseUser.uid);
await sharedPreferences.setString(userEmail, firebaseUser.email.toString());
await sharedPreferences.setString(userName, _nametextEditingController.text.trim());
await sharedPreferences.setString(userAvatar, userImageurl);
await sharedPreferences.setStringList(userCartList, ["garbageValue"]);
}
}
main.dart 文件:这里我使用 dart:async 作为方法“时间”
//import 'package:cloud_firestore/cloud_firestore.dart';
//import 'package:firebase/firestore.dart';
import 'dart:async';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
//import 'package:shared_preferences/shared_preferences.dart';
import 'AuthenticationScreen.dart';
import 'StoreHome.dart';
void main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
//SharedPreferences sharedPreferences=SharedPreferences.getInstance() as SharedPreferences;
//Firestore firestore=FirebaseFirestore.instance as Firestore;
// ignore: unnecessary_statements
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'E-Shop',
theme: ThemeData(
primarySwatch: Colors.blue,
),
debugShowCheckedModeBanner: false,
home: SplashScreen(),
);
}
}
class SplashScreen extends StatefulWidget{
@override
State<StatefulWidget> createState() => _splashproperties();
//=>(Fat Arrow is used to replace the braces and return)
}
class _splashproperties extends State<SplashScreen>{
@override
void initState(){
super.initState();
displaySplash();
}
displaySplash(){
FirebaseAuth auth=FirebaseAuth.instance;
Timer(Duration(seconds: 5), () async{
if(auth.currentUser!= null)
{
Route route=MaterialPageRoute(builder: (_)=>StoreHome());
Navigator.pushReplacement(context, route);
}
else{
Route route=MaterialPageRoute(builder: (_)=>AuthenticationScreen());
Navigator.pushReplacement(context, route);
}
});
}
Widget build(BuildContext context) {
return Material
(
child: Container
(
decoration: new BoxDecoration(
gradient: new LinearGradient(colors:[Colors.pink,Colors.lightGreenAccent],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0, 0.0),
stops: [0.0,1.0],
tileMode: TileMode.clamp,
)
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('images/xweb.jpg'),
SizedBox(height: 20.0),
Text("Number One We Are!!!!!!!",style: TextStyle(color: Colors.white30),
),
],
),
),
),
);
}
}
最佳答案
关于android - 未找到 : 'dart:html' import 'dart:html' ; I don't need dart:html and I also didn't used, 但我尝试通过导入它,但错误不会发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68325799/
我在使用 Typo3 时遇到问题。我可以通过 pagetree 添加新页面、文件夹等,但我无法添加,当我尝试这样做时出现错误: 抱歉,您没有执行此更改的适当权限。 日志中的第二个错误 SQL erro
过去几周我一直在学习 RabbitMQ。我正在尝试使用“ header ”交换来设置决策树类型路由。如果匹配的话我知道如何将其分支出来。但我想要一个“捕获所有”队列,仅当 header 与树中的其他任
我查询: select * from marrydays where YMD_X like '2010-1-%' and marrydays.CONG not like 'aa%'
我尝试发布我的应用程序:http://pomidoro.codeplex.com/在 Windows 应用商店和认证失败,因为:'您的应用不符合要求 1.1。来自测试者的评论:这个应用似乎没有提供值(
在 Django 中,我一直在尝试获取一个搜索字段来对位置进行地理编码,并从我的数据库中吐出一个按距离排序的列表。到目前为止,一切正常,除非我搜索 Google 返回多个结果形式的位置,例如“ann
当我打电话时 运行删除 ,那么它会调用run,那么为什么“ View 没有返回一个HttpResponse对象”发生呢? 谢谢:) View .py def run(request, build):
我的 Django 1.5 应用程序(托管在 webfaction 上)中有自定义用户模型,我得到: AssertionError at /admin/users/user/add/ sensitiv
这是我遇到的错误: View extraio.file_uploader.views.Upload_File 没有返回 HttpResponse 对象。 谁能看出我在这里做错了什么?我似乎无法弄清楚为
我有一个保存表单的简单 View 。代码看起来“干净”,但我无法摆脱错误: "The view didn't return an HttpResponse object." 虽然我在网上搜索过,但我没
在使用 Gradle 导入一堆 (2) 个库后,我在 Logcat 中收到以下错误: https://gist.github.com/devyanlab/1b18fbe67309f3a07d5d 我认
当我尝试多面对话(从 Google Home 切换到 Android Google Assistant)时,我收到“抱歉,我没有得到任何回应”。 我正在使用 Action SDK,语言环境是“ja”。
当我尝试在 Visual Studio python 中运行我的代码时,为什么会收到错误消息“我们没有找到任何解释器”? 最佳答案 您是否安装了合适的 Python 解释器?您安装了它但 Visual
我不明白为什么我会收到这个错误。一个新节点绝对应该能够容纳 pod。因为我只是要求 768Mi 内存和 450m CPU 的数量,并且将自动扩展的实例组的类型为 n1-highcpu-2 - 2 个虚
我正在关注此代码实验室 Facts about You: Build a conversational app for the Google Assistant 我让它工作了一次,但一定是做错了什么,
我在使用 adb 安装命令将一个简单的 APK 安装到模拟器时收到此错误消息:adb install 错误信息: [root@localhost MobileBenchmark]# cd /opt/a
当我使用核心数据将一些从互联网下载的图像保存在 collectionView 单元格中时,出现错误“NSInternalInconsistencyException”,原因:“-[UICollecti
我最近继承了一个实验室 Ubuntu LAMP 服务器,该服务器相对被忽视并且仍在运行 Struts 1.0 应用程序。我们正准备进行全面检修,但与此同时,日志中抛出的唯一错误是 javax.net.
我用谷歌搜索了一下,发现这是 PHP/Apache/MySQL 早期的一个问题,比如 PHP v5.2.4。但是我现在有那个问题,我做错了什么吗?或者有谁可以帮我解决这个问题吗? 日志文件多次打印:
为什么会出现这个错误? Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-
这个问题在这里已经有了答案: Eclipse error "ADB server didn't ACK, failed to start daemon" (23 个回答) Adb won't star
我是一名优秀的程序员,十分优秀!