I/flutter ( 8282): The following NoSuchMethodError was thrown building Meme(dirty, state: _MemeState#77e49):
I/flutter ( 8282): The getter 'iterator' was called on null.
I/flutter ( 8282): Receiver: null
I/flutter ( 8282): Tried calling: iterator
I/flutter ( 8282):
I/flutter ( 8282): The relevant error-causing widget was:
I/flutter ( 8282): Meme file:///F:/android_studio_projects/daily_indian_memes/lib/main.dart:7:9
I/flutter ( 8282):
I/flutter ( 8282): When the exception was thrown, this was the stack:
I/flutter ( 8282): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
I/flutter ( 8282): #1 _MemeState.build (package:dailyindianmemes/main.dart:102:30)
I/flutter ( 8282): #2 StatefulElement.build (package:flutter/src/widgets/framework.dart:4334:27)
I/flutter ( 8282): #3 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4223:15)
I/flutter ( 8282): #4 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 8282): #5 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 8282): #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
I/flutter ( 8282): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 8282): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 8282): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 8282): #10 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 8282): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 8282): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 8282): #13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 8282): #14 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 8282): #15 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 8282): #16 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 8282): #17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 8282): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 8282): #19 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 8282): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 8282): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 8282): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 8282): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 8282): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 8282): #25 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 8282): #26 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 8282): #27 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 8282): #28 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
I/flutter ( 8282): #29 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 8282): #30 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 8282): #31 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 8282): #32 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 8282): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 8282): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 8282): #35 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 8282): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 8282): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 8282): #38 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 8282): #39 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 8282): #40 ComponentElement._firstBuild
А вот код:
import 'package:flutter/material.dart';
import 'package:dailyindianmemes/about.dart';
import 'package:http/http.dart';
void main() => runApp(MaterialApp(
home: Meme(),
));
class Meme extends StatefulWidget {
@override
_MemeState createState() => _MemeState();
}
class _MemeState extends State<Meme> {
var len ;
void getData() async {
Response response = await get('http://glappy.freeasphost.net/');
var urlBunch = response.body;
List<String> urls = new List();
urls = urlBunch.split(',');
}
@override
void initState() {
super.initState();
getData();
}
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[850],
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.grey[850],
title: Text(
'Indian Memes',
style: TextStyle(
color: Colors.white,
letterSpacing: 1,
fontSize: 25,
fontWeight: FontWeight.bold
),
),
),
drawer: Drawer(
child: Container(
color: Colors.grey[850],
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
padding: EdgeInsets.zero,
child: Text(
' Indian Memes ',
style: TextStyle(
color: Colors.white,
letterSpacing: 1.5,
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
decoration: BoxDecoration(
color: Colors.grey[850],
),
),
ListTile(
leading: Icon(Icons.image,color: Colors.grey),
title: Text('Memes',
style: TextStyle(
color: Colors.white
),
),
onTap: (){
//to the page navigating to...
Navigator.pop(context);
},
),
ListTile(
leading: Icon(Icons.info_outline,color: Colors.grey,),
title: Text('About',
style: TextStyle(color: Colors.white)),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => About()));
},
),
for ( var i in len ) Text(i.toString())
],
),
),
),
body: ListView(
padding: EdgeInsets.fromLTRB(0, 0, 0, 10),
children: <Widget>[
],
)
);
}
}
Как это исправить?