Can't modify SnackBar animation duration

This issue has been tracked since 2022-11-23.

While working on #115750, I was attempting to conditionally change the duration of the SnackBar animation, depending on whether the theme was Material 3 or not.

The Scaffold creates the animation controller for its snackbars in the ScaffoldMessengerState method showSnackBar():

 _snackBarController ??= SnackBar.createAnimationController(vsync: this)

(scaffold.dart)

createAnimationController is a static method of SnackBar:

  static AnimationController createAnimationController({ required TickerProvider vsync }) {
    return AnimationController(
      duration: _snackBarTransitionDuration,
      debugLabel: 'SnackBar',
      vsync: vsync,
    );
  }

(snack_bar.dart)

Ideally we could pass an optional useMaterial3 parameter to this method, and change the duration accordingly.

However, when running a Material 3 example (like snackbar.2.dart in the above mentioned PR) I can't seem to access a value of Theme.of(context).useMaterial3 = true from ScaffoldMessengerState, though I can from ScaffoldState.

Perhaps there's a trivial solution to this, but I need some insight from someone with more Scaffold familiarity.

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-12-07
Star Count 147031
Watcher Count 3560
Fork Count 23915
Issue Count 11300

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date