This is the error message which I am getting:
请看下面是我的代码:
void main(){
runApp(HomePage());
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/dotbg.jpg"),
fit: BoxFit.cover,
),
),
child: Row(
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
'Welcome!',
style: TextStyle(
fontSize: 30.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
Container(height: 10.0),
RaisedButton(
padding: EdgeInsets.symmetric(
horizontal: 50.0, vertical: 15.0),
textColor: Colors.black,
child: Text(
'Play Online',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
onPressed: () {
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0))),
Container(
height: 30.0,
),
RaisedButton(
padding: EdgeInsets.symmetric(
horizontal: 50.0, vertical: 15.0),
textColor: Colors.black,
child: Text(
'Play Offline',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder:(context)=> OfflinePage()),);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0))),
Container(height: 70.0),
Text(
'Copyright@2019 DotsNBoxes',
style: TextStyle(fontSize: 20.0),
),
],
),
)
],
)),
);
}
}
答案 0 :(得分:0)
通过添加MaterialApp解决此问题:
void main()
runApp(
MaterialApp(home: HomePage()),
);
}