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) )] ), ) ], ), ), )); ], ) ), ); } }
而我已经删除了 const
我修复了你的代码,看看吧
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: 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)
)]
),
)
],
),
),
)
)
],
)
),
);
}
}