我在遵循简单代码时遇到了这个奇怪的错误:
The named parameter children isnt defined.
import 'package:flutter/material.dart';
class Test extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
body: Center(
children: <Widget>[
Text('Hello World'),
RaisedButton(
onPressed: null,
child: const Text('Disabled Button'),
)
]),
);
}
}
谁能找出错误?我觉得我瞎了。。。 最好的问候。
最佳答案
Center
不接受 child ,只有 child (一个小部件),你可以在你的中心内添加一个Column
Center(
child: Column(children: <Widget>[
Text('Hello World'),
RaisedButton(
onPressed: null,
child: const Text('Disabled Button'),
)
])
),
关于flutter - 未定义命名参数子项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55347064/