Flutter入门学习--(7)图片组件Image

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zx13525079024/article/details/86557397

  Image组件用来显示图片,有多种方式

  Image.asset 加载本地资源

 Image.file 加载本地图片文件,如相机中的图片

 Image.network 加载网络图片

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter',
        home: Scaffold(
          appBar: AppBar(
            title: Text("Hello World"),
          ),
          body: Center(
              child: Container(
              child: Image.network("http://p1.so.qhmsg.com/bdr/1843__/t0101bc5934a0f24496.jpg",
               scale:2,
               fit:BoxFit.scaleDown ,
              ),
              width: 500,
              height: 400,
              color: Colors.green,
          )),
        ));
  }
}

猜你喜欢

转载自blog.csdn.net/zx13525079024/article/details/86557397