//flutter
import 'package:flutter/material.dart';
void main() {
return runApp(TestPage());
}
//リスト4.45
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: tabNames
.map((tabName) => Tab(text: tabName))
.toList()
),
title: Text('Tabs')
),
body: TabBarView(
children: tabNames
.map((tabName) => Center(child: Text(tabName)))
.toList()
)
)
)
);
}
}