for new users who are working now a days JSON.decode will occur errors so to solve this... import 'dart:convert' show json; and then in place of var myData =.... type this >> var myData = json.decode(snapshot.data.toString()); >> This will work for you!! :)
Hello, can you explain the 'BuildContext context' how it's looping with the list of elements in json and also the context and snapshot of FutureBuilder(builder:(context, snapshot){})
Hi! I really like your video, but at the end of the video I can see that you have two filled in the lib directory, is it possible to have the entire content of both files in the PDF file or in your Github account, that will be very helpful.
Hiii. I am using same code . But json data is not being fetched . Despite there is not a single error. App is running on emulator. But json data is not coming
can you make for this app refresh so when and new data come I make refresh to get it +++ can you make a notification system for this app so when any new data come the notification appear
Im a fan of ur channel, been looking bloc tutorial from ur channel, if u wont mind, i want to read data from an api using stream as well as send request to the api using the bloc logic, can u help with that
I'm trying to hit a java rest API which takes input values. Based on the values the records are fetched. Can you tell me how to pass a parameter through http request object?? Your videos are really helpful btw! Thanks a ton.
I was getting some errors after decoding the json file and then I figured it out.. Here's the code with maybe some changes, if anyone of u get stuck at some errors or something import 'package:flutter/material.dart'; import 'dart:convert'; void main() => runApp(new MaterialApp( theme: new ThemeData( primarySwatch: Colors.blue, ), home: new HomePage(), )); class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State { List data; @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text( "Loading Json App using flutter", ), ), body: new Container( child: new Center( child: new FutureBuilder( future: DefaultAssetBundle.of(context) .loadString('loadjson/person.json'), builder: (context, snapshot) { //decode json var mydata = JsonDecoder().convert(snapshot.data.toString()); return new ListView.builder( itemBuilder: (BuildContext context, int index) { return new Card( child: new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ new Text("Name : " + mydata[index]['name']), new Text("Age : " + mydata[index]['age']), new Text("Height : " + mydata[index]['height']), new Text("Gender : " + mydata[index]['gender']), new Text("Hair Color : " + mydata[index]['hair_color']), ], ), ); }, itemCount: mydata == null ? 0 : mydata.length, ); }, ), ), ), ); } }
Make sure you are actually loading the asset in your pubspec , since yaml space sensitive if you dont maintain the exact spacing as in the vid you will not see data populate.
for new users who are working now a days JSON.decode will occur errors so to solve this... import 'dart:convert' show json; and then in place of var myData =.... type this >> var myData = json.decode(snapshot.data.toString()); >> This will work for you!! :)
the JSON.decode wasn't working for me, instead jsonDecode() method worked. no clues why.?
var mydata= jsonDecode(snapshot.data.toString());
you saved the day man
thanks
Thanks bro
You need to import Dart:convert, it should work fine then
Wow man, thanks very much, this has helped me.
which is better option to workout flutter vs code or anriod studio?
That was really helpful. Thanks a lot, vai. I've been a fan of you. Keep it up.
what about convert notes to json file
Hay friend there is an error inthis line can you correct this
var mydata = json.decode(snapshot.data.toString());
it's more like jsonDecode ()
@@Lokesh_Karki tq bro
@@Lokesh_Karki you the man. thanks!
You need to import dàrt: convert , it will work fine then
Dear sir How can we implement search in this local json file.. please please please make a video on this as well..
Merci ce tutoriel m'a beaucoup aidé a comprendre
the JSON.decode wasn't working for me, instead jsonDecode() method worked. no clues why.
thanks brother
It is the new version of writing the code
It doesn’t differ, just change if spelling
Thank u
Thanks
True
Hello, can you explain the 'BuildContext context' how it's looping with the list of elements in json and also the context and snapshot of FutureBuilder(builder:(context, snapshot){})
very nice, very helpful for beginners like me, keep making these kinds of videos, once again great work sir, keep it up :)
The following TypeErrorImpl was thrown building:
Expected a value of type 'String', but got one of type 'Null'
I am getting this error Please help!
What does DefaultAssetBundle actually do?
Can't understand form the docs
This video was really helpful for me ....thank you so much!!!!!!
In the updated flutter we have to use json.decode
and also can u mention plz is there any other approach rather than this one for decoding or deserialization of data from json file
Trying to create an horizontal scrollable listview with values gotten from json,,, It keeps giving the vertical.. Help!!!!!!!!!
This was really helpful thank you! Quick question though, is there anyway to write to the Json file within the assets file from the app?
Can you build a map page having text field in body which offers auto search location suggestion using directly google api. I am struggling to get such
Very helpful tutorial, i would like to ask if there is a way to delete an object from json file
Please give me the github link for this video or json application and also try to make video for arithemetic or mathematical operations
hi, i know this vid is a bit old, but after i have this set up how could i click on an item and send data to another screen?
My json data is not showing. I double checked my code with yours and restarted the app..
it shouldn't happen .. can u share it with me?
What's the best way to share?
Same problem
It is helpful video,but I have to ask how you auto save the code
if I want to build text and image json how can I call ?
Thanks for doing this tutorial 👍🏾
How to solve JSON.decode() error?
change JSON.decode() to json.decode() all letter small
thx dude your video is very helpfull, but how i put search filter bar on this app
Hi! I really like your video, but at the end of the video I can see that you have two filled in the lib directory, is it possible to have the entire content of both files in the PDF file or in your Github account, that will be very helpful.
Hiii.
I am using same code .
But json data is not being fetched .
Despite there is not a single error.
App is running on emulator.
But json data is not coming
use jsonDecode instead of JSON.decode
same here
@@Lokesh_Karki i did but result is same plz help me
not working properly Not Showing data.
json.decode(sanpshot.data.toString()); in this data is not working as List type variable ???
@pawan kumar
Same issue. If your issue got resolved,pls help me too:)
Is there any other way to decode json I've seen somewhere that json.decode(api_url); works
tnq, source code ?
can you make for this app refresh so when and new data come I make refresh to get it +++ can you make a notification system for this app so when any new data come the notification appear
Im a fan of ur channel, been looking bloc tutorial from ur channel, if u wont mind, i want to read data from an api using stream as well as send request to the api using the bloc logic, can u help with that
I'm trying to hit a java rest API which takes input values. Based on the values the records are fetched. Can you tell me how to pass a parameter through http request object??
Your videos are really helpful btw! Thanks a ton.
parameter as in ? you want to do post request ?
I was getting some errors after decoding the json file and then I figured it out..
Here's the code with maybe some changes, if anyone of u get stuck at some errors or something
import 'package:flutter/material.dart';
import 'dart:convert';
void main() => runApp(new MaterialApp(
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new HomePage(),
));
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State {
List data;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(
"Loading Json App using flutter",
),
),
body: new Container(
child: new Center(
child: new FutureBuilder(
future: DefaultAssetBundle.of(context)
.loadString('loadjson/person.json'),
builder: (context, snapshot) {
//decode json
var mydata = JsonDecoder().convert(snapshot.data.toString());
return new ListView.builder(
itemBuilder: (BuildContext context, int index) {
return new Card(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
new Text("Name : " + mydata[index]['name']),
new Text("Age : " + mydata[index]['age']),
new Text("Height : " + mydata[index]['height']),
new Text("Gender : " + mydata[index]['gender']),
new Text("Hair Color : " + mydata[index]['hair_color']),
],
),
);
},
itemCount: mydata == null ? 0 : mydata.length,
);
},
),
),
),
);
}
}
you the man! Been smashing my head over how to get the itemCount data. Thanks for being a great help!
It seems impossible for me to read the file, so any help please
formatException: unexcepted character (at character 1) is coming pls hellp
Invalid argument(s) error
hi..how to return 1 data only??? where id = 2
change index to 2 and itemCount true to 1 data only
Data is not showing :(
what the error ?
@@naufalhafizi1044 data showed after some times
thanks, do you know about socket error no 07 ?
Where is the source code?
How to render images from local json
What's the issue ? It will be the same assuming that you have stored some url for images?
Can you give a example like how to do
hey dude plzzz provide me the code or the repository link on github of above code asap!!
also make a tutorial for json.encode()
like how to serialized the data or saved or write the data to json file
bro plz show this code on your git and type 'String' is not a subtype of type 'int' i got this types of error
remove new Text("Age: " + mydata[index]['age']) and run it is because the output is an int but we have declare a string
Thanks but it would be helpful if you upload the source code too!
Great
Thank you very much
What is a JSON file?
JSON stands for JAVASCRIPT OBJECT NOTATION. You can google it more information
@@HelloCodepur Thankyou!!
How do we write/edit to the json file ?
(Not talking about app storage. -> flutter.io/cookbook/persistence/reading-writing-files/)
Project file plz !
Nice Video
Thanks for this
Says JSON is depreciated and shouldn't be used.
use json. lowercase
Thanks bro
20:13 Exactly my opinion XD
thats a weak json file .. use a complex json file having structure like having nested dictionaries. that would be more useful .
Bhai simulator pe error dika raha h....kya karu😈
Baki sab code sahi h
We know english ..but we want it hindi plz
We want Hindi
you talk a lot and your explanation is boring and not brief ,I am not a mocker but for you to be better
That's hard
bhai ..english why ..plz hindi
Right bro... English sabko ata hai..lekin we are indian hindi mai video banavo
not working properly Not Showing data.
json.decode(sanpshot.data.toString()); in this data is not working as List type variable ???
@pawan kumar
Make sure you are actually loading the asset in your pubspec , since yaml space sensitive if you dont maintain the exact spacing as in the vid you will not see data populate.