My Blog

My WordPress Blog

My Blog

My WordPress Blog

Using a TabBar for Navigation

This example shows how to use a TabBar for navigating between different sections of an app.

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
return MaterialApp(
  title: 'TabBar Example',
  theme: ThemeData(primarySwatch: Colors.blue),
  home: TabBarExample(),
);
} } class TabBarExample extends StatelessWidget { @override Widget build(BuildContext context) {
return DefaultTabController(
  length: 3,
  child: Scaffold(
    appBar: AppBar(
      title: Text('TabBar Example'),
      bottom: TabBar(
        tabs: [
          Tab(text: 'Home'),
          Tab(text: 'Search'),
          Tab(text: 'Profile'),
        ],
      ),
    ),
    body: TabBarView(
      children: [
        Center(child: Text('Home Screen')),
        Center(child: Text('Search Screen')),
        Center(child: Text('Profile Screen')),
      ],
    ),
  ),
);
} }
Using a TabBar for Navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top