[Flutter笔记]BlendMode

3,692 阅读1分钟

官方文档:api.flutter.dev/flutter/dar…

Dartpad示例:dartpad.dev/53049ac9419…

import 'package:flutter/material.dart';

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

var colorBlendMode = [
  BlendMode.clear,
  BlendMode.src,
  BlendMode.dst,
  BlendMode.srcOver,
  BlendMode.dstOver,
  BlendMode.srcIn,
  BlendMode.dstIn,
  BlendMode.srcOut,
  BlendMode.dstOut,
  BlendMode.srcATop,
  BlendMode.dstATop,
  BlendMode.xor,
  BlendMode.plus,
  BlendMode.modulate,
  BlendMode.screen,
  BlendMode.overlay,
  BlendMode.darken,
  BlendMode.lighten,
  BlendMode.colorDodge,
  BlendMode.colorBurn,
  BlendMode.hardLight,
  BlendMode.softLight,
  BlendMode.difference,
  BlendMode.exclusion,
  BlendMode.multiply,
  BlendMode.hue,
  BlendMode.saturation,
  BlendMode.color,
  BlendMode.luminosity,
];

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: GridView.count(
          crossAxisCount: 4,
          children: <Widget>[
            for (var mode in colorBlendMode)
              GridTile(
                child: Image.network(
                  'https://raw.githubusercontent.com/flutter/flutter/master/dev/docs/favicon.ico',
                  color: Colors.amber,
                  colorBlendMode: mode,
                ),
                footer: Text('${mode.toString()}'),
              ),
            
          ],
        ),
      ),
    );
  }
}



参考:

https://juejin.cn/post/6844903885908213768