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