Gbenga B Ayannuga
Gbenga B Ayannuga

Reputation: 2792

Error: The argument type 'Uint8List?' can't be assigned to the parameter type 'Iterable<int>

i am this as i convert to Null- safety, and i keep getting this error

error

here is my code

try {
      final AuthorizationResult appleResult =
          await TheAppleSignIn.performRequests([
        AppleIdRequest(requestedScopes: [Scope?.email, Scope?.fullName])
      ]);
      if (appleResult.error != null) {
        // handle errors from Apple here
      }

      final AuthCredential credential = OAuthProvider('apple.com').credential(
        accessToken:
            String.fromCharCodes(appleResult.credential!.authorizationCode),//here the error coming out.... i have also try Uint8List.fromList but still showing the error
        idToken: String.fromCharCodes(appleResult.credential!.identityToken),//here the error coming out.... i have also try Uint8List.fromList but still showing the error
      );
      final firebaseResult = await auth.signInWithCredential(credential);
      users = firebaseResult.user;
      if (users == null) {
        return false;
      }
      return true;
    } catch (error) {
      print(error);
      return false;
    }

i have also try

Uint8List.from()

Upvotes: 2

Views: 13166

Answers (1)

CopsOnRoad
CopsOnRoad

Reputation: 267724

Problem:

Your Uint8List? is nullable and Iterable<int> is non-nullable so you can't assign nullable to non-nullable.

Solutions:

  1. Provide a default value if Unit8List? can be null.

    Iterable<int> iterable = yourUint8List ?? []; 
    
  2. Use bang operator if Uint8List? can't be null.

    Iterable<int> iterable = yourUint8List!;
    

Upvotes: 4

Related Questions