mirror of
https://github.com/flutter/packages.git
synced 2025-06-29 22:33:11 +08:00
@ -1,3 +1,7 @@
|
|||||||
|
## 2.2.4
|
||||||
|
|
||||||
|
* Bumps example go_router version to v10.0.0 and migrate example code.
|
||||||
|
|
||||||
## 2.2.3
|
## 2.2.3
|
||||||
|
|
||||||
* Removes `path_to_regexp` from the dependencies.
|
* Removes `path_to_regexp` from the dependencies.
|
||||||
|
@ -58,7 +58,7 @@ class BigIntRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('BigIntRoute'),
|
title: const Text('BigIntRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class BoolRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('BoolRoute'),
|
title: const Text('BoolRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class DateTimeRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('DateTimeRoute'),
|
title: const Text('DateTimeRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ class DoubleRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('DoubleRoute'),
|
title: const Text('DoubleRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ class IntRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('IntRoute'),
|
title: const Text('IntRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ class NumRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('NumRoute'),
|
title: const Text('NumRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ class EnumRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('EnumRoute'),
|
title: const Text('EnumRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ class EnhancedEnumRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('EnhancedEnumRoute'),
|
title: const Text('EnhancedEnumRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ class StringRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('StringRoute'),
|
title: const Text('StringRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ class UriRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('UriRoute'),
|
title: const Text('UriRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ class IterableRoute extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('IterableRoute'),
|
title: const Text('IterableRoute'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ class IterableRouteWithDefaultValues extends GoRouteData {
|
|||||||
Widget drawerTile(BuildContext context) => ListTile(
|
Widget drawerTile(BuildContext context) => ListTile(
|
||||||
title: const Text('IterableRouteWithDefaultValues'),
|
title: const Text('IterableRouteWithDefaultValues'),
|
||||||
onTap: () => go(context),
|
onTap: () => go(context),
|
||||||
selected: GoRouterState.of(context).location == location,
|
selected: GoRouterState.of(context).uri.toString() == location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ class BasePage<T> extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
'Query param with default value: $queryParamWithDefaultValue',
|
'Query param with default value: $queryParamWithDefaultValue',
|
||||||
),
|
),
|
||||||
SelectableText(GoRouterState.of(context).location),
|
SelectableText(GoRouterState.of(context).uri.toString()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -94,7 +94,7 @@ extension $BigIntRouteExtension on BigIntRoute {
|
|||||||
requiredBigIntField:
|
requiredBigIntField:
|
||||||
BigInt.parse(state.pathParameters['requiredBigIntField']!),
|
BigInt.parse(state.pathParameters['requiredBigIntField']!),
|
||||||
bigIntField: _$convertMapValue(
|
bigIntField: _$convertMapValue(
|
||||||
'big-int-field', state.queryParameters, BigInt.parse),
|
'big-int-field', state.uri.queryParameters, BigInt.parse),
|
||||||
);
|
);
|
||||||
|
|
||||||
String get location => GoRouteData.$location(
|
String get location => GoRouteData.$location(
|
||||||
@ -119,10 +119,10 @@ extension $BoolRouteExtension on BoolRoute {
|
|||||||
requiredBoolField:
|
requiredBoolField:
|
||||||
_$boolConverter(state.pathParameters['requiredBoolField']!),
|
_$boolConverter(state.pathParameters['requiredBoolField']!),
|
||||||
boolField: _$convertMapValue(
|
boolField: _$convertMapValue(
|
||||||
'bool-field', state.queryParameters, _$boolConverter),
|
'bool-field', state.uri.queryParameters, _$boolConverter),
|
||||||
boolFieldWithDefaultValue: _$convertMapValue(
|
boolFieldWithDefaultValue: _$convertMapValue(
|
||||||
'bool-field-with-default-value',
|
'bool-field-with-default-value',
|
||||||
state.queryParameters,
|
state.uri.queryParameters,
|
||||||
_$boolConverter) ??
|
_$boolConverter) ??
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
@ -152,7 +152,7 @@ extension $DateTimeRouteExtension on DateTimeRoute {
|
|||||||
requiredDateTimeField:
|
requiredDateTimeField:
|
||||||
DateTime.parse(state.pathParameters['requiredDateTimeField']!),
|
DateTime.parse(state.pathParameters['requiredDateTimeField']!),
|
||||||
dateTimeField: _$convertMapValue(
|
dateTimeField: _$convertMapValue(
|
||||||
'date-time-field', state.queryParameters, DateTime.parse),
|
'date-time-field', state.uri.queryParameters, DateTime.parse),
|
||||||
);
|
);
|
||||||
|
|
||||||
String get location => GoRouteData.$location(
|
String get location => GoRouteData.$location(
|
||||||
@ -178,10 +178,10 @@ extension $DoubleRouteExtension on DoubleRoute {
|
|||||||
requiredDoubleField:
|
requiredDoubleField:
|
||||||
double.parse(state.pathParameters['requiredDoubleField']!),
|
double.parse(state.pathParameters['requiredDoubleField']!),
|
||||||
doubleField: _$convertMapValue(
|
doubleField: _$convertMapValue(
|
||||||
'double-field', state.queryParameters, double.parse),
|
'double-field', state.uri.queryParameters, double.parse),
|
||||||
doubleFieldWithDefaultValue: _$convertMapValue(
|
doubleFieldWithDefaultValue: _$convertMapValue(
|
||||||
'double-field-with-default-value',
|
'double-field-with-default-value',
|
||||||
state.queryParameters,
|
state.uri.queryParameters,
|
||||||
double.parse) ??
|
double.parse) ??
|
||||||
1.0,
|
1.0,
|
||||||
);
|
);
|
||||||
@ -209,11 +209,11 @@ extension $DoubleRouteExtension on DoubleRoute {
|
|||||||
extension $IntRouteExtension on IntRoute {
|
extension $IntRouteExtension on IntRoute {
|
||||||
static IntRoute _fromState(GoRouterState state) => IntRoute(
|
static IntRoute _fromState(GoRouterState state) => IntRoute(
|
||||||
requiredIntField: int.parse(state.pathParameters['requiredIntField']!),
|
requiredIntField: int.parse(state.pathParameters['requiredIntField']!),
|
||||||
intField:
|
intField: _$convertMapValue(
|
||||||
_$convertMapValue('int-field', state.queryParameters, int.parse),
|
'int-field', state.uri.queryParameters, int.parse),
|
||||||
intFieldWithDefaultValue: _$convertMapValue(
|
intFieldWithDefaultValue: _$convertMapValue(
|
||||||
'int-field-with-default-value',
|
'int-field-with-default-value',
|
||||||
state.queryParameters,
|
state.uri.queryParameters,
|
||||||
int.parse) ??
|
int.parse) ??
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
@ -240,11 +240,11 @@ extension $IntRouteExtension on IntRoute {
|
|||||||
extension $NumRouteExtension on NumRoute {
|
extension $NumRouteExtension on NumRoute {
|
||||||
static NumRoute _fromState(GoRouterState state) => NumRoute(
|
static NumRoute _fromState(GoRouterState state) => NumRoute(
|
||||||
requiredNumField: num.parse(state.pathParameters['requiredNumField']!),
|
requiredNumField: num.parse(state.pathParameters['requiredNumField']!),
|
||||||
numField:
|
numField: _$convertMapValue(
|
||||||
_$convertMapValue('num-field', state.queryParameters, num.parse),
|
'num-field', state.uri.queryParameters, num.parse),
|
||||||
numFieldWithDefaultValue: _$convertMapValue(
|
numFieldWithDefaultValue: _$convertMapValue(
|
||||||
'num-field-with-default-value',
|
'num-field-with-default-value',
|
||||||
state.queryParameters,
|
state.uri.queryParameters,
|
||||||
num.parse) ??
|
num.parse) ??
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
@ -272,11 +272,11 @@ extension $EnumRouteExtension on EnumRoute {
|
|||||||
static EnumRoute _fromState(GoRouterState state) => EnumRoute(
|
static EnumRoute _fromState(GoRouterState state) => EnumRoute(
|
||||||
requiredEnumField: _$PersonDetailsEnumMap
|
requiredEnumField: _$PersonDetailsEnumMap
|
||||||
._$fromName(state.pathParameters['requiredEnumField']!),
|
._$fromName(state.pathParameters['requiredEnumField']!),
|
||||||
enumField: _$convertMapValue('enum-field', state.queryParameters,
|
enumField: _$convertMapValue('enum-field', state.uri.queryParameters,
|
||||||
_$PersonDetailsEnumMap._$fromName),
|
_$PersonDetailsEnumMap._$fromName),
|
||||||
enumFieldWithDefaultValue: _$convertMapValue(
|
enumFieldWithDefaultValue: _$convertMapValue(
|
||||||
'enum-field-with-default-value',
|
'enum-field-with-default-value',
|
||||||
state.queryParameters,
|
state.uri.queryParameters,
|
||||||
_$PersonDetailsEnumMap._$fromName) ??
|
_$PersonDetailsEnumMap._$fromName) ??
|
||||||
PersonDetails.favoriteFood,
|
PersonDetails.favoriteFood,
|
||||||
);
|
);
|
||||||
@ -312,11 +312,11 @@ extension $EnhancedEnumRouteExtension on EnhancedEnumRoute {
|
|||||||
static EnhancedEnumRoute _fromState(GoRouterState state) => EnhancedEnumRoute(
|
static EnhancedEnumRoute _fromState(GoRouterState state) => EnhancedEnumRoute(
|
||||||
requiredEnumField: _$SportDetailsEnumMap
|
requiredEnumField: _$SportDetailsEnumMap
|
||||||
._$fromName(state.pathParameters['requiredEnumField']!),
|
._$fromName(state.pathParameters['requiredEnumField']!),
|
||||||
enumField: _$convertMapValue('enum-field', state.queryParameters,
|
enumField: _$convertMapValue('enum-field', state.uri.queryParameters,
|
||||||
_$SportDetailsEnumMap._$fromName),
|
_$SportDetailsEnumMap._$fromName),
|
||||||
enumFieldWithDefaultValue: _$convertMapValue(
|
enumFieldWithDefaultValue: _$convertMapValue(
|
||||||
'enum-field-with-default-value',
|
'enum-field-with-default-value',
|
||||||
state.queryParameters,
|
state.uri.queryParameters,
|
||||||
_$SportDetailsEnumMap._$fromName) ??
|
_$SportDetailsEnumMap._$fromName) ??
|
||||||
SportDetails.football,
|
SportDetails.football,
|
||||||
);
|
);
|
||||||
@ -352,9 +352,9 @@ const _$SportDetailsEnumMap = {
|
|||||||
extension $StringRouteExtension on StringRoute {
|
extension $StringRouteExtension on StringRoute {
|
||||||
static StringRoute _fromState(GoRouterState state) => StringRoute(
|
static StringRoute _fromState(GoRouterState state) => StringRoute(
|
||||||
requiredStringField: state.pathParameters['requiredStringField']!,
|
requiredStringField: state.pathParameters['requiredStringField']!,
|
||||||
stringField: state.queryParameters['string-field'],
|
stringField: state.uri.queryParameters['string-field'],
|
||||||
stringFieldWithDefaultValue:
|
stringFieldWithDefaultValue:
|
||||||
state.queryParameters['string-field-with-default-value'] ??
|
state.uri.queryParameters['string-field-with-default-value'] ??
|
||||||
'defaultValue',
|
'defaultValue',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -380,8 +380,8 @@ extension $StringRouteExtension on StringRoute {
|
|||||||
extension $UriRouteExtension on UriRoute {
|
extension $UriRouteExtension on UriRoute {
|
||||||
static UriRoute _fromState(GoRouterState state) => UriRoute(
|
static UriRoute _fromState(GoRouterState state) => UriRoute(
|
||||||
requiredUriField: Uri.parse(state.pathParameters['requiredUriField']!),
|
requiredUriField: Uri.parse(state.pathParameters['requiredUriField']!),
|
||||||
uriField:
|
uriField: _$convertMapValue(
|
||||||
_$convertMapValue('uri-field', state.queryParameters, Uri.parse),
|
'uri-field', state.uri.queryParameters, Uri.parse),
|
||||||
);
|
);
|
||||||
|
|
||||||
String get location => GoRouteData.$location(
|
String get location => GoRouteData.$location(
|
||||||
@ -404,49 +404,56 @@ extension $UriRouteExtension on UriRoute {
|
|||||||
extension $IterableRouteExtension on IterableRoute {
|
extension $IterableRouteExtension on IterableRoute {
|
||||||
static IterableRoute _fromState(GoRouterState state) => IterableRoute(
|
static IterableRoute _fromState(GoRouterState state) => IterableRoute(
|
||||||
intIterableField:
|
intIterableField:
|
||||||
state.queryParametersAll['int-iterable-field']?.map(int.parse),
|
state.uri.queryParametersAll['int-iterable-field']?.map(int.parse),
|
||||||
doubleIterableField: state.queryParametersAll['double-iterable-field']
|
doubleIterableField: state
|
||||||
|
.uri.queryParametersAll['double-iterable-field']
|
||||||
?.map(double.parse),
|
?.map(double.parse),
|
||||||
stringIterableField:
|
stringIterableField: state
|
||||||
state.queryParametersAll['string-iterable-field']?.map((e) => e),
|
.uri.queryParametersAll['string-iterable-field']
|
||||||
boolIterableField: state.queryParametersAll['bool-iterable-field']
|
?.map((e) => e),
|
||||||
|
boolIterableField: state.uri.queryParametersAll['bool-iterable-field']
|
||||||
?.map(_$boolConverter),
|
?.map(_$boolConverter),
|
||||||
enumIterableField: state.queryParametersAll['enum-iterable-field']
|
enumIterableField: state.uri.queryParametersAll['enum-iterable-field']
|
||||||
?.map(_$SportDetailsEnumMap._$fromName),
|
?.map(_$SportDetailsEnumMap._$fromName),
|
||||||
enumOnlyInIterableField: state
|
enumOnlyInIterableField: state
|
||||||
.queryParametersAll['enum-only-in-iterable-field']
|
.uri.queryParametersAll['enum-only-in-iterable-field']
|
||||||
?.map(_$CookingRecipeEnumMap._$fromName),
|
?.map(_$CookingRecipeEnumMap._$fromName),
|
||||||
intListField:
|
intListField: state.uri.queryParametersAll['int-list-field']
|
||||||
state.queryParametersAll['int-list-field']?.map(int.parse).toList(),
|
?.map(int.parse)
|
||||||
doubleListField: state.queryParametersAll['double-list-field']
|
.toList(),
|
||||||
|
doubleListField: state.uri.queryParametersAll['double-list-field']
|
||||||
?.map(double.parse)
|
?.map(double.parse)
|
||||||
.toList(),
|
.toList(),
|
||||||
stringListField: state.queryParametersAll['string-list-field']
|
stringListField: state.uri.queryParametersAll['string-list-field']
|
||||||
?.map((e) => e)
|
?.map((e) => e)
|
||||||
.toList(),
|
.toList(),
|
||||||
boolListField: state.queryParametersAll['bool-list-field']
|
boolListField: state.uri.queryParametersAll['bool-list-field']
|
||||||
?.map(_$boolConverter)
|
?.map(_$boolConverter)
|
||||||
.toList(),
|
.toList(),
|
||||||
enumListField: state.queryParametersAll['enum-list-field']
|
enumListField: state.uri.queryParametersAll['enum-list-field']
|
||||||
?.map(_$SportDetailsEnumMap._$fromName)
|
?.map(_$SportDetailsEnumMap._$fromName)
|
||||||
.toList(),
|
.toList(),
|
||||||
enumOnlyInListField: state.queryParametersAll['enum-only-in-list-field']
|
enumOnlyInListField: state
|
||||||
|
.uri.queryParametersAll['enum-only-in-list-field']
|
||||||
?.map(_$CookingRecipeEnumMap._$fromName)
|
?.map(_$CookingRecipeEnumMap._$fromName)
|
||||||
.toList(),
|
.toList(),
|
||||||
intSetField:
|
intSetField: state.uri.queryParametersAll['int-set-field']
|
||||||
state.queryParametersAll['int-set-field']?.map(int.parse).toSet(),
|
?.map(int.parse)
|
||||||
doubleSetField: state.queryParametersAll['double-set-field']
|
.toSet(),
|
||||||
|
doubleSetField: state.uri.queryParametersAll['double-set-field']
|
||||||
?.map(double.parse)
|
?.map(double.parse)
|
||||||
.toSet(),
|
.toSet(),
|
||||||
stringSetField:
|
stringSetField: state.uri.queryParametersAll['string-set-field']
|
||||||
state.queryParametersAll['string-set-field']?.map((e) => e).toSet(),
|
?.map((e) => e)
|
||||||
boolSetField: state.queryParametersAll['bool-set-field']
|
.toSet(),
|
||||||
|
boolSetField: state.uri.queryParametersAll['bool-set-field']
|
||||||
?.map(_$boolConverter)
|
?.map(_$boolConverter)
|
||||||
.toSet(),
|
.toSet(),
|
||||||
enumSetField: state.queryParametersAll['enum-set-field']
|
enumSetField: state.uri.queryParametersAll['enum-set-field']
|
||||||
?.map(_$SportDetailsEnumMap._$fromName)
|
?.map(_$SportDetailsEnumMap._$fromName)
|
||||||
.toSet(),
|
.toSet(),
|
||||||
enumOnlyInSetField: state.queryParametersAll['enum-only-in-set-field']
|
enumOnlyInSetField: state
|
||||||
|
.uri.queryParametersAll['enum-only-in-set-field']
|
||||||
?.map(_$CookingRecipeEnumMap._$fromName)
|
?.map(_$CookingRecipeEnumMap._$fromName)
|
||||||
.toSet(),
|
.toSet(),
|
||||||
);
|
);
|
||||||
@ -529,57 +536,60 @@ extension $IterableRouteWithDefaultValuesExtension
|
|||||||
on IterableRouteWithDefaultValues {
|
on IterableRouteWithDefaultValues {
|
||||||
static IterableRouteWithDefaultValues _fromState(GoRouterState state) =>
|
static IterableRouteWithDefaultValues _fromState(GoRouterState state) =>
|
||||||
IterableRouteWithDefaultValues(
|
IterableRouteWithDefaultValues(
|
||||||
intIterableField:
|
intIterableField: state.uri.queryParametersAll['int-iterable-field']
|
||||||
state.queryParametersAll['int-iterable-field']?.map(int.parse) ??
|
?.map(int.parse) ??
|
||||||
const <int>[0],
|
const <int>[0],
|
||||||
doubleIterableField: state.queryParametersAll['double-iterable-field']
|
doubleIterableField: state
|
||||||
|
.uri.queryParametersAll['double-iterable-field']
|
||||||
?.map(double.parse) ??
|
?.map(double.parse) ??
|
||||||
const <double>[0, 1, 2],
|
const <double>[0, 1, 2],
|
||||||
stringIterableField:
|
stringIterableField: state
|
||||||
state.queryParametersAll['string-iterable-field']?.map((e) => e) ??
|
.uri.queryParametersAll['string-iterable-field']
|
||||||
const <String>['defaultValue'],
|
?.map((e) => e) ??
|
||||||
boolIterableField: state.queryParametersAll['bool-iterable-field']
|
const <String>['defaultValue'],
|
||||||
|
boolIterableField: state.uri.queryParametersAll['bool-iterable-field']
|
||||||
?.map(_$boolConverter) ??
|
?.map(_$boolConverter) ??
|
||||||
const <bool>[false],
|
const <bool>[false],
|
||||||
enumIterableField: state.queryParametersAll['enum-iterable-field']
|
enumIterableField: state.uri.queryParametersAll['enum-iterable-field']
|
||||||
?.map(_$SportDetailsEnumMap._$fromName) ??
|
?.map(_$SportDetailsEnumMap._$fromName) ??
|
||||||
const <SportDetails>[SportDetails.tennis, SportDetails.hockey],
|
const <SportDetails>[SportDetails.tennis, SportDetails.hockey],
|
||||||
intListField: state.queryParametersAll['int-list-field']
|
intListField: state.uri.queryParametersAll['int-list-field']
|
||||||
?.map(int.parse)
|
?.map(int.parse)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const <int>[0],
|
const <int>[0],
|
||||||
doubleListField: state.queryParametersAll['double-list-field']
|
doubleListField: state.uri.queryParametersAll['double-list-field']
|
||||||
?.map(double.parse)
|
?.map(double.parse)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const <double>[1, 2, 3],
|
const <double>[1, 2, 3],
|
||||||
stringListField: state.queryParametersAll['string-list-field']
|
stringListField: state.uri.queryParametersAll['string-list-field']
|
||||||
?.map((e) => e)
|
?.map((e) => e)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const <String>['defaultValue0', 'defaultValue1'],
|
const <String>['defaultValue0', 'defaultValue1'],
|
||||||
boolListField: state.queryParametersAll['bool-list-field']
|
boolListField: state.uri.queryParametersAll['bool-list-field']
|
||||||
?.map(_$boolConverter)
|
?.map(_$boolConverter)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const <bool>[true],
|
const <bool>[true],
|
||||||
enumListField: state.queryParametersAll['enum-list-field']
|
enumListField: state.uri.queryParametersAll['enum-list-field']
|
||||||
?.map(_$SportDetailsEnumMap._$fromName)
|
?.map(_$SportDetailsEnumMap._$fromName)
|
||||||
.toList() ??
|
.toList() ??
|
||||||
const <SportDetails>[SportDetails.football],
|
const <SportDetails>[SportDetails.football],
|
||||||
intSetField:
|
intSetField: state.uri.queryParametersAll['int-set-field']
|
||||||
state.queryParametersAll['int-set-field']?.map(int.parse).toSet() ??
|
?.map(int.parse)
|
||||||
const <int>{0, 1},
|
.toSet() ??
|
||||||
doubleSetField: state.queryParametersAll['double-set-field']
|
const <int>{0, 1},
|
||||||
|
doubleSetField: state.uri.queryParametersAll['double-set-field']
|
||||||
?.map(double.parse)
|
?.map(double.parse)
|
||||||
.toSet() ??
|
.toSet() ??
|
||||||
const <double>{},
|
const <double>{},
|
||||||
stringSetField: state.queryParametersAll['string-set-field']
|
stringSetField: state.uri.queryParametersAll['string-set-field']
|
||||||
?.map((e) => e)
|
?.map((e) => e)
|
||||||
.toSet() ??
|
.toSet() ??
|
||||||
const <String>{'defaultValue'},
|
const <String>{'defaultValue'},
|
||||||
boolSetField: state.queryParametersAll['bool-set-field']
|
boolSetField: state.uri.queryParametersAll['bool-set-field']
|
||||||
?.map(_$boolConverter)
|
?.map(_$boolConverter)
|
||||||
.toSet() ??
|
.toSet() ??
|
||||||
const <bool>{true, false},
|
const <bool>{true, false},
|
||||||
enumSetField: state.queryParametersAll['enum-set-field']
|
enumSetField: state.uri.queryParametersAll['enum-set-field']
|
||||||
?.map(_$SportDetailsEnumMap._$fromName)
|
?.map(_$SportDetailsEnumMap._$fromName)
|
||||||
.toSet() ??
|
.toSet() ??
|
||||||
const <SportDetails>{SportDetails.hockey},
|
const <SportDetails>{SportDetails.hockey},
|
||||||
|
@ -158,7 +158,7 @@ RouteBase get $loginRoute => GoRouteData.$route(
|
|||||||
|
|
||||||
extension $LoginRouteExtension on LoginRoute {
|
extension $LoginRouteExtension on LoginRoute {
|
||||||
static LoginRoute _fromState(GoRouterState state) => LoginRoute(
|
static LoginRoute _fromState(GoRouterState state) => LoginRoute(
|
||||||
fromPage: state.queryParameters['from-page'],
|
fromPage: state.uri.queryParameters['from-page'],
|
||||||
);
|
);
|
||||||
|
|
||||||
String get location => GoRouteData.$location(
|
String get location => GoRouteData.$location(
|
||||||
|
@ -77,7 +77,7 @@ class MyShellRouteScreen extends StatelessWidget {
|
|||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
int getCurrentIndex(BuildContext context) {
|
int getCurrentIndex(BuildContext context) {
|
||||||
final String location = GoRouterState.of(context).location;
|
final String location = GoRouterState.of(context).uri.toString();
|
||||||
if (location == '/bar') {
|
if (location == '/bar') {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class MyShellRouteScreen extends StatelessWidget {
|
|||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
int getCurrentIndex(BuildContext context) {
|
int getCurrentIndex(BuildContext context) {
|
||||||
final String location = GoRouterState.of(context).location;
|
final String location = GoRouterState.of(context).uri.toString();
|
||||||
if (location.startsWith('/users')) {
|
if (location.startsWith('/users')) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
go_router: ^9.0.3
|
go_router: ^10.0.0
|
||||||
provider: 6.0.5
|
provider: 6.0.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
@ -101,7 +101,7 @@ String _stateValueAccess(ParameterElement element, Set<String> pathParameters) {
|
|||||||
if (pathParameters.contains(element.name)) {
|
if (pathParameters.contains(element.name)) {
|
||||||
access = 'pathParameters[${escapeDartString(element.name)}]';
|
access = 'pathParameters[${escapeDartString(element.name)}]';
|
||||||
} else {
|
} else {
|
||||||
access = 'queryParameters[${escapeDartString(element.name.kebab)}]';
|
access = 'uri.queryParameters[${escapeDartString(element.name.kebab)}]';
|
||||||
}
|
}
|
||||||
if (pathParameters.contains(element.name) ||
|
if (pathParameters.contains(element.name) ||
|
||||||
(!element.type.isNullableType && !element.hasDefaultValue)) {
|
(!element.type.isNullableType && !element.hasDefaultValue)) {
|
||||||
@ -284,12 +284,12 @@ class _TypeHelperIterable extends _TypeHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return '''
|
return '''
|
||||||
state.queryParametersAll[
|
state.uri.queryParametersAll[
|
||||||
${escapeDartString(parameterElement.name.kebab)}]
|
${escapeDartString(parameterElement.name.kebab)}]
|
||||||
?.map($entriesTypeDecoder)$iterableCaster''';
|
?.map($entriesTypeDecoder)$iterableCaster''';
|
||||||
}
|
}
|
||||||
return '''
|
return '''
|
||||||
state.queryParametersAll[${escapeDartString(parameterElement.name.kebab)}]''';
|
state.uri.queryParametersAll[${escapeDartString(parameterElement.name.kebab)}]''';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -334,7 +334,7 @@ abstract class _TypeHelperWithHelper extends _TypeHelper {
|
|||||||
(paramType.isNullableType || parameterElement.hasDefaultValue)) {
|
(paramType.isNullableType || parameterElement.hasDefaultValue)) {
|
||||||
return '$convertMapValueHelperName('
|
return '$convertMapValueHelperName('
|
||||||
'${escapeDartString(parameterName.kebab)}, '
|
'${escapeDartString(parameterName.kebab)}, '
|
||||||
'state.queryParameters, '
|
'state.uri.queryParameters, '
|
||||||
'${helperName(paramType)})';
|
'${helperName(paramType)})';
|
||||||
}
|
}
|
||||||
return '${helperName(paramType)}'
|
return '${helperName(paramType)}'
|
||||||
|
@ -2,7 +2,7 @@ name: go_router_builder
|
|||||||
description: >-
|
description: >-
|
||||||
A builder that supports generated strongly-typed route helpers for
|
A builder that supports generated strongly-typed route helpers for
|
||||||
package:go_router
|
package:go_router
|
||||||
version: 2.2.3
|
version: 2.2.4
|
||||||
repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder
|
repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder
|
||||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22
|
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22
|
||||||
|
|
||||||
@ -23,5 +23,5 @@ dependencies:
|
|||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_test: ^2.1.7
|
build_test: ^2.1.7
|
||||||
dart_style: 2.3.2
|
dart_style: 2.3.2
|
||||||
go_router: ^9.0.0
|
go_router: ^10.0.0
|
||||||
test: ^1.20.0
|
test: ^1.20.0
|
||||||
|
@ -6,7 +6,8 @@ RouteBase get $defaultValueRoute => GoRouteData.$route(
|
|||||||
extension $DefaultValueRouteExtension on DefaultValueRoute {
|
extension $DefaultValueRouteExtension on DefaultValueRoute {
|
||||||
static DefaultValueRoute _fromState(GoRouterState state) => DefaultValueRoute(
|
static DefaultValueRoute _fromState(GoRouterState state) => DefaultValueRoute(
|
||||||
param:
|
param:
|
||||||
_$convertMapValue('param', state.queryParameters, int.parse) ?? 0,
|
_$convertMapValue('param', state.uri.queryParameters, int.parse) ??
|
||||||
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
String get location => GoRouteData.$location(
|
String get location => GoRouteData.$location(
|
||||||
|
@ -6,7 +6,8 @@ RouteBase get $extraValueRoute => GoRouteData.$route(
|
|||||||
extension $ExtraValueRouteExtension on ExtraValueRoute {
|
extension $ExtraValueRouteExtension on ExtraValueRoute {
|
||||||
static ExtraValueRoute _fromState(GoRouterState state) => ExtraValueRoute(
|
static ExtraValueRoute _fromState(GoRouterState state) => ExtraValueRoute(
|
||||||
param:
|
param:
|
||||||
_$convertMapValue('param', state.queryParameters, int.parse) ?? 0,
|
_$convertMapValue('param', state.uri.queryParameters, int.parse) ??
|
||||||
|
0,
|
||||||
$extra: state.extra as int?,
|
$extra: state.extra as int?,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ RouteBase get $iterableDefaultValueRoute => GoRouteData.$route(
|
|||||||
extension $IterableDefaultValueRouteExtension on IterableDefaultValueRoute {
|
extension $IterableDefaultValueRouteExtension on IterableDefaultValueRoute {
|
||||||
static IterableDefaultValueRoute _fromState(GoRouterState state) =>
|
static IterableDefaultValueRoute _fromState(GoRouterState state) =>
|
||||||
IterableDefaultValueRoute(
|
IterableDefaultValueRoute(
|
||||||
param:
|
param: state.uri.queryParametersAll['param']?.map(int.parse) ??
|
||||||
state.queryParametersAll['param']?.map(int.parse) ?? const <int>[0],
|
const <int>[0],
|
||||||
);
|
);
|
||||||
|
|
||||||
String get location => GoRouteData.$location(
|
String get location => GoRouteData.$location(
|
||||||
|
@ -6,7 +6,7 @@ RouteBase get $iterableWithEnumRoute => GoRouteData.$route(
|
|||||||
extension $IterableWithEnumRouteExtension on IterableWithEnumRoute {
|
extension $IterableWithEnumRouteExtension on IterableWithEnumRoute {
|
||||||
static IterableWithEnumRoute _fromState(GoRouterState state) =>
|
static IterableWithEnumRoute _fromState(GoRouterState state) =>
|
||||||
IterableWithEnumRoute(
|
IterableWithEnumRoute(
|
||||||
param: state.queryParametersAll['param']
|
param: state.uri.queryParametersAll['param']
|
||||||
?.map(_$EnumOnlyUsedInIterableEnumMap._$fromName),
|
?.map(_$EnumOnlyUsedInIterableEnumMap._$fromName),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ extension $NullableRequiredParamNotInPathExtension
|
|||||||
on NullableRequiredParamNotInPath {
|
on NullableRequiredParamNotInPath {
|
||||||
static NullableRequiredParamNotInPath _fromState(GoRouterState state) =>
|
static NullableRequiredParamNotInPath _fromState(GoRouterState state) =>
|
||||||
NullableRequiredParamNotInPath(
|
NullableRequiredParamNotInPath(
|
||||||
id: _$convertMapValue('id', state.queryParameters, int.parse),
|
id: _$convertMapValue('id', state.uri.queryParameters, int.parse),
|
||||||
);
|
);
|
||||||
|
|
||||||
String get location => GoRouteData.$location(
|
String get location => GoRouteData.$location(
|
||||||
|
@ -7,7 +7,7 @@ extension $NonNullableRequiredParamNotInPathExtension
|
|||||||
on NonNullableRequiredParamNotInPath {
|
on NonNullableRequiredParamNotInPath {
|
||||||
static NonNullableRequiredParamNotInPath _fromState(GoRouterState state) =>
|
static NonNullableRequiredParamNotInPath _fromState(GoRouterState state) =>
|
||||||
NonNullableRequiredParamNotInPath(
|
NonNullableRequiredParamNotInPath(
|
||||||
id: int.parse(state.queryParameters['id']!),
|
id: int.parse(state.uri.queryParameters['id']!),
|
||||||
);
|
);
|
||||||
|
|
||||||
String get location => GoRouteData.$location(
|
String get location => GoRouteData.$location(
|
||||||
|
@ -56,6 +56,6 @@ Future<void> main() async {
|
|||||||
.trim()
|
.trim()
|
||||||
.replaceAll('\r\n', '\n');
|
.replaceAll('\r\n', '\n');
|
||||||
expect(generated, equals(expectResult.replaceAll('\r\n', '\n')));
|
expect(generated, equals(expectResult.replaceAll('\r\n', '\n')));
|
||||||
});
|
}, timeout: const Timeout(Duration(seconds: 100)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user