//必须有封号 material就是个UI import ‘package:flutter/material.dart‘; //这是个主函数入口 void main()=>runApp(MyApp()); // 也可以这么写 // void main(){ // runApp(MyApp()) // } // 声明MyApp类 class MyApp extends StatelessWidget{ // 重写build @override Widget build(BuildContext context){ //返回一个Material风格的App return MaterialApp( title:‘Welcome to Flutteraa‘, home: Scaffold( // 在主题的中间区域,添加一个文本 Center:屏幕的中间 body: Center( // child:Container( // child:new Image.network( // ‘https://avatars2.githubusercontent.com/u/20411648?s=460&v=4‘, // // scale:1.0, // width: 100.0, // height: 100.0, // ), // width:300.0, // height:300.0, // color: Colors.lightBlue, // ), child: Container( child: Image( image: AssetImage("images/2222.png"), //缩放模式 fit: BoxFit.scaleDown, color: Colors.greenAccent, //背景色 colorBlendMode: BlendMode.darken, //重复 repeat: ImageRepeat.repeat, ), width: 400.0, height: 500.0, color: Colors.lightBlue, ), ), ), ); } }
原文:https://www.cnblogs.com/lxz-blogs/p/13224227.html