alibaba / alibaba/flutter_boost

[Bug]: bool isFlutterPage(String name) 优化

Open
#2,122 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dart
Stars
7.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

### 请描述遇到的问题,以及您所期望的正确的结果

1. 当前处于一个flutter页面【Flutter page 1】,
2. 点击跳转下一个flutter页面【Flutter page 2】
```
BoostNavigator.instance.push("record/detail", arguments: {}, withContainer: true, opaque: true)
```
3. 这个时候会发现FlutterBoostApp的routeFactory被调用了两遍, 第一遍是isFlutterPage(name)中触发的调用--用于查找页面是不是flutter页面;第二遍是打开页面的时候调用的。针对第一遍的调用可以做些优化,即在FlutterBoostApp初始化的时候让开发者传入全部flutter页面的路由List,那么
```
FlutterBoostApp(List routeNames, ....) {
BoostNavigator.instance. routeNames = routeNames;
}

bool isFlutterPage(String name) {
List? routeNames = BoostNavigator.instance. routeNames;
if(routeNames != null && routeNames.isNotEmpty){
return routeNames.contains(name);
}
//兼容原有的模式
return routeFactory(RouteSettings(name: name), null) != null;
}
```
如此可以减少一次routeFactory的调用,从而减少不必要的Route的初始化。

### 请说明如何操作会遇到上述问题

每次都会遇到。

### 在下面填入关键复现代码

```
BoostNavigator.instance.push("record/detail", arguments: {}, withContainer: true, opaque: true)
```

### 复现的平台

Both

### Flutter SDK版本

3.22.3

### FlutterBoost版本

4.6.2

### 是否延迟初始化FlutterBoost

No

### 解决方案

如上。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating FlutterBoostApp, BoostNavigator.instance, and isFlutterPage; trace how the shown push("record/detail", ...) call reaches routeFactory. Verify that supplying a route-name list avoids the preliminary routeFactory lookup while preserving the existing fallback when no list is provided. Confirm the behavior on both platforms described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.