SmartApiKeyMap class
Tells smart_api which JSON keys to look for when your backend's
response shape doesn't match the library's defaults.
Pass this to SmartApiConfig.init(keyMap: ...) when renaming keys is
enough (e.g. your backend uses ok/msg/payload instead of
success/message/data). For a fully custom or nested response
envelope, use SmartApiConfig.init(responseParser: ...) instead.
Constructors
-
SmartApiKeyMap({List<
String> successKeys = const ['success', 'status', 'ok'], List successValues = const [true, 1, '1', 200, 'success', 'true'], List<String> messageKeys = const ['message', 'msg', 'error'], List<String> statusCodeKeys = const ['status_code', 'statusCode', 'code'], List<String> dataKeys = const ['data', 'body', 'result', 'payload']}) -
Creates a key map. The defaults cover the most common backend
conventions, so most apps only need to override a subset.
const
Properties
-
dataKeys
→ List<
String> -
Candidate keys checked, in order, for the actual payload/data.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
messageKeys
→ List<
String> -
Candidate keys checked, in order, for the response message.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
statusCodeKeys
→ List<
String> -
Candidate keys checked, in order, for a status code embedded in the
response body itself (as opposed to the HTTP status code).
final
-
successKeys
→ List<
String> -
Candidate keys checked, in order, for the success flag.
final
- successValues → List
-
Values that count as "successful" for whichever successKeys entry
is found (e.g.
true,1,200).final
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