I have a specific situation, so I need to put some data into a model with FutureProvider but I also need to have some additional fields that I want to change during the app, these fields need to be reactive. So this is my StateNotifier class:
class AirportNotifier extends StateNotifier<List<Airport>> {
AirportNotifier(super.state);
void updateIsActive(String value, int index) {
state[index].isActive = value;
}
}
My base class:
class Airport {
final String? name;
final String? description;
//final Uint8List? imageBytes;
String? isActive = "ve";
Airport({
this.name,
this.description,
});
factory Airport.fromJson(Map<String, dynamic> json) {
return Airport(name: json['name'], description: json['description']
//imageBytes: base64.decode(json['icon']),
);
}
}
Here I'm trying to create StateNotifier provider
final checkProvider =
StateNotifierProvider<AirportNotifier, List<Airport>>((ref) {
return AirportNotifier();
});
So, one way is to not use FutureProvider, in that way solution will be to send data like argument here
AirportNotifier(---);
But I have problem with converting Future<List> to List, every single solution on SO is just some basic things, I just need to convert this to List or to combine StateNotifier with FutureProvider on some way