providerIcon function Null safety

IconData providerIcon(
  1. BuildContext context,
  2. String providerId
)

Implementation

IconData providerIcon(BuildContext context, String providerId) {
  final isCupertino = CupertinoUserInterfaceLevel.maybeOf(context) != null;

  switch (providerId) {
    case GOOGLE_PROVIDER_ID:
      return SocialIcons.google;
    case APPLE_PROVIDER_ID:
      return SocialIcons.apple;
    case TWITTER_PROVIDER_ID:
      return SocialIcons.twitter;
    case FACEBOOK_PROVIDER_ID:
      return SocialIcons.facebook;
    case PHONE_PROVIDER_ID:
      if (isCupertino) {
        return CupertinoIcons.phone;
      } else {
        return Icons.phone;
      }
    case PASSWORD_PROVIDER_ID:
      if (isCupertino) {
        return CupertinoIcons.mail;
      } else {
        return Icons.email_outlined;
      }
    default:
      throw Exception('Unknown provider: $providerId');
  }
}