v10
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'views/navigator_scope.dart';
|
||||
import 'iroute.dart';
|
||||
@@ -7,13 +8,10 @@ import 'route_history_manager.dart';
|
||||
import 'routes.dart';
|
||||
import 'views/not_find_view.dart';
|
||||
|
||||
AppRouterDelegate router = AppRouterDelegate(
|
||||
initial: IRouteConfig(
|
||||
uri: Uri.parse('/app/color'),
|
||||
),
|
||||
node: appRoute);
|
||||
AppRouterDelegate router = AppRouterDelegate(node: rootRoute);
|
||||
|
||||
class AppRouterDelegate extends RouterDelegate<IRouteConfig> with ChangeNotifier {
|
||||
class AppRouterDelegate extends RouterDelegate<IRouteConfig>
|
||||
with ChangeNotifier {
|
||||
/// 核心数据,路由配置数据列表
|
||||
final List<IRouteConfig> _configs = [];
|
||||
|
||||
@@ -25,18 +23,16 @@ class AppRouterDelegate extends RouterDelegate<IRouteConfig> with ChangeNotifier
|
||||
|
||||
final IRouteNode node;
|
||||
|
||||
|
||||
@override
|
||||
IRouteConfig get currentConfiguration => current;
|
||||
IRouteConfig? get currentConfiguration {
|
||||
if(_configs.isEmpty) return null;
|
||||
return current;
|
||||
}
|
||||
|
||||
AppRouterDelegate({
|
||||
this.notFindPageBuilder,
|
||||
required this.node,
|
||||
required IRouteConfig initial,
|
||||
}) {
|
||||
_configs.add(initial);
|
||||
_historyManager.recode(initial);
|
||||
}
|
||||
});
|
||||
|
||||
Page _defaultNotFindPageBuilder(_, __) => const MaterialPage(
|
||||
child: Material(child: NotFindPage()),
|
||||
@@ -84,6 +80,7 @@ class AppRouterDelegate extends RouterDelegate<IRouteConfig> with ChangeNotifier
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
if (config.forResult) {
|
||||
return _completerMap[value]!.future;
|
||||
}
|
||||
@@ -174,5 +171,14 @@ class AppRouterDelegate extends RouterDelegate<IRouteConfig> with ChangeNotifier
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setNewRoutePath(configuration) async {}
|
||||
Future<void> setNewRoutePath(IRouteConfig configuration) async{
|
||||
changeRoute(configuration);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setInitialRoutePath(IRouteConfig configuration) {
|
||||
_configs.add(configuration);
|
||||
_historyManager.recode(configuration);
|
||||
return super.setInitialRoutePath(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user