animation property

(Widget Function(Widget child)?) animation
final

A function that return an Animation Widget to animate transition to and from SearchMode of AppBarWithSearchSwitch.

There are two prebuild animation widgets:

But you can build you own animation widget, if you want.

Usage of prebuilt animation widgets:

        appBar: AppBarWithSearchSwitch(
         animation: AppBarAnimationSlideLeft.call
         // or customize:
         // animation: (child) => AppBarAnimationSlideLeft(child: child, milliseconds: 600, withFade: false, percents: 1.0,),
          appBarBuilder: (context) {
            return AppBar(
              title: Text(title),
              actions: const [
                AppBarSearchButton(),
              ],
            );
          },
        ),
        ...

Usage of your own animation widget:

        appBar: AppBarWithSearchSwitch(
          animation: (child) {
            return AnimatedSwitcher(
              duration: Duration(milliseconds: 600),
              transitionBuilder: (Widget child, Animation<double> animation) {
                return FadeTransition(opacity: animation, child: child);
                },
              child: child,
            );
          }
          appBarBuilder: (context) {
          ...

Implementation

final Widget Function(Widget child)? animation;