Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:http/http.dart' as http;
- import 'dart:async';
- import 'dart:convert';
- import '../modelHttp/datahasiluji/JsonAPIhasiluji.dart';
- class ListDataPage extends StatefulWidget {
- static String tag = 'listdatahasiluji-page';
- String ujianNomor;
- ListDataPage({this.ujianNomor});
- @override
- _ListDataPageState createState() => _ListDataPageState();
- }
- class _ListDataPageState extends State<ListDataPage> {
- Future<ListModel> getDataHasilUji() async {
- // print(widget.ujianNomor);
- final response = await http.get(
- "http://192.168.5.33:8080/project/getdata/datauji?no=${widget.ujianNomor}");
- // print(response.body);
- return ListModel.fromJson(json.decode(response.body));
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: new FutureBuilder<ListModel>(
- future: getDataHasilUji(),
- builder: (context, snapshot) {
- if (snapshot.hasError) print(snapshot.error);
- return snapshot.hasData
- ? new ItemList(
- list: snapshot.data,
- )
- : new Center(
- child: new CircularProgressIndicator(),
- );
- },
- ),
- );
- }
- }
- class ItemList extends StatelessWidget {
- final ListModel list;
- ItemList({this.list});
- @override
- Widget build(BuildContext context) {
- return Expanded(
- child: ListView.builder(
- padding: EdgeInsets.only(top: 20.0, bottom: 55.0),
- itemCount: list == null ? 0 : list.result.data.length,
- itemBuilder: (BuildContext context, int index) {
- return Stack(
- children: <Widget>[
- ListView(
- padding: EdgeInsets.only(left: 13.0, top: 40.0),
- children: <Widget>[
- Text(
- 'No. Uji',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 16,
- color: Colors.red),
- ),
- SizedBox(height: 6),
- Text(
- list.result.data[index].nouji,
- style: TextStyle(
- fontSize: 15.0, fontWeight: FontWeight.bold),
- ),
- SizedBox(height: 15),
- Text(
- 'Nama Pemilik',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 16,
- color: Colors.red),
- ),
- SizedBox(height: 6),
- Text(
- list.result.data[index].namapemilik,
- style: TextStyle(
- fontSize: 15.0, fontWeight: FontWeight.bold),
- ),
- ],
- )
- ],
- );
- }),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement