13-04
This commit is contained in:
@@ -7,7 +7,7 @@ import '../page_b.dart';
|
||||
import '../page_c.dart';
|
||||
import '../home_page.dart';
|
||||
|
||||
class AppRouterDelegate extends RouterDelegate with ChangeNotifier{
|
||||
class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier{
|
||||
|
||||
List<String> _value = ['/'];
|
||||
|
||||
@@ -35,13 +35,11 @@ class AppRouterDelegate extends RouterDelegate with ChangeNotifier{
|
||||
|
||||
@override
|
||||
Future<bool> popRoute() async{
|
||||
print('================');
|
||||
print('=======popRoute=========');
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _onPopPage(Route route, result) {
|
||||
_value = List.of(_value)..removeLast();
|
||||
notifyListeners();
|
||||
return route.didPop(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class PageA extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: const Text('A 界面'),
|
||||
backgroundColor: bgColor,
|
||||
leading: BackButton(onPressed: _pop),
|
||||
),
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
@@ -26,4 +27,7 @@ class PageA extends StatelessWidget {
|
||||
router.value = ['/', 'a', 'b'];
|
||||
}
|
||||
|
||||
void _pop() {
|
||||
router.value = List.of(router.value)..removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class PageB extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: const Text('B 界面'),
|
||||
backgroundColor: bgColor,
|
||||
|
||||
leading: BackButton(onPressed: _pop),
|
||||
),
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
@@ -29,4 +29,7 @@ class PageB extends StatelessWidget {
|
||||
router.value = ['/','a','b','c'];
|
||||
}
|
||||
|
||||
void _pop() {
|
||||
router.value = List.of(router.value)..removeLast();
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,14 @@ class PageC extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: const Text('C 界面'),
|
||||
backgroundColor: bgColor,
|
||||
leading: BackButton(onPressed: _pop),
|
||||
),
|
||||
body: Center(
|
||||
child: Text('到达终点'),
|
||||
));
|
||||
}
|
||||
|
||||
void _pop() {
|
||||
router.value = List.of(router.value)..removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user