Commit a548bc06 authored by khairullah zikri's avatar khairullah zikri
Browse files

Add json

parent 100152be
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/services.dart';
import 'dart:convert';
class Json extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: RaisedButton(
child: Text("simpan"),
onPressed: _prosesSimpan,
),
);
}
}
void _prosesSimpan() async {
final db = Firestore.instance;
String jsonString = await rootBundle.loadString('assets/pokedex.json');
List pokedex = json.decode(jsonString);
pokedex.forEach((pokemon){db.collection('pokedex').document(pokemon['id'].toString()).setData(pokemon);});
print('end proses data');
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment