Flutter bug 踩坑 flutter No Material widget found.

268 阅读1分钟

简而言之: 使用了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(),
      body:Row()

      .....
    )
  1. An InputDecorator, which is typically created by a TextField, cannot have an unbounded width.

TextField需要指定边界,例如外层包一个SizedBox,或者添加Expanded

SizedBox(
  width: 150.0,
  height: 150.0,
  child: TextField(

  ),
)