Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 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.  
  10. ListDataPage({this.ujianNomor});
  11.  
  12. String ujianNomor;
  13. @override
  14. _ListDataPageState createState() => _ListDataPageState();
  15. }
  16.  
  17. class _ListDataPageState extends State<ListDataPage> {
  18.  
  19.  
  20. Future<ListModel> getDataHasilUji() async {
  21. final response = await http
  22. .get("http://192.168.5.33:8080/project/getdata/datauji?no=${widget.ujianNomor}");
  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. appBar: AppBar(
  43. leading: IconButton(
  44. icon: Icon(Icons.arrow_back_ios),
  45. onPressed: () {
  46. Navigator.of(context).pop();
  47. }),
  48. iconTheme: IconThemeData(
  49. color: Colors.white, //change your color here
  50. ),
  51. title: Text("Data Pemilik"),
  52. ),
  53. );
  54. }
  55. }
  56.  
  57. class ItemList extends StatelessWidget {
  58. final ListModel list;
  59. ItemList({this.list});
  60.  
  61. @override
  62. Widget build(BuildContext context) {
  63. return Material(
  64. child: ListView.builder(
  65. itemCount: list == null ? 0 : list.result.data.length,
  66. itemBuilder: (BuildContext context, int index) {
  67. return Scaffold(
  68. body: Stack(
  69. children: <Widget>[
  70. Container(
  71. decoration: BoxDecoration(
  72. image: DecorationImage(
  73. image: AssetImage("assets/img/logo.png"),
  74. fit: BoxFit.fitWidth)),
  75. ),
  76. ListView(
  77. padding: EdgeInsets.only(left: 10.0, top: 10.0),
  78. children: <Widget>[
  79. Text(
  80. 'No.',
  81. style: TextStyle(
  82. fontWeight: FontWeight.bold,
  83. fontSize: 16,
  84. color: Colors.red),
  85. ),
  86. SizedBox(height: 6),
  87. Text(
  88. list.result.data[index].noID,
  89. style: TextStyle(
  90. fontSize: 15.0, fontWeight: FontWeight.bold),
  91. ),
  92. SizedBox(height: 15),
  93. Text(
  94. 'Nama Pemilik',
  95. style: TextStyle(
  96. fontWeight: FontWeight.bold,
  97. fontSize: 16,
  98. color: Colors.red),
  99. ),
  100. SizedBox(height: 6),
  101. Text(
  102. list.result.data[index].namaPemilik,
  103. style: TextStyle(
  104. fontSize: 15.0, fontWeight: FontWeight.bold),
  105. ),
  106. ],
  107. )
  108. ],
  109. ),
  110. );
  111. }),
  112. );
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement