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';
- ListDataPage({this.ujianNomor});
- String ujianNomor;
- @override
- _ListDataPageState createState() => _ListDataPageState();
- }
- class _ListDataPageState extends State<ListDataPage> {
- Future<ListModel> getDataHasilUji() async {
- final response = await http
- .get("http://192.168.5.33:8080/project/getdata/datauji?no=${widget.ujianNomor}");
- 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(),
- );
- },
- ),
- appBar: AppBar(
- leading: IconButton(
- icon: Icon(Icons.arrow_back_ios),
- onPressed: () {
- Navigator.of(context).pop();
- }),
- iconTheme: IconThemeData(
- color: Colors.white, //change your color here
- ),
- title: Text("Data Pemilik"),
- ),
- );
- }
- }
- class ItemList extends StatelessWidget {
- final ListModel list;
- ItemList({this.list});
- @override
- Widget build(BuildContext context) {
- return Material(
- child: ListView.builder(
- itemCount: list == null ? 0 : list.result.data.length,
- itemBuilder: (BuildContext context, int index) {
- return Scaffold(
- body: Stack(
- children: <Widget>[
- Container(
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage("assets/img/logo.png"),
- fit: BoxFit.fitWidth)),
- ),
- ListView(
- padding: EdgeInsets.only(left: 10.0, top: 10.0),
- children: <Widget>[
- Text(
- 'No.',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 16,
- color: Colors.red),
- ),
- SizedBox(height: 6),
- Text(
- list.result.data[index].noID,
- 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