我收到错误:在此之前应为“,”,在我的代码中指定Flutter中的主体

xxe27gdn  于 2022-12-24  发布在  Flutter
关注(0)|答案(2)|浏览(81)
@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar:AppBar(
        title: Text('New project',style: TextStyle(fontSize:25,color: Colors.green,decorationStyle: TextDecorationStyle.dotted ),),
    )
        body: Center(
         child: Column(
          children: <Widget>[
          Text('How many times pushed'),
          Text('ok')
      ],
    ),
    ),

    );

  }
}

当我尝试运行代码时,在靠近主体的地方出现错误“Expected ',' before this”,解决方案是什么

okxuctiv

okxuctiv1#

尝试以下代码,在主体开始前添加,

return Scaffold(
      appBar: AppBar(
        title: Text(
          'New project',
          style: TextStyle(
              fontSize: 25,
              color: Colors.green,
              decorationStyle: TextDecorationStyle.dotted),
        ),
      ),
      body: Center(
        child: Column(
          children: <Widget>[Text('How many times pushed'), Text('ok')],
        ),
      ),
    );

结果-〉

c0vxltue

c0vxltue2#

return Scaffold(
  appBar: AppBar(
    title: Text(
      'New project',
      style: TextStyle(
          fontSize: 25,
          color: Colors.green,
          decorationStyle: TextDecorationStyle.dotted),
    ),
  ), -----------------> add , here
  body: Center(
    child: Column(
      children: <Widget>[Text('How many times pushed'), Text('ok')],
    ),
  ),
);

相关问题