Enhancement: back button to main menu reload

This commit is contained in:
2024-06-04 15:57:17 +03:00
parent eaa8b138a4
commit 1e5b235a6c
4 changed files with 48 additions and 20 deletions

View File

@@ -1,8 +1,11 @@
import 'package:flutter/material.dart';
import 'package:gymlink_module_web/pages/main.dart';
import 'package:gymlink_module_web/tools/routes.dart';
class GymLinkHeader extends StatelessWidget {
final String title;
const GymLinkHeader({super.key, required this.title});
final bool toMain;
const GymLinkHeader({super.key, required this.title, this.toMain = false});
@override
Widget build(BuildContext context) {
@@ -13,7 +16,13 @@ class GymLinkHeader extends StatelessWidget {
Row(
children: [
IconButton(
onPressed: () => Navigator.pop(context),
onPressed: () => toMain
? Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
builder: (context) => const MainPage()),
(route) => route.isFirst)
: Navigator.pop(context),
icon: const Icon(Icons.arrow_back)),
Text(title, style: Theme.of(context).textTheme.titleLarge),
],