platformExceptionToFirebaseException function
FirebaseException
platformExceptionToFirebaseException(
- PlatformException platformException, {
- required String plugin,
Converts a PlatformException into a FirebaseException.
A PlatformException can only be converted to a FirebaseException if the
details
of the exception exist. Firebase returns specific codes and messages
which can be converted into user friendly exceptions.
Implementation
FirebaseException platformExceptionToFirebaseException(
PlatformException platformException, {
required String plugin,
}) {
Map<String, Object>? details = platformException.details != null
? Map<String, Object>.from(platformException.details)
: null;
String? code;
String message = platformException.message ?? '';
if (details != null) {
code = (details['code'] as String?) ?? code;
message = (details['message'] as String?) ?? message;
}
return FirebaseException(
plugin: plugin,
code: code,
message: message,
);
}