FLUTTER ECOSYSTEM

letsar/visual_effect

Flutter 的 VisualEffect API

视觉效果 项目封面
Stars
75
Forks
2
最近推送(UTC)
2023年8月15日
项目状态
未归档
Romain Rastel GitHub avatar
GITHUB User

Romain Rastel ↗

Flutter Developer

Rennes, France官方网站 ↗
语言DartGLSLHTMLSwiftKotlinObjective-C

此仓库发布的插件

使用的依赖

依赖清单 4 项
  • flutter{"sdk":"flutter"}
  • meta^1.9.1
  • vector_math^2.1.4
  • flutter_test开发依赖{"sdk":"flutter"}

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

visual_effect

VisualEffect API for Flutter to easily add paint effects on your widgets.

Warning This package is experimental for the moment. The API can change at any time.

Scroll Effect

The main purpose of this API is to provide an easy and efficiently way to apply scroll animations.

Warning The addRepaintBoundaries MUST be set to false in the parent Sliver/ScrollView because we explicitely want in that case to repaint for every single scroll so we can add the effect.

For example this Card Stack effect can be obtained with the code below:

Card Stack

class _ScrolledItem extends StatelessWidget {
  const _ScrolledItem();

  @override
  Widget build(BuildContext context) {
    return ScrollEffect(
      onGenerateVisualEffect: (effect, phase) {
        return effect
            .grayscale(phase.leadingLerp(to: 0.5))
            .scale(
              x: phase.isLeading ? phase.leadingLerp(from: 1, to: 0.9) : 1,
              anchor: Alignment.topCenter,
            )
            .translate(y: effect.childSize.height * phase.leading);
      },
      child: const _CardItem(),
    );
  }
}