Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:http/http.dart' as http;
  3. import 'dart:async';
  4. import 'dart:convert';
  5. import '../modelHttp/datahasiluji/JsonAPIhasiluji.dart';
  6.  
  7. class ListDataPage extends StatefulWidget {
  8. static String tag = 'listdatahasiluji-page';
  9. String ujianNomor;
  10. ListDataPage({this.ujianNomor});
  11.  
  12. @override
  13. _ListDataPageState createState() => _ListDataPageState();
  14. }
  15.  
  16. class _ListDataPageState extends State<ListDataPage> {
  17. Future<ListModel> getDataHasilUji() async {
  18. // print(widget.ujianNomor);
  19. final response = await http.get(
  20. "http://192.168.5.33:8080/project/getdata/datauji?no=${widget.ujianNomor}");
  21.  
  22. // print(response.body);
  23. return ListModel.fromJson(json.decode(response.body));
  24. }
  25.  
  26. @override
  27. Widget build(BuildContext context) {
  28. return Scaffold(
  29. body: new FutureBuilder<ListModel>(
  30. future: getDataHasilUji(),
  31. builder: (context, snapshot) {
  32. if (snapshot.hasError) print(snapshot.error);
  33. return snapshot.hasData
  34. ? new ItemList(
  35. list: snapshot.data,
  36. )
  37. : new Center(
  38. child: new CircularProgressIndicator(),
  39. );
  40. },
  41. ),
  42. );
  43. }
  44. }
  45.  
  46. class ItemList extends StatelessWidget {
  47. final ListModel list;
  48. ItemList({this.list});
  49. @override
  50. Widget build(BuildContext context) {
  51. return Expanded(
  52. child: ListView.builder(
  53. padding: EdgeInsets.only(top: 20.0, bottom: 55.0),
  54. itemCount: list == null ? 0 : list.result.data.length,
  55. itemBuilder: (BuildContext context, int index) {
  56. return Stack(
  57. children: <Widget>[
  58. ListView(
  59. padding: EdgeInsets.only(left: 13.0, top: 40.0),
  60. children: <Widget>[
  61. Text(
  62. 'No. Uji',
  63. style: TextStyle(
  64. fontWeight: FontWeight.bold,
  65. fontSize: 16,
  66. color: Colors.red),
  67. ),
  68. SizedBox(height: 6),
  69. Text(
  70. list.result.data[index].nouji,
  71. style: TextStyle(
  72. fontSize: 15.0, fontWeight: FontWeight.bold),
  73. ),
  74. SizedBox(height: 15),
  75. Text(
  76. 'Nama Pemilik',
  77. style: TextStyle(
  78. fontWeight: FontWeight.bold,
  79. fontSize: 16,
  80. color: Colors.red),
  81. ),
  82. SizedBox(height: 6),
  83. Text(
  84. list.result.data[index].namapemilik,
  85. style: TextStyle(
  86. fontSize: 15.0, fontWeight: FontWeight.bold),
  87. ),
  88. ],
  89. )
  90. ],
  91. );
  92. }),
  93. );
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement