Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 16, 2020 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/556d44a88ab6fd9bc8f4d10d5f8fc5c4 to your computer and use it in GitHub Desktop.
Save ryanlid/556d44a88ab6fd9bc8f4d10d5f8fc5c4 to your computer and use it in GitHub Desktop.
BoxDecoration装饰盒子-背景图片
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