From 2fdf3e828479ba23a713a986099f6eaaec634cf5 Mon Sep 17 00:00:00 2001 From: Lukas Lihotzki Date: Wed, 5 May 2021 12:05:26 +0200 Subject: [PATCH] refactor: polymorphism can be used without manual switch statement --- .../model/auth/authentication_password.dart | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/lib/src/model/auth/authentication_password.dart b/lib/src/model/auth/authentication_password.dart index bfc85546..77ed95d4 100644 --- a/lib/src/model/auth/authentication_password.dart +++ b/lib/src/model/auth/authentication_password.dart @@ -68,23 +68,7 @@ class AuthenticationPassword extends AuthenticationData { final data = super.toJson(); if (user != null) data['user'] = user; data['password'] = password; - switch (identifier.type) { - case AuthenticationIdentifierTypes.userId: - data['identifier'] = - (identifier as AuthenticationUserIdentifier).toJson(); - break; - case AuthenticationIdentifierTypes.phone: - data['identifier'] = - (identifier as AuthenticationPhoneIdentifier).toJson(); - break; - case AuthenticationIdentifierTypes.thirdParty: - data['identifier'] = - (identifier as AuthenticationThirdPartyIdentifier).toJson(); - break; - default: - data['identifier'] = identifier.toJson(); - break; - } + data['identifier'] = identifier.toJson(); return data; } }