Advertisement
Guest User

coba_lagi_json_get

a guest
Oct 21st, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.67 KB | None | 0 0
  1. import 'package:dropdown/main.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/rendering.dart';
  4. import 'package:flutter/services.dart';
  5. import 'package:http/http.dart' as http;
  6. import 'dart:async';
  7. import 'dart:convert';
  8.  
  9. class Lihat extends StatefulWidget {
  10.   @override
  11.   _LihatState createState() => _LihatState();
  12. }
  13.  
  14. class _LihatState extends State<Lihat> {
  15.  
  16.  
  17.     var data;
  18.  
  19.  
  20.   TextEditingController controllerCari = new TextEditingController();
  21.  
  22.   Future cariData(){
  23. final response = http.get('https://rsudenisa736.000webhostapp.com/json_get.php?norm='+controllerCari.text);
  24.  
  25. return response;
  26.      
  27.      
  28.      }
  29.    
  30.  
  31.   @override
  32.   Widget build(BuildContext context) {
  33.     return Scaffold(
  34.       appBar: new AppBar(
  35.         title: new Text("Lihat Data"),
  36.       ),
  37.       body: new Container(
  38.        
  39.        
  40.           child : new Column(
  41.         children: <Widget>[
  42.    
  43.            new TextField(
  44.                controller: controllerCari,
  45.                decoration: new InputDecoration(
  46.                  hintText: "Cari Data"
  47.                ),
  48.  
  49.              ),
  50.  
  51.               new RaisedButton(
  52.                 onPressed: ()
  53.                 async{
  54.                   final response = await cariData();
  55.                   setState(() {
  56.                    data = response;
  57.                   });
  58.                 },
  59.                 child: const Text("Cari DATA"),
  60.                 textColor: Colors.blue,
  61.               ), data == null ? Container() : Container(
  62.                 child: Text(data[0]["id_pasien"]),
  63.               ),
  64.  
  65.              
  66.               ],
  67.  
  68.  
  69.              
  70.       ),
  71.       ),
  72.     );
  73.   }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement