flutter No Material widget found.

举报
yechaoa 发表于 2022/05/31 00:13:06 2022/05/31
【摘要】 I/flutter (25517): No Material widget found. I/flutter (25517): ListTile widgets require a Material wi...
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

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

简而言之:

使用了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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

文章来源: blog.csdn.net,作者:yechaoa,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/yechaoa/article/details/90693377

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。