Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

空安全异常 type 'Null' is not a subtype of type 'Object' #1582

Closed
zgfliusha opened this issue Feb 14, 2022 · 2 comments
Closed

空安全异常 type 'Null' is not a subtype of type 'Object' #1582

zgfliusha opened this issue Feb 14, 2022 · 2 comments

Comments

@zgfliusha
Copy link

zgfliusha commented Feb 14, 2022

type 'Null' is not a subtype of type 'Object'

When the exception was thrown, this was the stack:
#1 FlutterBoostAppState.onNativeResult (package:flutter_boost/src/flutter_boost_app.dart:529:28)
#2 BoostFlutterRouterApi.onNativeResult (package:flutter_boost/src/boost_flutter_router_api.dart:63:53)
#3 FlutterRouterApi.setup. (package:flutter_boost/src/messages.dart:148:15)
#4 FlutterRouterApi.setup. (package:flutter_boost/src/messages.dart:145:35)
#5 BasicMessageChannel.setMessageHandler. (package:flutter/src/services/platform_channel.dart:73:49)
#6 BasicMessageChannel.setMessageHandler. (package:flutter/src/services/platform_channel.dart:72:47)
#7 _DefaultBinaryMessenger.setMessageHandler. (package:flutter/src/services/binding.dart:395:35)
#8 _DefaultBinaryMessenger.setMessageHandler. (package:flutter/src/services/binding.dart:392:46)
#9 _invoke2. (dart:ui/hooks.dart:213:15)

复线路径:
flutterA页跳转nativeB页,返回flutterA页

url: 'https://github.com/alibaba/flutter_boost.git'
ref: 'v3.0-null-safety-preview.18'

建议修复: 添加默认值或判空

image

@sunsxuan
Copy link
Collaborator

我在官方null_safety分支下运行Android Demo, open flutter page -> open native page -> NativePageActivity 点返回的时候不携带参数,

void onNativeResult(CommonParams params) {
final initiatorPage = topContainer?.topPage.pageInfo.uniqueId;
final key = '$initiatorPage#${params.pageName}';
if (_pendingResult.containsKey(key)) {
_pendingResult[key]!.complete(params.arguments);
_pendingResult.remove(key);
}
Logger.log('onNativeResult, key:$key, result:${params.arguments}');
}

params 参数为:
pageName = "native"
uniqueId = null
arguments = null
opaque = null
key = null

没有出现异常,你可以贴上nativeB 返回的代码吗?

@zgfliusha
Copy link
Author

zgfliusha commented Feb 15, 2022

image
arguments 为null
我理解是 _pendingResult[key]!.complete(null); 就会出问题,我本地加默认值{}就行了

@sunsxuan sunsxuan closed this as completed Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants