我在颤振(飞镖)中遇到一些错误
Posted
技术标签:
【中文标题】我在颤振(飞镖)中遇到一些错误【英文标题】:I am getting some errors in flutter(dart) 【发布时间】:2021-12-07 17:41:30 【问题描述】:我正在 YouTube 上观看有关 Flutter 的教程。我来到了 Firebase 部分。但是,我在这部分遇到了错误。即使我输入相同的内容,我也会收到错误消息。我想我遇到了这样的错误,因为 Flutter 语言有更新。很抱歉我的英语不好。提前感谢您对我的帮助。
错误图片:
main.dart
import 'package:firebasedenemem/singup_screen.dart';
import 'package:flutter/material.dart';
void main()
runApp(const MyApp());
class MyApp extends StatelessWidget
const MyApp(Key? key) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context)
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const SignupScreen());
signup_screen.dart
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'dart:io';
class SignupScreen extends StatefulWidget
const SignupScreen(Key? key) : super(key: key);
@override
_SignupScreenState createState() => _SignupScreenState();
class _SignupScreenState extends State<SignupScreen>
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final picUrl = "";
File? _image;
final TextEditingController _nameController = TextEditingController();
final TextEditingController _lastnameController = TextEditingController();
final TextEditingController _emailController = TextEditingController();
FirebaseAuth auth = FirebaseAuth.instance;
@override
Widget build(BuildContext context)
return Container(
padding: EdgeInsets.only(top: 30),
color: Colors.grey[800],
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Image(
image: AssetImage("assets/images/logo.png"),
width: 200,
height: 100,
),
Container(
margin: const EdgeInsets.only(top: 10),
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 11),
color: Colors.white,
borderRadius: const BorderRadius.only(
topRight: Radius.circular(122),
bottomLeft: Radius.circular(122),
)),
),
],
),
);
【问题讨论】:
嗯“了解如何在...处解决此问题”您是否错过了这部分错误? 【参考方案1】:打开/android/app/build.gradle
文件。在dependencies
下添加multidex 模块,并在defaultConfig
中启用它:
android
defaultConfig
// ...
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
dependencies
implementation 'com.android.support:multidex:1.0.3'
此链接中的更多详细信息: https://firebase.flutter.dev/docs/installation/android
另请参阅此答案,它适用于您的情况: Flutter Firestore causing D8: Cannot fit requested classes in a single dex file (# methods: 71610 > 65536) in Android Studio
【讨论】:
我通过在 voidWidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp();
中编写这段代码来修复它以上是关于我在颤振(飞镖)中遇到一些错误的主要内容,如果未能解决你的问题,请参考以下文章
错误:未找到:'dart:html' 使用带有颤振的 googleapis_auth 飞镖团队包时