login method Null safety

Future<JMUserInfo?> login(
  1. {required String? username,
  2. required String? password}
)

Implementation

Future<JMUserInfo?> login({
  required String? username,
  required String? password,
}) async {
  if (username == null || password == null) {
    throw ("username or password was passed null");
  }
  print("Action - login: username=$username,pw=$password");

  Map? userJson = await _channel
      .invokeMethod('login', {'username': username, 'password': password});
  if (userJson == null) {
    return null;
  } else {
    return JMUserInfo.fromJson(userJson);
  }
}