setStateWithViewportAnimation method

  1. @experimental
void setStateWithViewportAnimation(
  1. VoidCallback fn, {
  2. ViewportTransition? transition = const DefaultViewportTransition(),
  3. void completion(
    1. bool
    )?,
})

Applies the animation to the map viewport.

Use this function to apply animation to viewport state change.

final _viewport = ...

@override
Widget build(BuildContext context) {
  TextButton(onPressed: () {
    setStateWithViewportAnimation(() {
    _viewport = CameraViewportState(...);
}

See ViewportState and ViewportTransition documentation for more details.

Implementation

//    });
/// }
/// ```
///
/// See [ViewportState] and [ViewportTransition] documentation for more details.
@experimental
void setStateWithViewportAnimation(VoidCallback fn,
    {ViewportTransition? transition = const DefaultViewportTransition(),
    void Function(bool)? completion}) {
  _viewportTransition = transition;
  _viewportTransitionCompletion?.call(false);
  _viewportTransitionCompletion = completion;
  // ignore: invalid_use_of_protected_member
  setState(fn);
}