• Flutter学习之image


    import 'package:flutter/material.dart';
    
    void main(){
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget{
      @override
      Widget build(BuildContext context){
        return MaterialApp(
          title: 'image',
          home: Scaffold(
            body: Center(
              child: Container(
                child: new Image.network('https://avatar.csdn.net/7/F/F/3_weixin_43434223.jpg',
                // fit: BoxFit.fitHeight,/fitWidth,fitHeight,fill,scaleDown,contain,fill
                repeat: ImageRepeat.repeat
                // color: Colors.lightGreen,
                // colorBlendMode: BlendMode.multiply,
                ),
                color: Colors.lightBlue,
                width: 400.0,
                height: 400.0,
              ),
            ),
          ),
        );
      }
    }
    

    这里的image组件照例是放在Container组件当中,在Container中放一个child,new一个Image,Image有四个方法,assert(),memory(),file(),network(最常用),就是存储在网络上的图片。Image里有几个重要的属性

    • fit: BoxFit.fitHeight() Y轴填充 其他几个方法字面意思
    • repeat: ImageRepeat.repeat 就是复读
    • color: Colors.lightGreen,
      colorBlendMode: BlendMode.multiply 这两个是设置颜色,颜色混合

    效果图
    有点丑哈

    Image组件的基本用法就是这样啦

  • 相关阅读:
    flask 基础
    新的项目部署
    linux (01) linux基础
    linux (04) linux安装mysql
    linux (06) redis安装
    linux (09) nginx反向代理,负载均衡
    linux (08) nginx入门详解
    linux (07) redis详解
    linux(05) 编译安装py3
    spring-boot war包部署(二)
  • 原文地址:https://www.cnblogs.com/yfc0818/p/11072667.html
Copyright © 2020-2023  润新知