BoxDecoration装饰盒子-背景图片
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MaterialApp( | |
title: "BoxDecoration装饰盒子-背景图片", | |
home: LayoutDemo(), | |
)); | |
} | |
class LayoutDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("BoxDecoration装饰盒子-背景图片"), | |
), | |
body: Center( | |
child: Container( | |
width: 300.0, | |
height: 300.0, | |
// 装饰器 | |
decoration: BoxDecoration( | |
// 背景色 | |
color: Colors.grey, | |
// 图片装饰器 | |
image: DecorationImage( | |
// 添加 Image 属性 | |
// image: ExactAssetImage('images/1.png'), | |
image: | |
NetworkImage("https://static.lidong.me/upload/c7QdErvcb.png"), | |
fit: BoxFit.cover, | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment