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

例子代码有问题 #1639

Closed
280482431 opened this issue May 4, 2022 · 1 comment
Closed

例子代码有问题 #1639

280482431 opened this issue May 4, 2022 · 1 comment

Comments

@280482431
Copy link

lib/main.dart:98:16: Error: A value of type 'Route?' can't be returned from a function with return type 'Route' because 'Route?' is nullable and 'Route' isn't.

  • 'Route' is from 'package:flutter/src/widgets/navigator.dart' ('../../../Documents/flutter/flutter/packages/flutter/lib/src/widgets/navigator.dart').
    return func(settings, uniqueId);
    ^
    lib/main.dart:116:7: Error: The argument type 'Route Function(RouteSettings, String)' can't be assigned to the parameter type 'Route? Function(RouteSettings, String?)' because 'String?' is nullable and 'String' isn't.
  • 'Route' is from 'package:flutter/src/widgets/navigator.dart' ('../../../Documents/flutter/flutter/packages/flutter/lib/src/widgets/navigator.dart').
  • 'RouteSettings' is from 'package:flutter/src/widgets/navigator.dart' ('../../../Documents/flutter/flutter/packages/flutter/lib/src/widgets/navigator.dart').
    routeFactory,
    ^
@wangxuewen
Copy link

wangxuewen commented May 23, 2022

1.使用空安全版本
ref: 'v3.0-null-safety-release.1'

2.routeFactory函数调整为
Route? routeFactory(RouteSettings settings, String? uniqueId) {
FlutterBoostRouteFactory? func = routerMap[settings.name];
if (func == null) {
return null;
}
return func(settings, uniqueId);
}

@0xZOne 0xZOne closed this as completed May 25, 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

3 participants