I am coding a Pokedex app with API, with simple http get, my StateFul Widget looks like this:
class _PokemonGridState extends State<PokemonGrid> {
List? pokedex;
Future<void> searchPokemonGOData() async {
var url = Uri.http(
'raw.githubusercontent.com',
'/Biuni/PokemonGO-Pokedex/master/pokedex.json',
);
await http.get(url).then(
(value) {
if (value.statusCode == 200) {
var decodeJsonData = jsonDecode(value.body);
pokedex = decodeJsonData['pokemon'];
setState(() {});
}
},
);
}
@override
void initState() {
super.initState();
if (mounted) {
searchPokemonGOData();
}
}
I want to use the function searchPokemonGOData() from MobX controller but I don't know how, the store file and .g file are already ready. I want something to replace the initState() from StateFul, is that possible?