我正在使用Firebase和Flutter进行电话身份验证的应用程序。我没有使用任何表单字段,但我得到了AutoValidateMode
未找到的错误。我一直在寻找解决方案,因为2天在网上,但无法找到一个。代码如下。
import 'dart:async';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:sms_autofill/sms_autofill.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.green,
),
home: MyHomePage(title: 'Phone Auth'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final FirebaseAuth _auth = FirebaseAuth.instance;
final _scaffoldKey = GlobalKey<ScaffoldState>();
final TextEditingController _phoneNumberController = TextEditingController();
final TextEditingController _smsController = TextEditingController();
String _verificationId;
final SmsAutoFill _autoFill = SmsAutoFill();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
key: _scaffoldKey,
resizeToAvoidBottomInset: false,
body: Padding(
padding: const EdgeInsets.all(8),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
TextFormField(
controller: _phoneNumberController,
decoration: const InputDecoration(
labelText: 'Phone number (+xx xxx-xxx-xxxx)'),
),],
)),
));
}
}
对于这个代码,我得到如下错误。
../../../../.pub-cache/hosted/pub.dartlang.org/pin_input_text_field-3.3.0/lib/src/widget/pin_widget.dart:402:5: Error: Type 'AutovalidateMode' not found.
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/pin_input_text_field-3.3.0/lib/src/widget/pin_widget.dart:402:5: Error: 'AutovalidateMode' isn't a type.
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/pin_input_text_field-3.3.0/lib/src/widget/pin_widget.dart:402:41: Error: Getter not found: 'AutovalidateMode'.
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/pin_input_text_field-3.3.0/lib/src/widget/pin_widget.dart:436:13: Error: No named parameter with the name 'autovalidateMode'.
autovalidateMode: autovalidateMode,
^^^^^^^^^^^^^^^^
如何解决这个问题?在哪里编辑AutoValidateMode
总是?您的帮助是非常感谢。
1条答案
按热度按时间0h4hbjxa1#
在浏览错误时,它提到找不到正在使用的AutoValidateMode。看起来
AutoValidateMode
是在Flutter 1.22稳定版上发布的,在之前的版本上不可用。这在Breaking Changes page上有记录。更新到最新的Flutter版本应该可以解决这个问题。