2
I’m trying to fetch an API Token using Flutter, but this code:
var _random = Random.secure();
var random = List<int>.generate(32, (i) => _random.nextInt(256));
var verificador = base64Url.encode(random).replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '');
var base64ToSha256 = sha256.convert(verificador);//erro aqui
var desafio = base64Url.encode(base64ToSha256).replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '');
But I’m having trouble using sha256.Convert
Error displayed: The argument type 'String' can’t be Assigned to the Parameter type 'List'
Thanks Julio for the explanation. But now I have another problem ._.
– AristoEinstein
The part:
var desafio = base64Url.encode(base64ToSha256)
is making that mistakeThe argument type 'Digest' can't be assigned to the parameter type 'List<int>'
what serious method to fix? Gave a search on this error but did not find much (in fact found nothing)– AristoEinstein
What implementation/lib are you using for sha256?? It’s basically the same problem, you’re trying to pass a type
Digest
for a method that accepts an int List.– Julio Henrique Bitencourt
import 'package:Crypto/Crypto.Dart';
– AristoEinstein
Okay, so the object
Digest
has an attributebytes
which is a list of int. Then do:var desafio = base64Url.encode(base64ToSha256.bytes)
– Julio Henrique Bitencourt