我在运行应用程序时收到以下错误 问题的可能原因是什么?
Launching lib/main.dart on iPhone 8 Plus in debug mode...
Xcode build done. 48.9s
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building TextField(controller:
flutter: TextEditingController#a4d28(TextEditingValue(text: ┤├, selection: TextSelection(baseOffset: -1,
flutter: extentOffset: -1, affinity: TextAffinity.downstream, isDirectional: false), composing:
flutter: TextRange(start: -1, end: -1))), enabled: false, decoration: InputDecoration(labelText: "Receiving
flutter: UPI Address", hintText: "address@upi", border: OutlineInputBorder(), alignLabelWithHint: false),
flutter: dirty, state: _TextFieldState#cc557):
flutter: No Material widget found.
flutter: TextField widgets require a Material widget ancestor.
flutter: In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter's
flutter: material library, that material is represented by the Material widget. It is the Material widget
flutter: that renders ink splashes, for instance. Because of this, many material library widgets require that
flutter: there be a Material widget in the tree above them.
flutter: To introduce a Material widget, you can either directly include one, or use a widget that contains
flutter: Material itself, such as a Card, Dialog, Drawer, or Scaffold.
flutter: The specific widget that could not find a Material ancestor was:
flutter: TextField
also tried :
flutter doctor -v
flutter clean
最佳答案
错误提示未找到 Material 小部件
,因此 TextField
小部件必须是 MaterialApp
的子级。喜欢下面的内容
class CustomWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: TextField(
// ... named parameters for this widget
),
),
);
}
关于android - flutter ios无法运行,获取widgets库异常并丢失设备连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59925545/