urlToPage<T> method
Future<T?> ?
urlToPage<T>(
- BuildContext context,
- String urlStr, {
- RoutePushType pushType = RoutePushType.pushNamed,
- RoutePredicate? predicate,
scheme://setting?arg=1&arg2=2, means: open '/setting' page with args:
- arg: 1
- arg2: 2
- _url: scheme://setting?arg=1&arg2=2
Implementation
Future<T?>? urlToPage<T>(BuildContext context, String urlStr,
{RoutePushType pushType = RoutePushType.pushNamed,
RoutePredicate? predicate}) {
Uri? url = Uri.tryParse(urlStr);
if (url == null) return Future.error('parse url fail');
Map<String, String> args = {};
args.addAll(url.queryParameters);
args['_url'] = urlStr;
String pageName = url.host;
super.openPage(
context,
'/' + pageName,
pushType: pushType,
arguments: args,
predicate: predicate,
);
}