Flutter Hive - Unhandled exception: type 'List<dynamic>' is not a subtype of type 'List<SourceStations>' in type cast Flutter Hive - Unhandled exception: type 'List<dynamic>' is not a subtype of type 'List<SourceStations>' in type cast dart dart

Flutter Hive - Unhandled exception: type 'List<dynamic>' is not a subtype of type 'List<SourceStations>' in type cast


"Generic type parameters like Box<List> are unsupported due to Dart limitations."This is mentioned in the author documentation: https://docs.hivedb.dev/#/basics/boxes at the bottom of the page.


If you are not using a ValueListenableBuilder, you can do it like this:

await Hive.openBox<List<SourceStations>>(stationBox); //Open boxBox<List<SourceStations>> sourceStationsBox = Hive.box(stationBox); sourceStationsBox.put(key, listSourceStation); // key is a stringlogger.d('station box list length is ${sourceStationsBox.get(key).length}');