import 'dart:io'; import 'package:flutter/material.dart'; import 'package:rogapp/model/destination.dart'; import 'package:rogapp/utils/database_helper.dart'; class HistoryPage extends StatefulWidget { const HistoryPage({super.key}); @override State createState() => _HistoryPageState(); } class _HistoryPageState extends State { DatabaseHelper db = DatabaseHelper.instance; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("History"), ), body: SingleChildScrollView( child: Column( children: [ FutureBuilder( future: db.getDestinations(), builder: (BuildContext context, AsyncSnapshot> snapshot) { if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { return Center( child: Text( '${snapshot.error} occurred', style: TextStyle(fontSize: 18), ), ); } else if (snapshot.hasData) { final dests = snapshot.data; if (dests!.length > 0) { print("----- history -----"); return Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, child: ListView.builder( itemCount: dests.length, itemBuilder: (ctx, index) { print("--- photo ${dests[index].checkin_image!} ----"); return ListTile( title: Text(dests[index].name ?? ""), subtitle: Text("${dests[index].sub_loc_id} : ${dests[index].name}"), leading: dests[index].checkin_image != null ? Row( children: [ Container(width: 100, height: 100, child: Image.file(File(dests[index].checkin_image!))), Container(width: 100, height: 100, child: Image.file(File(dests[index].buypoint_image!))) ], ) : Container(), ); })); } else { return Center(child: Text("No checkin yet")); } } } else if (snapshot.connectionState == ConnectionState.waiting) { return Center( child: CircularProgressIndicator(), ); } return Container(); }), ], ), ), ); } }