title: Error Retrieving cached api data from HiveDB in flutter
body: <p>I am trying to implement API data caching in my flutter application to enable offline usage of the app. However when I try to return the data it gives me a <code>type '_InternalLinkedHashMap&lt;dynamic, dynamic&gt;' is not a subtype of type 'Map&lt;String, dynamic&gt;'</code> error.</p>
  <p>I have verified that the data being stored in the hive DB is the api data that I am receiving.</p>
  <p><strong>!!IMPORTANT!!</strong> The way that this error is occurring is very odd. It only shows this error upon doing a FLUTTER RESTART and navigating to this page. However if I were to fetch the API data by being connected to the internet then navigating back to the home page, and then turning off my network connection and navigating back to this page, this error WILL NOT show.</p>
  <p>Any help to solve this issue would be appreciated. Thanks :)</p>
  <p>I have attached my code below:</p>
  <p><strong>API CLASS</strong></p>
  <pre><code>class HTTPService {
  
    Future&lt;List&lt;DriverStandings&gt;&gt; getDrivers(String year) async {
      final String urlStr =
          'https://ergast.com/api/f1/' + year + '/driverStandings.json';
      final Uri url = Uri.parse(urlStr);
      try {
        final response = await http.get(url);
        if (response.statusCode == 200) {
          List&lt;dynamic&gt; result = jsonDecode(response.body)[&quot;MRData&quot;]
              [&quot;StandingsTable&quot;][&quot;StandingsLists&quot;][0][&quot;DriverStandings&quot;];
          Hive.box('API_DATA').put('drivers ' + year, result);
          List&lt;DriverStandings&gt; drivers = result
              .map((dynamic driver) =&gt; DriverStandings.fromJson(driver))
              .toList();
  
          return drivers;
        } else {
          throw Exception(&quot;Failed to load&quot;);
        }
      } catch (SocketExceptionError) {
        print('catching');
        List&lt;dynamic&gt; cacheResult =
            Hive.box('API_DATA').get('drivers ' + year, defaultValue: []);
        if (cacheResult.isNotEmpty) {
          print('is not empty');
          print(cacheResult);
          List&lt;DriverStandings&gt; drivers = cacheResult
              .map((dynamic driver) =&gt; DriverStandings.fromJson(driver))
              .toList();
          return drivers;
        } else {
          return [
            DriverStandings(
                points: 'null',
                driver: Driver(
                    familyName: 'null',
                    permanentNumber: 'null',
                    code: 'null',
                    givenName: 'null'),
                wins: 'null')
          ];
        }
      }
    }
  }
  </code></pre>
  <p><strong>MODEL CLASS</strong></p>
  <pre><code>class DriverStandings {
    String points;
    String wins;
    Driver driver;
  
    DriverStandings(
        {required this.points, required this.driver, required this.wins});
  
    factory DriverStandings.fromJson(Map&lt;String, dynamic&gt; json) {
      return DriverStandings(
          points: json['points'],
          driver: Driver.fromJson(json['Driver']),
          wins: json['wins']);
    }
  }
  
  class Driver {
    String code;
    String givenName;
    String familyName;
    String permanentNumber;
  
    Driver(
        {required this.familyName,
        required this.permanentNumber,
        required this.code,
        required this.givenName});
  
    factory Driver.fromJson(Map&lt;String, dynamic&gt; json) {
      return Driver(
          familyName: json['familyName'],
          permanentNumber: json['permanentNumber'],
          code: json['code'],
          givenName: json['givenName']);
    }
  }
  </code></pre>
  <p><strong>FUTURE BUILDER TO DISPLAY</strong></p>
  <pre><code>FutureBuilder(
                              future: httpService.getDrivers('current'),
                              builder: (BuildContext context,
                                  AsyncSnapshot&lt;List&lt;DriverStandings&gt;&gt; snapshot) {
                                if (snapshot.hasData) {
                                  return ListView.separated(
                                    itemCount: snapshot.data!.length,
                                    itemBuilder: (context, index) {
                                      if (driver.points == 'null') {
                                         return NoInternetError();
                                      }
                                      return DriverWidget(
                                          givenName: snapshot
                                              .data![index].driver.givenName,
                                          familyName: snapshot
                                              .data![index].driver.familyName,
                                          code: snapshot.data![index].driver.code,
                                          permanentNumber: snapshot.data![index]
                                              .driver.permanentNumber,
                                          points: snapshot.data![index].points,
                                          wins: snapshot.data![index].wins);
                                    },
                                    separatorBuilder:
                                        (BuildContext context, int index) {
                                      return SizedBox(height: 30.0);
                                    },
                                  );
                                } else if (snapshot.hasError) {
                                  return Text(
                                    snapshot.error.toString(),
                                    style: TextStyle(color: Colors.white),
                                  );
                                }
                                return CircularProgressIndicator();
                              },
                            )
  </code></pre>