重复命名的论点-如何在一个扑腾的body上添加一个以上的孩子



import'package:flutter/material.dart';

第18行错误:

错误:已指定命名参数"child"的参数。尝试删除其中一个命名参数,或更正其中一个名称以引用其他命名参数。dart(duplicate_named_argument(

为什么身体不能有一个以上的孩子?如何解决?

class mainMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Bar Iland"),
),
body: Center(
child:
Image.asset(
'assets/Bar_Iland_line.png',
height: 200,
color: Colors.black.withOpacity(0.80),
),
child:
Column( 
children: <Widget>[
Spacer(flex: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children:[                  
SizedBox.fromSize(
size: Size(90, 90), // button width and height
child: ClipOval(
child: Material(
color: Colors.orange, // button color
child: InkWell(
splashColor: Colors.green, // splash color
onTap: () {}, // button pressed
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.call), // icon
Text("Call"), // text
],
),
),
),
),
),
SizedBox.fromSize(
size: Size(90, 90), // button width and height
child: ClipOval(
child: Material(
color: Colors.orange, // button color
child: InkWell(
splashColor: Colors.green, // splash color
onTap: () {}, // button pressed
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.call), // icon
Text("Call"), // text
],
),
),
),
),
),
SizedBox.fromSize(
size: Size(90, 90), // button width and height
child: ClipOval(
child: Material(
color: Colors.orange, // button color
child: InkWell(
splashColor: Colors.green, // splash color
onTap: () {}, // button pressed
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.call), // icon
Text("Call"), // text
],
),
),
),
),
),
],
),
Spacer(flex: 1),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children:[
SizedBox.fromSize(
size: Size(90, 90), // button width and height
child: ClipOval(
child: Material(
color: Colors.orange, // button color
child: InkWell(
splashColor: Colors.green, // splash color
onTap: () {}, // button pressed
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.call), // icon
Text("Call"), // text
],
),
),
),
),
),
SizedBox.fromSize(
size: Size(90, 90), // button width and height
child: ClipOval(
child: Material(
color: Colors.orange, // button color
child: InkWell(
splashColor: Colors.green, // splash color
onTap: () {}, // button pressed
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.call), // icon
Text("Call"), // text
],
),
),
),
),
),
SizedBox.fromSize(
size: Size(90, 90), // button width and height
child: ClipOval(
child: Material(
color: Colors.orange, // button color
child: InkWell(
splashColor: Colors.green, // splash color
onTap: () {}, // button pressed
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.call), // icon
Text("Call"), // text
],
),
),
),
),
),
],
),
Spacer(flex: 10),
],
),
),
);
}
}

正如pskink所提到的,一个身体里不能有两个孩子。

使用

Scaffold(
body: Column( // or Row or Wrap 
children: [
Child1(),
Child2(),
]
)
)

最新更新