content: import 'package:flutter/material.dart';
  
  void main() => runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    @override
    MyHomePageState createState() => MyHomePageState();
  }
  
  class MyHomePageState extends State<MyHomePage> {
    int _selectedIndex = 0;
  
    static const List<Widget> _widgets = <Widget>[
      Text('Index 0: Home'),
      Text('Index 1: Business'),
      Text('Index 2: School'),
    ];
  
    void _onItemTapped(int index) {
      setState(() {
        _selectedIndex = index;
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: const Text('BottomNavigationBar Sample'),
        ),
        body: Center(
          // (3) 保持したindexのウィジェットをbodyで表示
          child: _widgets.elementAt(_selectedIndex),
        ),
        // (1) ここで下部のデザインを設定
        bottomNavigationBar: BottomNavigationBar(
          items: const <BottomNavigationBarItem>[
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              title: Text('Home'),
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.business),
              title: Text('Business'),
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.school),
              title: Text('School'),
            ),
          ],
          currentIndex: _selectedIndex,
          selectedItemColor: Colors.blue,
          // (2) 選択したタブのindexを保持
          onTap: _onItemTapped,
        ),
      );
    }
  }
  