SHARE
TWEET

TicketDart

Zaboy May 19th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'dart:convert';
  2.  
  3. import 'package:flutter/material.dart';
  4. import 'package:ticket_new/modal/ticketModel.dart';
  5. import 'package:http/http.dart' as http;
  6. class Report extends StatefulWidget {
  7.   @override
  8.   _ReportState createState() => _ReportState();
  9. }
  10.  
  11. class _ReportState extends State<Report> {
  12.  
  13.   List<TicketModel> _list = [];
  14.   var loading = false;
  15.   Future<Null> _fetchData() async{
  16.     setState(() {
  17.       loading = true;
  18.     });
  19.     final response = await http.post("http://192.168.43.253/edc/api/index.php", body: {
  20.       'key' : '5fpqRt23yU2kgJcl7fDo6ARIzsU5zIGAOIYtNPDBNokQcRViNfKnbaSiNow61lXG',
  21.       'method' : 'get',
  22.       'resource' : 'tickets',
  23.     });
  24.     if (response.statusCode == 200) {
  25.         final data = jsonDecode(response.body);
  26.         setState(() {
  27.           for (Map i in data) {
  28.           _list.add(TicketModel.fromJson(i));
  29.           }
  30.           loading = false;
  31.         });
  32.     } else {
  33.     }
  34.   }
  35.  
  36.   @override
  37.   void initState() {
  38.     // TODO: implement initState
  39.     super.initState();
  40.     _fetchData();
  41.   }
  42.  
  43.   @override
  44.   Widget build(BuildContext context) {
  45.     return Scaffold(
  46.      
  47.       body: Container(
  48.         child: loading
  49.         ? Center(child: CircularProgressIndicator())
  50.         : ListView.builder(
  51.           itemCount: _list.length,
  52.           itemBuilder: (context, i){
  53.             final x = _list[i];
  54.             return Container(
  55.               padding: EdgeInsets.all(10.0),
  56.               child: Column(
  57.                 crossAxisAlignment: CrossAxisAlignment.start,
  58.                 children: <Widget>[
  59.                   Text(x.result.email),
  60.                  
  61.                   Text(x.result.subject),
  62.                 ],
  63.               ),
  64.               );
  65.           },
  66.         ),
  67.       ),
  68.     );
  69.   }
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top