import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Load local image"),
),
body: Container(
child: Center(
child: Text(
"Hello World!",
style: TextStyle(color: Colors.black),
),
),
// Set the image as the background of the Container
decoration: BoxDecoration(//Container的decoration用BoxDecoration来设置,使其改变其显示形式
image: DecorationImage(//设置图片背景,设置image需要一个DecorationImage类
// Load image from assets
image: AssetImage('images/base_widgets/icon_main_date_select@2x.png'),
// Make the image cover the whole area
fit: BoxFit.cover)),//fit占满屏幕
));
}
}
Flutter 使用ImageView
最新推荐文章于 2024-05-12 10:00:14 发布