Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add @pragma('vm:entry-point') to RestorableRouteBuilder arguments #118738

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

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CupertinoDialogExample extends StatelessWidget {
);
}

@pragma('vm:entry-point')
static Route<Object?> _dialogBuilder(
BuildContext context, Object? arguments) {
return CupertinoDialogRoute<void>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ModalPopupExample extends StatelessWidget {
);
}

@pragma('vm:entry-point')
static Route<void> _modalBuilder(BuildContext context, Object? arguments) {
return CupertinoModalPopupRoute<void>(
builder: (BuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget>
},
);

@pragma('vm:entry-point')
static Route<DateTime> _datePickerRoute(
BuildContext context,
Object? arguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget>
_restorableDateRangePickerRouteFuture, 'date_picker_route_future');
}

@pragma('vm:entry-point')
static Route<DateTimeRange?> _dateRangePickerRoute(
BuildContext context,
Object? arguments,
Expand Down
1 change: 1 addition & 0 deletions examples/api/lib/material/dialog/show_dialog.2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class DialogExample extends StatelessWidget {
);
}

@pragma('vm:entry-point')
static Route<Object?> _dialogBuilder(
BuildContext context, Object? arguments) {
return DialogRoute<void>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MyStatefulWidget extends StatefulWidget {
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@pragma('vm:entry-point')
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) => const MyStatefulWidget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MyStatefulWidget extends StatefulWidget {
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@pragma('vm:entry-point')
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) => const MyStatefulWidget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MyStatefulWidget extends StatefulWidget {
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@pragma('vm:entry-point')
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) => const MyStatefulWidget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MyStatefulWidget extends StatefulWidget {
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@pragma('vm:entry-point')
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) => const MyStatefulWidget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MyStatefulWidget extends StatefulWidget {
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@pragma('vm:entry-point')
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) => const MyStatefulWidget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MyStatefulWidget extends StatefulWidget {
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@pragma('vm:entry-point')
static Route<void> _myRouteBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) => const MyStatefulWidget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class _MyHomeState extends State<MyHome> with RestorationMixin {

// A static `RestorableRouteBuilder` that can re-create the route during
// state restoration.
@pragma('vm:entry-point')
static Route<int> _counterRouteBuilder(
BuildContext context, Object? arguments) {
return MaterialPageRoute<int>(
Expand Down
1 change: 1 addition & 0 deletions examples/api/lib/widgets/routes/show_general_dialog.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class GeneralDialogExample extends StatelessWidget {
);
}

@pragma('vm:entry-point')
static Route<Object?> _dialogBuilder(
BuildContext context, Object? arguments) {
return RawDialogRoute<void>(
Expand Down
12 changes: 7 additions & 5 deletions packages/flutter/lib/src/widgets/navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ typedef RouteListFactory = List<Route<dynamic>> Function(NavigatorState navigato
///
/// Used by the restorable methods of the [Navigator] that add anonymous routes
/// (e.g. [NavigatorState.restorablePush]). For this use case, the
/// [RestorableRouteBuilder] must be static function as the [Navigator] will
/// call it again during state restoration to re-create the route.
/// [RestorableRouteBuilder] must be static function annotated with
/// `@pragma('vm:entry-point')`. The [Navigator] will call it again during
/// state restoration to re-create the route.
typedef RestorableRouteBuilder<T> = Route<T> Function(BuildContext context, Object? arguments);

/// Signature for the [Navigator.popUntil] predicate argument.
Expand Down Expand Up @@ -2108,9 +2109,10 @@ class Navigator extends StatefulWidget {
/// {@macro flutter.widgets.navigator.push}
///
/// {@template flutter.widgets.Navigator.restorablePush}
/// The method takes a _static_ [RestorableRouteBuilder] as argument, which
/// must instantiate and return a new [Route] object that will be added to
/// the navigator. The provided `arguments` object is passed to the
/// The method takes a [RestorableRouteBuilder] as argument, which must be a
/// _static_ function annotated with `@pragma('vm:entry-point')`. It must
/// instantiate and return a new [Route] object that will be added to the
/// navigator. The provided `arguments` object is passed to the
/// `routeBuilder`. The navigator calls the static `routeBuilder` function
/// again during state restoration to re-create the route object.
///
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/cupertino/dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,7 @@ Widget createAppWithCenteredButton(Widget child) {
class _RestorableDialogTestWidget extends StatelessWidget {
const _RestorableDialogTestWidget();

@pragma('vm:entry-point')
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
return CupertinoDialogRoute<void>(
context: context,
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/cupertino/route_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,7 @@ class _TestPostRouteCancelState extends State<_TestPostRouteCancel> {
class _RestorableModalTestWidget extends StatelessWidget {
const _RestorableModalTestWidget();

@pragma('vm:entry-point')
static Route<void> _modalBuilder(BuildContext context, Object? arguments) {
return CupertinoModalPopupRoute<void>(
builder: (BuildContext context) {
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/date_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,7 @@ class _RestorableDatePickerDialogTestWidgetState extends State<_RestorableDatePi
}
}

@pragma('vm:entry-point')
static Route<DateTime> _datePickerRoute(
BuildContext context,
Object? arguments,
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/date_range_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ class _RestorableDateRangePickerDialogTestWidgetState extends State<_RestorableD
}
}

@pragma('vm:entry-point')
static Route<DateTimeRange?> _dateRangePickerRoute(
BuildContext context,
Object? arguments,
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,7 @@ void main() {
class _RestorableDialogTestWidget extends StatelessWidget {
const _RestorableDialogTestWidget();

@pragma('vm:entry-point')
static Route<Object?> _materialDialogBuilder(BuildContext context, Object? arguments) {
return DialogRoute<void>(
context: context,
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/time_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,7 @@ class _TimePickerLauncherState extends State<_TimePickerLauncher> with Restorati
},
);

@pragma('vm:entry-point')
static Route<TimeOfDay> _timePickerRoute(
BuildContext context,
Object? arguments,
Expand Down
2 changes: 2 additions & 0 deletions packages/flutter/test/widgets/navigator_restoration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ void main() {
});
}

@pragma('vm:entry-point')
Route<void> _routeBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) {
Expand All @@ -1025,6 +1026,7 @@ Route<void> _routeBuilder(BuildContext context, Object? arguments) {
);
}

@pragma('vm:entry-point')
Route<void> _routeFutureBuilder(BuildContext context, Object? arguments) {
return MaterialPageRoute<void>(
builder: (BuildContext context) {
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/widgets/routes_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,7 @@ class WidgetWithNoLocalHistoryState extends State<WidgetWithNoLocalHistory> {
class _RestorableDialogTestWidget extends StatelessWidget {
const _RestorableDialogTestWidget();

@pragma('vm:entry-point')
static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
return RawDialogRoute<void>(
pageBuilder: (
Expand Down