Created
February 16, 2020 14:51
-
-
Save ryanlid/556d44a88ab6fd9bc8f4d10d5f8fc5c4 to your computer and use it in GitHub Desktop.
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