Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: new AppBar(
title: new Text('ListView Widget'),
),
body: new ListView(
children: <Widget>[new Image.asset('images/2.0x/ting.jpg')]),
),
);
}
1.需要注意的是图片的资源需要放到images/2.0x或者iamges/3.0x文件下;
2.在文件pubspec.yaml中加载图片资源,需要注意的是文件格式,以及对齐等eslint,否则会报错
pubspec.yaml
网友评论