lucasshiva / fade_indexed_stack

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:MIT License


Languages

Language:Dart 65.9%Language:CMake 10.7%Language:Shell 7.3%Language:C 4.4%Language:Objective-C 4.3%Language:Java 4.0%Language:C++ 2.3%Language:Swift 1.1%