Closed
Description
这是我的错误日志:
Reload already in progress, ignoring request
════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building TextField(controller: TextEditingController#86c12(TextEditingValue(text: ┤├, selection: TextSelection(baseOffset: -1, extentOffset: -1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))), decoration: InputDecoration(filled: true, fillColor: Color(0xffefefef), border: _NoInputBorder()), style: TextStyle(inherit: true, color: Color(0xff000000), size: 13.3, height: 1.0x), dirty, state: _TextFieldState#8dc02):
No Material widget found.
TextField widgets require a Material widget ancestor.
In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter's material library, that material is represented by the Material widget. It is the Material widget that renders ink splashes, for instance. Because of this, many material library widgets require that there be a Material widget in the tree above them.
To introduce a Material widget, you can either directly include one, or use a widget that contains Material itself, such as a Card, Dialog, Drawer, or Scaffold.
The specific widget that could not find a Material ancestor was: TextField
controller: TextEditingController#86c12(TextEditingValue(text: ┤├, selection: TextSelection(baseOffset: -1, extentOffset: -1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1)))
看起来像是TextField组件需要有一个MaterialApp的祖先组件;
然而 我在使用OKToast的时候:
// main.dart 的build部分
Widget build(BuildContext context) {
return DoubleQuit(
child: OKToast(
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
textTheme: TextTheme().apply(decoration: TextDecoration.none)),
initialRoute: 'Home',
onGenerateRoute: onGenerateRoute,
)));
}
}
OKToast是包裹着MaterialApp的, 看起来使得TextField没有MaterialApp作为其祖先 ;导致了错误.
请问有什么解决方案么?