[Bug]: iOS原生跳转flutter页面,每次都是一个新的Flutter页,且来回进入和退出,第一个页面一直存在
请描述遇到的问题,以及您所期望的正确的结果
期望返回的时候能销毁
请说明如何操作会遇到上述问题
有四个页面 原生A、FlutterB、原生C、FlutterD /course-category-page就是FlutterB页面
ABCD DCBA ABCD DCBA ABCD DCBA ABCD DCBA 来来回回进入和退出
控制台会打印
2024-07-26 15:29:37.244258+0800 中华珍宝馆[9823:584279] flutter: FlutterBoost_dart#remove, uniqueId=94B54E17-A0D4-4746-8C5A-0F72E5481934,
[
BoostContainer(name:/, pages:[BoostPage
每一个uniqueId都不一样,是不是对应的就是B页面初始化了很多
这是问题1
问题2是,当C页面是个嵌套Flutter的原生页面的时候,按照上面来回操作,B页面会白屏
在下面填入关键复现代码
原生进入Flutter代码如下
- (void)goFlutterWithPageName:(NSString *)pageName arguments:(NSDictionary *)arguments {
FlutterBoostRouteOptions *options = [[FlutterBoostRouteOptions alloc] init]; options.pageName = pageName; // options.uniqueId = nil; options.arguments = arguments; options.onPageFinished = ^(NSDictionary * dic) { NSLog(@"onPageFinished 反向传值");//反向传值 NSLog(@"%@",dic);//反向传值 }; options.completion = ^(BOOL success) { return;//跳转完成的回调 }; [[FlutterBoost instance] open:options]; }
Flutter页面pop
- (void)popRoute:(FlutterBoostRouteOptions *)options { ARTFlutterViewController *vc = (id)self.navigationController.presentedViewController; BOOL animated = YES; NSNumber * animatedValue = options.arguments[@"animated"]; if(animatedValue){ animated = [animatedValue boolValue]; } if([vc isKindOfClass:ARTFlutterViewController.class] && [vc.uniqueIDString isEqual: options.uniqueId]){ if(vc.modalPresentationStyle == UIModalPresentationOverFullScreen){ [self.navigationController.topViewController beginAppearanceTransition:YES animated:NO]; [vc dismissViewControllerAnimated:YES completion:^{ [self.navigationController.topViewController endAppearanceTransition]; }]; }else{ [vc dismissViewControllerAnimated:YES completion:^{}]; } }else{ [self.navigationController popViewControllerAnimated:animated]; } if (self.onPageFinished) { self.onPageFinished(options.arguments); } options.completion(YES); }
原生页面嵌套Flutter页面代码如下
-
(void)dealloc { [self stopTimer]; [self.flutterViewController notifyWillDealloc]; [self.flutterViewController detachFlutterEngineIfNeeded]; }
-
(void)initView { self.rt_disableInteractivePop = NO; [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; [self.view addSubview:self.mainView]; [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(0); }];
[self initViewAction]; [self initFlutterView]; }
-
(void)initFlutterView { self.flutterViewController = [[ARTFlutterViewController alloc] init]; NSString *routePath = [NSString stringWithFormat:@"/%@",self.page]; [self.flutterViewController setName:routePath uniqueId:nil params:@{@"id":self.id_p} opaque:YES]; [self addChildViewController:self.flutterViewController];
[self.mainView.businessContainer addSubview:self.flutterViewController.view]; CGRect containerFrame = self.mainView.businessContainer.frame; self.flutterViewController.view.frame = CGRectMake(0, 0, containerFrame.size.width, containerFrame.size.height);
}
复现的平台
iOS
Flutter SDK版本
3.19.6
FlutterBoost版本
5.0.2
是否延迟初始化FlutterBoost
No