Dart报错:参数类型'({Column child})'无法分配给'Widget?'类型
Flutter错误排查:The argument type '({Column child})' can't be assigned to the parameter type 'Widget?'
问题出在body属性的写法上:你给body赋值时,额外加了一层括号和child参数,但Scaffold的body本身直接接受Widget类型的组件,不需要这种包裹结构,这就导致类型不匹配报错。
修正后的代码:
class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.blue, title: Text("SHOP 1!"), // обернуть в padding и задать местоположение ), body: Column( children: [ Center( child: Padding( padding: const EdgeInsets.only(left: 0.0), child: ElevatedButton.icon( onPressed: () {}, icon: Icon( Icons.account_circle_rounded, size: 24.0, ), label: Text('Личный кабинет'), ), ) ) ], ), ); } }
内容的提问来源于stack exchange,提问作者Karnaval 964
相关产品推荐
相关产品推荐

