iampawan / iampawan/PokemonApp
NoSuchMethodError
- Dominant language
- Dart
- Stars
- 296
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Description
I followed your code and Im getting this
Error
I/flutter (12085): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (12085): The following NoSuchMethodError was thrown building HomePage(dirty, state: _HomePageState#4f655):
I/flutter (12085): The getter 'pokemon' was called on null.
I/flutter (12085): Receiver: null
I/flutter (12085): Tried calling: pokemon
I/flutter (12085):
I/flutter (12085): When the exception was thrown, this was the stack:
I/flutter (12085): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
I/flutter (12085): #1 _HomePageState.build
package:poke_dex/main.dart:49
I/flutter (12085): #2 StatefulElement.build
package:flutter/…/widgets/framework.dart:3825
I/flutter (12085): #3 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3736
I/flutter (12085): #4 Element.rebuild
package:flutter/…/widgets/framework.dart:3559
I/flutter (12085): #5 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3716
I/flutter (12085): #6 StatefulElement._firstBuild
theCode main.dart:
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'pokemon.dart';
void main() => runApp(MaterialApp(
title: "PokeDex",
home: HomePage(),
debugShowCheckedModeBanner: false,
));
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State {
var url ="https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json";
pokeData pkData ;
@override
void initState() {
super.initState();
pullData();
}
pullData() async {
var output = await http.get(url);
print(output);
var decodedJson = jsonDecode(output.body);
pkData=pokeData.fromJson(decodedJson) ;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("PokeDex"),
backgroundColor: Colors.cyan,
),
body: GridView.count(
crossAxisCount: 2,
children: pkData.pokemon.map((poke)=>Card()).toList()
),
drawer: Drawer(child: FlutterLogo(),),
floatingActionButton: FloatingActionButton(onPressed: (){
print(Text("ScrollDown"));
},child: Icon(Icons.search),
backgroundColor: Colors.red,
),
bottomNavigationBar: BottomAppBar(
color: Colors.cyan,
child: Container(height: 50.0,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
);
}
}
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.