ios抖动无法运行,导致小部件库异常和设备连接丢失

时间:2020-01-27 05:30:51

标签: android ios xcode flutter flutter-dependencies

在运行应用程序时出现以下错误?问题的可能原因是什么?

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

也尝试过:

颤振医生-v

干净整洁

1 个答案:

答案 0 :(得分:1)

错误说No Material widget found,所以TextField小部件必须是MaterialApp的子级。就像关注

class CustomWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: TextField(
          // ... named parameters for this widget
        ),
      ),
    );
}