mirrored_repositories/animated_crossfade_example
import 'package:animated_crossfade_example/page/advanced_page.dart';
import 'package:animated_crossfade_example/page/basic_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Future main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown,
  ]);

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  static final String title = 'Animated CrossFade';

  @override
  Widget build(BuildContext context) => MaterialApp(
        debugShowCheckedModeBanner: false,
        title: title,
        theme: ThemeData(
          primaryColor: Colors.red,
          scaffoldBackgroundColor: Colors.red.shade100,
          elevatedButtonTheme: ElevatedButtonThemeData(
            style: ElevatedButton.styleFrom(primary: Colors.red),
          ),
        ),
        home: MainPage(),
      );
}

class MainPage extends StatefulWidget {
  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  int index = 1;

  @override
  Widget build(BuildContext context) => Scaffold(
        body: IndexedStack(
          index: index,
          children: [
            BasicPage(),
            AdvancedPage(),
          ],
        ),
        bottomNavigationBar: BottomNavigationBar(
          currentIndex: index,
          onTap: (index) => setState(() => this.index = index),
          items: [
            BottomNavigationBarItem(
              icon: Icon(Icons.airplay_outlined),
              label: 'Basic',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.local_play_outlined),
              label: 'Advanced',
            ),
          ],
        ),
      );
}
