import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(useMaterial3: true),
home: const MainScreen(),
routes: {
'/profile': (context) =>
const Scaffold(body: Center(child: Text("Profile Screen"))),
'/settings': (context) =>
const Scaffold(body: Center(child: Text("Settings Screen"))),
'/Help': (context) =>
const Scaffold(body: Center(child: Text("Help Screen"))),
},
);
}
}
class MainScreen extends StatefulWidget {
const MainScreen({super.key});
@override
State<MainScreen> createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("navigation demos"),
centerTitle: true,
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
),
drawer: Drawer(
child: Column(
children: [
UserAccountsDrawerHeader(
accountName: Text("Name"),
accountEmail: Text("[email protected]"),
),
ListTile(
leading: Icon(Icons.person),
title: Text("profile"),
onTap: () {
Navigator.pushNamed(context, '/profile');
},
),
ListTile(
leading: Icon(Icons.settings),
title: Text("settings"),
onTap: () {
Navigator.pushNamed(context, '/settings');
},
),
ListTile(
leading: Icon(Icons.help),
title: Text("help"),
onTap: () {
Navigator.pushNamed(context, '/Help');
},
),
],
),
),
body: HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: Column(
children: [
TabBar(
tabs: [
Tab(icon: Icon(Icons.chat), text: "chat"),
Tab(icon: Icon(Icons.group), text: "group"),
Tab(icon: Icon(Icons.notifications), text: "notification"),
],
),
Expanded(
child: TabBarView(
children: [
Center(child: Text("Chat view Screen")),
Center(child: Text("friend view Screen")),
Center(child: Text("notification view Screen")),
],
),
),
],
),
);
}
}5 views