【问题标题】:(flutter) the return type MaterialApp{...} shows error : Type cant be returned from method 'build' as it has return type 'Widget'(颤抖)返回类型 MaterialApp{...} 显示错误:无法从方法“build”返回类型,因为它具有返回类型“Widget”
【发布时间】:2020-01-11 05:06:53
【问题描述】:
class MyApp extends StatelessWidget{
@override
  Widget build(BuildContext context) {
    return  MaterialApp{
      title:'First app',
    home: Scaffold(
       appBar: AppBar(
        title: Text('app'),
     ),
     body : Center(

        child: Text('Hello'),
   ),
   );
    };
}
}

第 3 行显示“MaterialApp”上的错误。

错误说明:

类型不能从方法'build'返回,因为它有返回类型 '小部件'。

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    嘿,Material App 应该是用 () 包裹的

    示例 => https://dartpad.dev/e7432b0d8c215625f3acf8aa8fbedb86

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-15
      • 2021-01-25
      • 2021-09-14
      • 1970-01-01
      • 1970-01-01
      • 2022-01-26
      • 1970-01-01
      • 2021-09-27
      相关资源
      最近更新 更多