flutter No Material widget found.

简介: flutter No Material widget found.
I/flutter (25517): No Material widget found.
I/flutter (25517): ListTile widgets require a Material widget ancestor.
I/flutter (25517): In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter's
I/flutter (25517): material library, that material is represented by the Material widget. It is the Material widget
I/flutter (25517): that renders ink splashes, for instance. Because of this, many material library widgets require that
I/flutter (25517): there be a Material widget in the tree above them.
I/flutter (25517): To introduce a Material widget, you can either directly include one, or use a widget that contains
I/flutter (25517): Material itself, such as a Card, Dialog, Drawer, or Scaffold.
I/flutter (25517): The specific widget that could not find a Material ancestor was:
I/flutter (25517):   ListTile

简而言之:

使用了Material 风格的widget 就需要Scaffold作为根布局


什么是Material 风格的widget,比如


  • AppBar
  • BottomAppBar
  • FloatingActionButton
  • Drawer
  • SnackBar
  • BottomSheet
  • BottomNavigationBar
  • ListTile

等等


需要Scaffold作为根布局,意为用Scaffold包裹起来即可


return Scaffold(
      appBar: AppBar( ),
      bottomNavigationBar: BottomNavigationBar( ),
      floatingActionButton: FloatingActionButton( ),
      drawer: Drawer(),
      .....
    );
目录
相关文章
|
1月前
|
存储 开发者 UED
Flutter笔记:谈Material状态属性-为什么FlatButton等旧版按钮就废弃了
Flutter笔记:谈Material状态属性-为什么FlatButton等旧版按钮就废弃了
33 4
|
1月前
|
缓存 iOS开发
Flutter run出现No Provisioning Profile was found for your project‘s Bundle Identifier or your device
Flutter run出现No Provisioning Profile was found for your project‘s Bundle Identifier or your device
32 2
|
1月前
|
存储 JSON 数据格式
解决使用flutter_intl出现警告No @@locale or _locale field found in intl_en
解决使用flutter_intl出现警告No @@locale or _locale field found in intl_en
44 2
|
1月前
|
开发工具 Android开发
Flutter: Android SDK not found at this location,Android Studio not found at xxx
Flutter: Android SDK not found at this location,Android Studio not found at xxx
116 2
|
1月前
|
API
Flutter 解决Type ‘MouseCursor‘ not found.
Flutter 解决Type ‘MouseCursor‘ not found.
35 0
|
2月前
Flutter-底部弹出框(Widget层级)
文章描述了如何在Flutter中使用DraggableScrollableSheet创建一个底部弹出框,同时保持其可手势滑动关闭。作者遇到问题并提出对原控件进行扩展,以支持头部和列表布局的滑动关闭功能。
138 0
|
3月前
Flutter StreamBuilder 实现局部刷新 Widget
Flutter StreamBuilder 实现局部刷新 Widget
29 0
|
4月前
|
Android开发
Flutter完整开发实战详解(六、 深入Widget原理),2024百度Android岗面试真题收录解析
Flutter完整开发实战详解(六、 深入Widget原理),2024百度Android岗面试真题收录解析
|
4月前
|
开发框架 前端开发 开发者
【Flutter前端技术开发专栏】Flutter的Material Design与Cupertino Design风格
【4月更文挑战第30天】Flutter框架支持Material Design和Cupertino Design两种设计风格,助力开发者创建吸引人的移动应用。Material Design基于现实世界物理规律,提供`Scaffold`、`Card`等组件,实现纸片效果和直观体验。Cupertino Design注重简洁图标和流畅动画,借助`CupertinoTabScaffold`、`CupertinoActivityIndicator`等组件呈现苹果风格界面。Flutter的`Theme`类允许统一管理应用样式,开发者可根据需求混搭两种风格,实现跨平台的优质用户体验。
137 0
【Flutter前端技术开发专栏】Flutter的Material Design与Cupertino Design风格
|
4月前
|
JavaScript 前端开发 开发者
【Flutter前端技术开发专栏】Flutter中的Widget与状态管理
【4月更文挑战第30天】本文探讨了Flutter的Widget和状态管理。Widget是Flutter构建UI的基础,分为有状态和无状态两种。状态管理确保UI随应用状态变化更新,影响应用性能和可维护性。文章介绍了`setState`、`Provider`、`Riverpod`、`Bloc`和`Redux`等状态管理方法,并通过计数器应用展示了其实现。选择合适的状态管理策略对高效开发至关重要。
63 0
【Flutter前端技术开发专栏】Flutter中的Widget与状态管理