Closed gabriel-gheorghe closed 3 months ago
Could not reproduce the Problem, This work works as expected
import 'package:flutter/material.dart';
import 'package:qlevar_router/qlevar_router.dart';
void main() async {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
final List<QRoute> router = [
QRoute(
path: '/',
builder: () {
return const HomePage();
},
),
QRoute(
path: '/schedule',
name: 'schedule',
builder: () => const PageOne(),
),
QRoute(
path: '/scheduleDetailed',
name: 'scheduleDetailed',
builder: () => const PageTow(),
),
];
return MaterialApp.router(
routeInformationParser: const QRouteInformationParser(),
routerDelegate: QRouterDelegate(router, withWebBar: true),
);
}
}
const navigatorName = 'bottom sheet';
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.green,
body: Center(
child: Column(
children: [
ElevatedButton(
child: const Text("Go"),
onPressed: () async {
QR.to('/schedule');
},
),
],
),
),
);
}
}
class PageOne extends StatefulWidget {
const PageOne({super.key});
@override
State<PageOne> createState() => _PageOneState();
}
class _PageOneState extends State<PageOne> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Page One"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
child: const Text("Go to page 2"),
onPressed: () {
QR.to('/scheduleDetailed');
},
),
TextButton(
child: const Text("Back"),
onPressed: () {
QR.back();
},
),
],
),
),
);
}
}
class PageTow extends StatelessWidget {
const PageTow({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Page One"),
),
body: const Center(
child: Icon(Icons.home),
),
);
}
}
Consider the following scenario:
First time you switch your view to "schedule", it shows the "ScheduleView", correct. Second time you switch to "schedule", it shows the "ScheduleDetailedView", wrong.
My temporary fix: I replaced '/scheduleDetailed' path with '/detailed' and now '/schedule' path works fine everytime I switch to it.