I an new to flutter and learning about rows and column classes. I am trying to add a container to the column, but it’s throwing errors.
void main(){
runApp(
const Myapp()
);
}
class Myapp extends StatelessWidget {
const Myapp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
backgroundColor: Colors.teal,
body: SafeArea(
child: Column(
children: <Widget>[
Text('Text 1'),
Container(
height: 100,
width: 100,
color: Colors.blue,
child: Text('Text 2'),
)
],
)
),
),
);
}
}
I am getting errors when I add container as a child in column.
Here are the errors :
I am following a tutorial and doing the same still getting error.
Thank you for your time.
2
Answers
You cant use const in there. Column cant be constant. So you have to remove const. Just:
Simply you should remove
const
keyword, and will work fine.