The container always displays an error like that
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: EdgeInsets.symmetric(vertical: 30),
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
colors: [
Color.fromARGB(255, 9, 106, 185),
Color.fromARGB(255, 56, 145, 217),
Color.fromARGB(255, 66, 161, 239),
Color.fromARGB(255, 109, 179, 237)
]
)
),
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: 80,),
Padding(
padding: EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("Login", style: TextStyle(color: Colors.white, fontSize: 40),),
SizedBox(height: 5,),
Text("Welcome Back", style: TextStyle(color: Colors.white, fontSize: 18),)
],
),
),
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topLeft: Radius.circular(50), topRight: Radius.circular(50))
),
child: Padding(
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
boxShadow: [BoxShadow(
color: Color.fromARGB(255, 5, 97, 173),
blurRadius: 20,
offset: Offset(0,10)
)]
),
)
],
),
),
));
],
)
),
);
}
}
2
Answers
I fixed your code, take a look
for more Flutter Constant constructors information, please check link.
Working code:
What I did is: Removed const in front of Column widget and added const on children’s of Column as per the lint.
Explanation: We can’t make constant Container widget due to that you are getting. If you see the Container widget, we do not have a constant constructor, due to which we are unable to use const keyword in Container widget.
I hope this is helpful. Thank you.