fromIdentifier static method
Resolves a BleBondState from its String identifier as sent by the native platform.
Matching is case-insensitive. Any value that does not correspond to a known state — including a null argument or
an identifier introduced by a newer native layer than this Dart code — resolves to BleBondState.unknown rather
than throwing. This keeps the method channel handler resilient to unexpected payloads.
- Parameter
identifier: The raw state identifier received from the platform, such as"bonded"or"failed". - Returns: The matching BleBondState, or BleBondState.unknown when no match is found.
Implementation
static BleBondState fromIdentifier(String? identifier) {
if (identifier == null) {
return BleBondState.unknown;
}
final String normalized = identifier.toLowerCase();
for (final BleBondState state in BleBondState.values) {
if (state.identifier == normalized) {
return state;
}
}
return BleBondState.unknown;
}