From 4726c8ad8b4149e4d7d41d5fc77996fc6e65c73d Mon Sep 17 00:00:00 2001 From: Hiddify <114227601+hiddify-com@users.noreply.github.com> Date: Tue, 20 Aug 2024 01:52:44 -0400 Subject: [PATCH] fix: bug of back button in rtl flutter 3.24 --- lib/features/common/nested_app_bar.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/features/common/nested_app_bar.dart b/lib/features/common/nested_app_bar.dart index e9281f03..6848d181 100644 --- a/lib/features/common/nested_app_bar.dart +++ b/lib/features/common/nested_app_bar.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; +import 'package:hiddify/bootstrap.dart'; import 'package:hiddify/core/router/router.dart'; import 'package:hiddify/features/common/adaptive_root_scaffold.dart'; +import 'package:hiddify/utils/utils.dart'; bool showDrawerButton(BuildContext context) { if (!useMobileRouter) return true; final String location = GoRouterState.of(context).uri.path; - if (location == const HomeRoute().location || - location == const ProfilesOverviewRoute().location) return true; + if (location == const HomeRoute().location || location == const ProfilesOverviewRoute().location) return true; if (location.startsWith(const ProxiesRoute().location)) return true; return false; } @@ -33,14 +34,19 @@ class NestedAppBar extends StatelessWidget { RootScaffold.canShowDrawer(context); return SliverAppBar( - leading: (RootScaffold.stateKey.currentState?.hasDrawer ?? false) && - showDrawerButton(context) + leading: (RootScaffold.stateKey.currentState?.hasDrawer ?? false) && showDrawerButton(context) ? DrawerButton( onPressed: () { RootScaffold.stateKey.currentState?.openDrawer(); }, ) - : null, + : IconButton( + icon: Icon(context.isRtl ? Icons.arrow_forward : Icons.arrow_back), + padding: EdgeInsets.only(right: context.isRtl ? 50 : 0), + onPressed: () { + Navigator.of(context).pop(); // Pops the current route off the navigator stack + }, + ), title: title, actions: actions, pinned: pinned,