flutter ios 无法运行,获取小部件库异常和设备连接丢失
Posted
技术标签:
【中文标题】flutter ios 无法运行,获取小部件库异常和设备连接丢失【英文标题】:flutter ios can't run, getting widgets library exceptions and lost device connetion 【发布时间】:2020-05-12 11:58:07 【问题描述】:我在运行应用程序时收到以下错误问题的可能原因是什么?
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】:错误为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
),
),
);
【讨论】:
您能否发布基本小部件,您如何将其实现为演示代码,删除所有其他内容,如动画、动画控制器等。如果我不知道您的小部件层次结构并且不会是,颤振是嵌套小部件能够为您的案例提供正确的解决方案。从我上面回答的错误中。看看我提出的问题并为它写了一个演示:How to know pop event happened inside Nested Widget in Flutter以上是关于flutter ios 无法运行,获取小部件库异常和设备连接丢失的主要内容,如果未能解决你的问题,请参考以下文章