Skip to content

Commit dedccdd

Browse files
committed
3.1.1 Add FFGoRouterRouteSettings and GoRouterPageBuilder to support go_router.
1 parent 31b9d1f commit dedccdd

4 files changed

Lines changed: 69 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.2.1
2+
3+
* Add `FFGoRouterRouteSettings` and `GoRouterPageBuilder` to support `go_router`.
4+
15
## 3.2.0
26

37
* Introduce `FFErrorWidgetBuilder` to build an error page correspondingly.

lib/src/helper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ T? asT<T extends Object?>(dynamic value, [T? defaultValue]) {
2828
if ('' is T) {
2929
return valueS as T;
3030
} else if (0 is T) {
31-
return int.parse(valueS) as T;
31+
return (int.tryParse(valueS) ?? double.tryParse(valueS)?.toInt()) as T;
3232
} else if (0.0 is T) {
3333
return double.parse(valueS) as T;
3434
} else if (false is T) {

lib/src/page.dart

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,64 @@ typedef FFErrorWidgetBuilder = Widget Function(
367367
Object error,
368368
StackTrace stackTrace,
369369
);
370+
371+
/// GoRouter
372+
///
373+
class FFGoRouterRouteSettings extends RouteSettings {
374+
const FFGoRouterRouteSettings({
375+
required String name,
376+
required this.builder,
377+
Object? arguments,
378+
this.showStatusBar,
379+
this.routeName,
380+
this.pageRouteType,
381+
this.description,
382+
this.exts,
383+
this.codes,
384+
}) : super(
385+
name: name,
386+
arguments: arguments,
387+
);
388+
389+
factory FFGoRouterRouteSettings.notFound(Widget notFoundWidget) {
390+
return FFGoRouterRouteSettings(
391+
name: FFRoute.notFoundName,
392+
routeName: FFRoute.notFoundRouteName,
393+
builder: (_) => notFoundWidget,
394+
);
395+
}
396+
397+
/// to support something can't write in annotation
398+
/// it will be hadnled as a code when generate route
399+
final Map<String, dynamic>? codes;
400+
401+
/// The builder return the page
402+
final GoRouterPageBuilder builder;
403+
404+
/// The Widget base on this route
405+
//final Widget? widget;
406+
407+
/// Whether show status bar.
408+
final bool? showStatusBar;
409+
410+
/// The route name to track page
411+
final String? routeName;
412+
413+
/// The type of page route
414+
final PageRouteType? pageRouteType;
415+
416+
/// The description of route
417+
final String? description;
418+
419+
/// The extend arguments
420+
final Map<String, dynamic>? exts;
421+
422+
/// Whether the setting is targeting the not found route.
423+
bool get isNotFound =>
424+
name == FFRoute.notFoundName && routeName == FFRoute.notFoundRouteName;
425+
}
426+
427+
/// The builder return the page
428+
typedef GoRouterPageBuilder = Widget Function(
429+
Map<String, dynamic> safeArguments,
430+
);

pubspec.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
name: ff_annotation_route_library
22
description: The library for ff_annotation_route,support both null-safety and non-null-safety.
3-
version: 3.2.0
3+
version: 3.2.1
44
homepage: https://github.com/fluttercandies/ff_annotation_route_library
55

66
environment:
7-
sdk: '>=2.12.0 <4.0.0'
7+
sdk: ">=2.12.0 <4.0.0"
88

99
dependencies:
1010
flutter:
1111
sdk: flutter
1212

1313
collection: ^1.15.0
14-
ff_annotation_route_core: ^2.1.0
14+
ff_annotation_route_core: ^2.1.1
1515

1616
dev_dependencies:
1717
flutter_lints: any
18-
1918
# dependency_overrides:
2019
# ff_annotation_route_core:
2120
# path: ../ff_annotation_route_core

0 commit comments

Comments
 (0)