Skip to content

lucasshiva/fade_indexed_stack

Repository files navigation

fade_indexed_stack

An IndexedStack with FadeTransition and lazy loading.

Inspirations

Usage

You can use FadeIndexedStack like you would use an IndexedStack.

class MainPage extends StatefulWidget {
  const MainPage({super.key});

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: FadeIndexedStack(
        index: _currentIndex,
        children: [
          FirstPage(),
          SecondPage(),
          ThirdPage(),
        ],
      ),
      bottomNavigationBar: NavigationBar(
        destinations: [
          NavigationDestination(),
          NavigationDestination(),
          NavigationDestination(),
        ],
        selectedIndex: _currentIndex,
        onDestinationSelected: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
    );
  }
}

For more details, check out the example file.

About

A Flutter package built on top of IndexedStack to allow lazy loading and FadeTransition.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published