You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 00:37:09