bottom nav fixed

This commit is contained in:
jayesh
2024-06-13 11:22:54 +05:30
parent f27f40dcf5
commit b14aa9e83d
3 changed files with 9 additions and 3 deletions

View File

@@ -27,7 +27,9 @@ class MainScreen extends StatelessWidget {
const MainScreen({super.key});
@override
Widget build(BuildContext context) {
final PageController pageController = PageController();
context.read<BottomNavigationBloc>().add(TabChanged(1));
final PageController pageController = PageController(initialPage: 1);
return BlocBuilder<BottomNavigationBloc, BottomNavigationState>(
builder: (context, state) {
int selectedIndex = (state as TabState).selectedIndex;
@@ -40,7 +42,7 @@ class MainScreen extends StatelessWidget {
backgroundColor: Colors.white,
body: PageView(
controller: pageController,
physics: const NeverScrollableScrollPhysics(), // Disable swipe
physics: const NeverScrollableScrollPhysics(),
onPageChanged: (index) {
context.read<BottomNavigationBloc>().add(TabChanged(index));
},

View File

@@ -6,7 +6,7 @@ import 'bottom_navigation_state.dart';
// Bloc
class BottomNavigationBloc
extends Bloc<BottomNavigationEvent, BottomNavigationState> {
BottomNavigationBloc() : super(TabState(0)) {
BottomNavigationBloc() : super(TabState(1)) {
// Register the event handler
on<TabChanged>((event, emit) {
emit(TabState(event.index));

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gap/gap.dart';
@@ -7,6 +8,8 @@ import '../../core/routes/routes.dart';
import '../../core/styles/app_color.dart';
import '../../core/styles/app_text.dart';
import '../../core/utils/secure/secure_storage_service.dart';
import 'bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
import 'bloc/bottom_nav_bar/bottom_navigation_event.dart';
import 'text_widget.dart';
buildprofilelogoutdialog(context) {
@@ -82,6 +85,7 @@ buildprofilelogoutdialog(context) {
Gap(28.w),
InkWell(
onTap: () async {
context.read<BottomNavigationBloc>().add(TabChanged(1));
await secureStorageService.write('isLoginedIn', "false");
goRouter.goNamed(RouteName.loginScreen, pathParameters: {
"fromScreen": "registerStep",