v8
This commit is contained in:
@@ -44,6 +44,7 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
|
||||
final List<String> keepAlivePath = [] ;
|
||||
|
||||
|
||||
void setPathKeepLive(String value){
|
||||
if(keepAlivePath.contains(value)){
|
||||
keepAlivePath.remove(value);
|
||||
@@ -52,6 +53,8 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
path = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setPathForData(String value,dynamic data){
|
||||
_pathExtraMap[value] = data;
|
||||
path = value;
|
||||
@@ -82,6 +85,17 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
List<Page> pages = [];
|
||||
List<Page> topPages = _buildPageByPath(path);
|
||||
|
||||
if(keepAlivePath.isNotEmpty){
|
||||
for (String alivePath in keepAlivePath) {
|
||||
if(alivePath!=path){
|
||||
pages.addAll(_buildPageByPath(alivePath)) ;
|
||||
}
|
||||
}
|
||||
/// 去除和 topPages 中重复的界面
|
||||
pages.removeWhere((element) => topPages.map((e) => e.key).contains(element.key));
|
||||
}
|
||||
|
||||
|
||||
if(keepAlivePath.isNotEmpty){
|
||||
for (String alivePath in keepAlivePath) {
|
||||
if(alivePath!=path){
|
||||
@@ -171,7 +185,6 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
_completerMap[path]?.complete(result);
|
||||
_completerMap.remove(path);
|
||||
}
|
||||
|
||||
path = backPath(path);
|
||||
return route.didPop(result);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ class AppNavigationRail extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
|
||||
final List<MenuMeta> deskNavBarMenus = const [
|
||||
MenuMeta(label: '颜色板', icon: Icons.color_lens_outlined),
|
||||
MenuMeta(label: '计数器', icon: Icons.add_chart),
|
||||
@@ -41,22 +40,24 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
),
|
||||
tail: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6.0),
|
||||
child: Text('V0.0.5',style: TextStyle(color: Colors.white,fontSize: 12),),
|
||||
child: Text(
|
||||
'V0.0.5',
|
||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||
),
|
||||
),
|
||||
backgroundColor: const Color(0xff3975c6),
|
||||
onDestinationSelected: _onDestinationSelected,
|
||||
selectedIndex: router.activeIndex,
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
void _onDestinationSelected(int index) {
|
||||
if(index==1){
|
||||
if (index == 1) {
|
||||
router.setPathKeepLive(kDestinationsPaths[index]);
|
||||
}else{
|
||||
router.path = kDestinationsPaths[index];
|
||||
return;
|
||||
}
|
||||
router.path = kDestinationsPaths[index];
|
||||
}
|
||||
|
||||
void _onRouterChange() {
|
||||
|
||||
Reference in New Issue
Block a user