Home > other >  type 'Null' is not a subtype of type 'List<dynamic>' in type cast
type 'Null' is not a subtype of type 'List<dynamic>' in type cast

Time:10-19

Please can anyone explain what's the issue with this! I am getting this error "type 'Null' is not a subtype of type 'List' in type cast"

&

"Invalid argument(s) (onError): The error handler of Future.catchError must return a value of the future's type"

factory Talent.fromJson(String userId, dynamic data) {
    try {
      print('This is the data we are looking for $userId $data');
      return Talent(
        id: userId,
        awareOf: data['awareOf'],
        firstName: data['firstName'],
        lastName: data['lastName'],
        aliasName: data['aliasName'],
        useRealName: data['useRealName'] ?? false,
        revealPicture: data['revealPicture'] ?? false,
        imageUrl: data['imageUrl'],
        staticLocation: LocationModel(
          label: data['staticLocation']['label'],
          latitude: data['staticLocation']['latitude'],
          longitude: data['staticLocation']['longitude'],
        ),
        searchRadius: data['searchRadius'] ?? 25,
        willingToMove: data['willingToMove'] ?? false,
        prefersRemote: data['prefersRemote'] ?? false,
        yearsOfExperience: data['yearsOfExperience'] ?? 0,
        salaryExpectation:
        SalaryExpectation.fromJson(data['salaryExpectation']),
        hardskills: data['hardskills'] ?? [],
        softskills: (data['softskills'] as List)?.first?.runtimeType != String
            ? (data['softskills'] as List)
            ?.map((json) => Softskill.fromJson(json))
            ?.toList() ??
            []
            : (data['softskills'] as List)
            ?.map((s) => Softskill.fromJson(json.decode(s)))
            ?.toList() ??
            [],
        studies: (data['studies'] as List)?.first?.runtimeType != String
            ? (data['studies'] as List)
            ?.map((s) => Study.fromJson(Map<String, dynamic>.from(s)))
            ?.toList() ??
            []
            : (data['studies'] as List)
            ?.map((s) => Study.fromJson(json.decode(s)))
            ?.toList() ??
            [],
        apprenticeships:
        (data['apprenticeships'] as List)?.first?.runtimeType != String
            ? (data['apprenticeships'] as List)
            ?.map((s) => Apprenticeship.fromJson(s))
            ?.toList() ??
            []
            : (data['apprenticeships'] as List)
            ?.map((s) => Apprenticeship.fromJson(json.decode(s)))
            ?.toList() ??
            [],
        coronaHelper: data['coronaHelper'] ?? false,
        driverLicense: data['driverLicense'] ?? false,
      );
    } on Exception catch (e) {
      Logger().e("Unable to parse Talent $e");
    }
    return Talent.fromJson(userId, data);
  }

flutter doctor -v

[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-arm, locale en-DE) • Flutter version 2.5.2 at /Users/almamun/Documents/developer/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 3595343e20 (3 weeks ago), 2021-09-30 12:58:18 -0700 • Engine revision 6ac856380f • Dart version 2.14.3

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/almamun/Library/Android/sdk • Platform android-31, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10 0-b96-7249189) • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 13.0, Build version 13A233 ✗ CocoaPods not installed. CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from:

  • Related