我使用EasyLoading库(https://pub.dev/packages/flutter_easyloading)。一切正常。但是当我双击 TextFormField 时,会发生此错误。 我试图将MaterialApp设置为根窗口小部件,并将EasyLoading设置为子级,但这一次EasyLoading无法正常工作。 我的代码:
void main() {
runApp(MyApp());
configLoading();
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FlutterEasyLoading(
child: GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: MaterialApp(
home: StartPage(),
debugShowCheckedModeBanner: false,
),
));
}
}
答案 0 :(得分:1)
您可以在下面复制粘贴运行完整代码
来自官方示例https://github.com/huangjianke/flutter_easyloading#how-to-use
您可以将FlutterEasyLoading
放在builder
的{{1}}中
代码段
MaterialApp
工作演示
完整代码
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter EasyLoading',
theme: ThemeData(
primarySwatch: Colors.blue,
),
builder: (BuildContext context, Widget child) {
return FlutterEasyLoading(
child: GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: child,
));
},
home: StartPage(),
);
}
}