Flutter TabBar Widget

List<String> _tabs = ['One', 'Two', 'Three'];

Widget build(BuildContext context) {
  return DefaultTabController(
    length: _tabs.length, // This is the number of tabs.
    child: Scaffold(
      appBar: AppBar(
        title: const Text('TabBar Sample'),
        bottom: TabBar(
          // These are the widgets to put in each tab in the tab bar.
          tabs: _tabs.map((String name) => Tab(text: name)).toList(),
      body: TabBarView(
        // These are the contents of the tab views, below the tabs.
        children: _tabs.map((String name) {
          return SafeArea(
            top: false,
            bottom: false,
            child: Builder(
              // This Builder is needed to provide a BuildContext that is "inside"
              // the NestedScrollView, so that sliverOverlapAbsorberHandleFor() can
              // find the NestedScrollView.
              builder: (BuildContext context) {
                return Center(
                  child: Text('Page $name'),

Subscribe For Daily Updates

Flutter Questions
Android Questions