Unhandled exception:
type 'Null' is not a subtype of type 'String'
#0 DuolingoImpl.user (package:duolingo4d/src/duolingo_impl.dart:107:13)
#1 DuolingoImpl.authenticate (package:duolingo4d/src/duolingo_impl.dart:82:34)
<asynchronous suspension>
#2 main (file:///home/******/Documents/duolingo/bin/duolingo.dart:12:37)
<asynchronous suspension>
import 'package:duolingo4d/duolingo4d.dart';
void main() async {
final duolingo = Duolingo.instance;
final AuthResponse authResponse = await duolingo.authenticate(
username: '*************',
password: '***********',
);
if (authResponse.status.isNotOk) {
// Client or Server error or something.
authResponse.status.reasonPhrase;
authResponse.headers;
return;
}
if (authResponse.hasError) {
// When there is an error on authentication.
final authError = authResponse.error!;
print(authError.code);
print(authError.reason);
authError.isInvalidUser; // Returns true if user is invalid.
authError.isInvalidPassword; // Returns true if password is invalid.
return;
}
// Do something if user is authenticated.
}