//flutter import 'package:flutter/material.dart'; void main() { return runApp(TestPage()); } //リスト4.46 class TestPage extends StatelessWidget { @override Widget build(BuildContext context) { final tabNames = <String>['First', 'Second', 'Third', 'Fourth']; return MaterialApp( title: 'Tab', home: DefaultTabController( length: tabNames.length, child: Scaffold( appBar: AppBar( bottom: TabBar( tabs: [ Tab(icon: Icon(Icons.wb_sunny)), Tab(icon: Icon(Icons.wb_cloudy)), Tab(icon: Icon(Icons.wb_twighlight)), Tab(icon: Icon(Icons.wb_cloudy_outlined)) ] ), title: Text('Tabs') ), body: TabBarView( children: tabNames .map((tabName) => Center(child: Text(tabName))) .toList() ) ) ) ); } }