扑。动画着色器蒙版更改

时间:2019-12-21 04:23:29

标签: animation flutter widget shader

我有简单的ShaderMask来创建叠加淡入(底部)效果。而且我还需要消除这种褪色。正如您在下面使用BlendMode所看到的,这很容易做到。

    ShaderMask(
              blendMode: accepted ? BlendMode.dst : BlendMode.dstIn,
              shaderCallback: (Rect bounds) {
                return LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: <Color>[
                    Colors.black,
                    Colors.black,
                    Colors.black26,
                    Colors.transparent,
                    Colors.transparent,
                  ],
                ).createShader(
                    Rect.fromLTRB(0, 0, bounds.width, bounds.height));
              },
              child: Container(
                height: size.width / 2.4,
                child: ListView.builder(
                  itemCount: products.length,
                  physics: BouncingScrollPhysics(),
                  scrollDirection: Axis.horizontal,
                  itemBuilder: (context, index) {
                    return getItem(index);
                  },
                ),
              ),
            ),

是否可以为BlendMode的变化设置动画?通过将其从一种模式转移到另一种模式?

0 个答案:

没有答案