copyWith method
- @useResult
- ImageFilter barrierFilter(
- BuildContext context,
- double animation
- FModalSheetMotionDelta? motion,
- double? flingVelocity,
- double? closeProgressThreshold,
Returns a copy of this FModalSheetStyle with the given properties replaced.
See customizing widget styles.
Parameters
- FModalSheetStyle.barrierFilter - An optional callback that takes a BuildContext and the current animation transition value (0.0 to 1.0), and returns an ImageFilter that is used as the barrier. Defaults to null.
Prefer a static function over a closure literal. A closure literal is never equal to another, which causes widgets to flicker when the same theme is recreated.
Examples
// Blurred
(context, animation) => ImageFilter.blur(sigmaX: animation * 5, sigmaY: animation * 5);
// Solid color
(context, animation) => ColorFilter.mode(Colors.white.withValues(alpha: animation), BlendMode.srcOver);
// Tinted
(context, animation) => ColorFilter.mode(
context.theme.colors.barrier.withValues(alpha: animation * 0.5),
BlendMode.srcOver,
);
// Blurred & tinted
(context, animation) => ImageFilter.compose(
outer: ImageFilter.blur(sigmaX: animation * 5, sigmaY: animation * 5),
inner: ColorFilter.mode(Colors.white.withValues(alpha: animation * 0.5), BlendMode.srcOver),
);
- FModalSheetStyle.motion - The motion-related properties for a modal sheet.
- FModalSheetStyle.flingVelocity - The minimum velocity to initiate a fling.
- FModalSheetStyle.closeProgressThreshold - The threshold for determining whether the sheet is closing.
Implementation
@useResult
FModalSheetStyle copyWith({
ImageFilter Function(BuildContext, double)? barrierFilter = Sentinels.imageFilterFunction,
FModalSheetMotionDelta? motion,
double? flingVelocity,
double? closeProgressThreshold,
}) => .new(
barrierFilter: barrierFilter == Sentinels.imageFilterFunction ? this.barrierFilter : barrierFilter,
motion: motion?.call(this.motion) ?? this.motion,
flingVelocity: flingVelocity ?? this.flingVelocity,
closeProgressThreshold: closeProgressThreshold ?? this.closeProgressThreshold,
);