Created
December 15, 2020 16:03
-
-
Save malibayram/c49007f5b2cce95b1973be1744d2de4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'package:flutter/material.dart'; | |
main() => runApp(MaterialApp(home: LocalJsonKonusu())); | |
class LocalJsonKonusu extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() => LocaleState(); | |
} | |
class LocaleState extends State<LocalJsonKonusu> { | |
List ogrenci; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Local Json Konusu"), | |
), | |
body: Container( | |
padding: EdgeInsets.all(20.0), | |
child: Center( | |
child: FutureBuilder( | |
future: DefaultAssetBundle.of(context) | |
.loadString("assets/veriler/sinif.json"), | |
builder: (context, cevap) { | |
ogrenci = jsonDecode(cevap.data | |
.toString()); | |
return ListView.builder( | |
itemBuilder: (BuildContext context, int index) { | |
return Card( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: <Widget>[ | |
Text("Adı: " + ogrenci[index]['adi']), | |
Text("Soyadı: " + ogrenci[index]['soyadi']), | |
Text("Cinsiyet: " + ogrenci[index]['cinsiyet']), | |
], | |
), | |
); | |
}, | |
itemCount: ogrenci == null | |
? 0 | |
: ogrenci | |
.length, | |
); | |
}, | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment