Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add repaint boundary by default #7

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions flutter/mesh/lib/src/widgets/omesh_gradient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class OMeshGradient extends StatelessWidget {
this.tessellation,
this.size,
this.impellerCompatibilityMode,
this.addRepaintBoundary,
});

/// The mesh that will be rendered.
Expand Down Expand Up @@ -99,17 +100,33 @@ class OMeshGradient extends StatelessWidget {
/// artifacts if any of the vertices has transparent/semitransparent colors.
final bool? impellerCompatibilityMode;

/// Whether to add a [RepaintBoundary] around the mesh widget
/// to avoid repainting the whole widget tree when the mesh changes.
///
/// Read more about [RepaintBoundary](https://api.flutter.dev/flutter/widgets/RepaintBoundary-class.html)
///
/// Default is true
final bool? addRepaintBoundary;

@override
Widget build(BuildContext context) {
return _ShaderPreloader(
(context, shaderProvider) => _OMeshGradient(
shaderProvider: shaderProvider,
mesh: mesh,
debugMode: debugMode,
tessellation: tessellation ?? 12,
size: size,
impellerCompatibilityMode: impellerCompatibilityMode ?? false,
),
(context, shaderProvider) {
Widget child = _OMeshGradient(
shaderProvider: shaderProvider,
mesh: mesh,
debugMode: debugMode,
tessellation: tessellation ?? 12,
size: size,
impellerCompatibilityMode: impellerCompatibilityMode ?? false,
);

if (addRepaintBoundary ?? true) {
child = RepaintBoundary(child: child);
}

return child;
},
);
}
}
Expand Down Expand Up @@ -239,6 +256,7 @@ class AnimatedOMeshGradient extends StatelessWidget {
debugMode: debugMode,
tessellation: tessellation,
impellerCompatibilityMode: impellerCompatibilityMode,
addRepaintBoundary: false,
);
},
),
Expand Down