Receiver: null
Hemant-7 opened this issue · comments
my code is :
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:pokemon/pokemon_list_modal.dart';
import 'dart:convert';
void main() => runApp(MaterialApp(
title: "Pokemon",
theme: ThemeData(primarySwatch: Colors.teal),
debugShowCheckedModeBanner: false,
home: HomePage(),
));
//MARK:- This is our first Page.
class HomePage extends StatefulWidget {
// This widget is the root of your application.
@OverRide
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State {
var url =
"https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json";
PokemonList pokemonList;
@OverRide
void initState() {
super.initState();
getPokemonList();
// fetchData();
}
getPokemonList() async {
var res = await http.get(url);
var decodedValue = jsonDecode(res.body);
pokemonList = PokemonList.fromJson(decodedValue);
print(pokemonList.pokemon[0].name);
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Pokemons"),
centerTitle: true,
),
body: pokemonList == null
? Center(
child: CircularProgressIndicator(),
)
: GridView.count(
crossAxisCount: 2,
// children: [],
children:
pokemonList.pokemon.map((Pokemon poke) => Card()).toList(),
),
drawer: Drawer(),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.refresh),
),
);
}
}