well_known library
Helpers for working with protobuf well-known types as plain Dart maps.
Each well-known type (Struct, Value, Timestamp, Duration, Any) is
represented as Map<String, Object?> matching the proto3 JSON mapping.
These functions convert between that representation and idiomatic Dart
types, following the canonical JSON encoding rules from:
Functions
-
durationToString(
Map< String, Object?> duration) → String -
Converts a
google.protobuf.Durationto its canonical string form. -
mapToStruct(
Map< String, Object?> map) → Map<String, Object?> -
Converts a plain Dart map to a
google.protobuf.StructJSON map. -
nativeToValue(
Object? value) → Map< String, Object?> -
Converts a native Dart value to a
google.protobuf.ValueJSON map. -
packAny(
String typeUrl, Map< String, Object?> message) → Map<String, Object?> -
Packs a message into a
google.protobuf.AnyJSON representation. -
rfc3339ToTimestamp(
String rfc3339) → Map< String, Object?> -
Parses an RFC 3339 string into a
google.protobuf.Timestamp. -
stringToDuration(
String durationStr) → Map< String, Object?> -
Parses a duration string (
"Xs","X.Ns") into agoogle.protobuf.Duration. -
structToMap(
Map< String, Object?> struct) → Map<String, Object?> -
Converts a
google.protobuf.StructJSON map to a plain Dart map. -
timestampToRfc3339(
Map< String, Object?> timestamp) → String -
Converts a
google.protobuf.Timestampto an RFC 3339 string. -
unpackAny(
Map< String, Object?> any) → Map<String, Object?> -
Unpacks a
google.protobuf.AnyJSON representation. -
valueToNative(
Map< String, Object?> value) → Object? -
Converts a
google.protobuf.ValueJSON map to its native Dart equivalent.