CustomParameterCodec class final
annotation to define a custom parameter decoder/encoder this is useful when the is encoded/decoded in a non-standard way like base64Url this must be used as an annotation on a field
String fromBase64(String value) {
return const Utf8Decoder()
.convert(base64Url.decode(base64Url.normalize(value)));
}
String toBase64(String value) {
return base64Url.encode(const Utf8Encoder().convert(value));
}
@TypedGoRoute<JsonRoute>(path: 'json')
class JsonRoute extends GoRouteData with _$EncodedRoute {
@CustomParameterCodec(
encode: toBase64,
decode: fromBase64,
)
final String data;
JsonRoute(this.data);
}
- Annotations
-
- @Target.new(<TargetKind>{TargetKind.field})
Constructors
- CustomParameterCodec({required String encode(String field), required String decode(String field)})
-
create a custom parameter codec
const
Properties
- decode → String Function(String field)
-
custom function to decode the field
final
- encode → String Function(String field)
-
custom function to encode the field
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited