Dirty state error in flutter

Dirty state error in flutter



fifth.dart


import 'package:flutter/material.dart';
import 'package:emas_app/Dependant.dart' as Dep;
import 'package:emas_app/crm_dependent_list_model.dart';
import 'dart:convert';
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:emas_app/crm_dep_entitlement_model.dart';

final String url = "http://crm.emastpa.com.my/MemberInfo.json";

//Future to get list of dependent names
Future<List<DependantModel>> fetchUserInfo() async

http.Response response = await http.get(url);
var responsejson = json.decode(response.body);

return(responsejson[0]['Dependents'] as List)
.map((user) => DependantModel.fromJson(user))
.toList();


class Fifth extends StatefulWidget
@override
_FifthState createState() => _FifthState();


class _FifthState extends State<Fifth>

static Future<List<DependantModel>> depState;

@override
void initState()
depState = fetchUserInfo();
super.initState();


@override
Widget build(BuildContext context)

//ListView.builder inside FutureBuilder
var futureBuilder = new FutureBuilder<List<DependantModel>>(
future: depState,
builder: (context, snapshot)
switch(snapshot.connectionState)
case ConnectionState.none:
case ConnectionState.waiting:
return new Center(
child: new CircularProgressIndicator(),
);
default:
if(snapshot.hasError)
return new Text(snapshot.error);
else

List<DependantModel> user = snapshot.data;

return new ListView.builder(
itemCount: user.length,
itemBuilder: (context, index)
return new Column(
children: <Widget>[
new ListTile(
title: new Text(user[index].name,
style: TextStyle(fontSize: 20.0)),
subtitle: new Text(user[index].relationship,
style: TextStyle(fontSize: 15.0)),
trailing: new MaterialButton(color: Colors.greenAccent,
textColor: Colors.white,
child: new Text("More"),
onPressed: ()
Navigator.push(context,
new MaterialPageRoute(builder: (context) => Dep.Dependents(name: user[index].name)));

),
)
],
);
);


);

return new Scaffold(
body: futureBuilder,
);




I've just had the following error occurring in my flutter project.
I/flutter (12737): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (12737): The following assertion was thrown building FutureBuilder>(dirty, state:
I/flutter (12737): _FutureBuilderState>#b09b6):
I/flutter (12737): type 'NoSuchMethodError' is not a subtype of type 'String'
I/flutter (12737): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (12737): more information in this error message to help you determine and fix the underlying cause.
I/flutter (12737): In either case, please report this assertion by filing a bug on GitHub:



what is dirty state?





I guess the problem is here. return new Text(snapshot.error); Try to comment that line and check. It says, 'NoSuchMethodError' is not a subtype of type 'String' so I guess the problem is there
– Jaswant Singh
Aug 23 at 4:25






@JaswantSingh i have already commented the line and its still not working. The snapshot.hasError will return a text mentioning the error (snapshot.error). So this part will catch the error and will not contribute to fixing the error mentioned.
– steven sathish
Aug 23 at 5:52










By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)