flutter ios не может работать, получая исключения из библиотеки виджетов и потерянное соединение с устройством - PullRequest
0 голосов
/ 27 января 2020

Я получаю следующую ошибку при запуске приложения. Что может быть причиной проблемы?

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

также пытался:

flutter doctor -v

чистый флаттер

1 Ответ

1 голос
/ 27 января 2020

Ошибка говорит о 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
        ),
      ),
    );
}
...