Skip to content

A drop-in replacement for Flutter's default IndexedStack that allows simple animations to transition between widgets

License

Notifications You must be signed in to change notification settings

shubhamsinghshubham777/easy_animated_indexed_stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy Animated Indexed Stack

A drop-in replacement for Flutter's default IndexedStack that allows simple animations to transition between widgets/screens/pages.

Demo

Getting Started

Add the dependency in your pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
  # Add this  
  easy_animated_indexed_stack:

Usage

As mentioned above, this package provides a drop-in replacement for Flutter's default IndexedStack widget, meaning you can simply replace your IndexedStack usages with EasyAnimatedIndexedStack instances. For example:

@override
Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      // Simply replaced `IndexedStack` with `EasyAnimatedIndexedStack`
      body: EasyAnimatedIndexedStack(
        // `selectedIndex` is a state variable (int)
        index: selectedIndex,
        // Customise the animation to your liking
        animationBuilder: (context, animation, child) {
          return RotationTransition(
            turns: Tween<double>(begin: 1, end: 0).animate(animation),
            child: child,
          );
        },
        curve: Curves.easeInOut,
        duration: const Duration(milliseconds: 700),
        children: [
          ScreenA(onTap: () => setState(() => selectedIndex = 1)),
          ScreenB(onTap: () => setState(() => selectedIndex = 2)),
          ScreenC(onTap: () => setState(() => selectedIndex = 0)),
        ],
      ),
    ),
  );
}

Resources

A medium article talking about the inspiration behind this library can be found here

License

This package uses the New BSD License

About

A drop-in replacement for Flutter's default IndexedStack that allows simple animations to transition between widgets

Topics

Resources

License

Stars

Watchers

Forks

Languages