android - flutter ios无法运行,获取widgets库异常并丢失设备连接

标签 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

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/

相关文章:

ios - Apple Watch - 另一个启动 session 已经在等待调试带有标识符的应用程序扩展

java - 可以在使用 Asynctask 将文件上传到服务器时显示估计时间、kbs、mb

Android模拟器sdcard权限

android - 为什么在 Activity 开始时软键盘显示或不显示?

ios - TabBarController 图标在单击之前不显示 - 无 Storyboard

ios - 如何在我的模拟器上运行以前的 iOS 版本?

android - 使用 BroadCastReceiver 删除短信 - Android

ios - UITableView 高度变化时更新其他元素的约束

ios - 如何使用 pod 获取最新的 GoogleMaps SDK

ios - 使用本地主机 HTTPS 连接测试 iOS 应用程序不工作