I am trying to have an ElevatedButton widget in this stateless widget. The hierarchy of the brackets is ok but it is not recognizing the ElevatedButton widget being a parameter of child
class buildProfileView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisSize: MainAxisSize.min,
children: [
Center(
child: CircleAvatar(
backgroundImage:
Image.network(controller.googleAccount.value?.photoUrl ?? '')
.image,
radius: 100,
),
),
Text(
controller.googleAccount.value?.displayName ?? '',
style: Get.textTheme.headline1,
),
Text(controller.googleAccount.value?.email ?? '',
style: Get.textTheme.bodyText1),
//),
],
child: ElevatedButton(
onPressed: () {},
child: Text('Continue to Main Menu'),
backgroundColor: Colors.blue,
),
),
);
}
}
CodePudding user response:
The issue lies on code-strucure
//),
],
child: ElevatedButton(
onPressed: () {},
where ElevatedButton
is out of the column scope.
It will be
body: Column(mainAxisSize: MainAxisSize.min, children: [
Center(
child: CircleAvatar(
backgroundImage:
Image.network(controller.googleAccount.value?.photoUrl ?? '')
.image,
radius: 100,
),
),
Text(
controller.googleAccount.value?.displayName ?? '',
style: Get.textTheme.headline1,
),
Text(controller.googleAccount.value?.email ?? '',
style: Get.textTheme.bodyText1),
ElevatedButton(
onPressed: () {},
child: Text('Continue to Main Menu'),
),
]),
More about Column
widget.
CodePudding user response:
Yeah you can't assign both child and children property to a Column. Column takes children so move ElevatedButton to children block inside [](square brackets).