我已经厌倦了这个,但它不像预期的那样工作,也厌倦了其他模式,但不符合我需要的效果。
Stack(
children: [
Container(
color: Colors.white,
height: 50,
width: 50,
),
SvgPicture.asset(
'assets/logo.svg',
ColorFilter.mode(Colors.white, BlendMode.difference),
)
],
)
添加此包:widget_mask。这个包包含一个“SaveLayer”类,我们可以像这样使用 ->
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:widget_mask/widget_mask.dart';
class BlendTest extends StatelessWidget {
const BlendTest({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: SafeArea(
child: Center(
child: SizedBox(
height: 150,
width: 150,
child: Stack(
children: [
Positioned(
top: 0,
left: 0,
child: Container(
height: 100,
width: 100,
color: Colors.white,
),
),
Positioned(
right: 0,
bottom: 0,
child: SaveLayer(
paint: Paint()..blendMode = BlendMode.difference,
child: SvgPicture.asset("assets/github.svg")),
),
],
),
),
)),
);
}
}