connect with backend
This commit is contained in:
64
lib/screens/order_track_screen.dart
Normal file
64
lib/screens/order_track_screen.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../services/dio_client.dart';
|
||||
import '../services/order_service.dart';
|
||||
|
||||
|
||||
class OrderTrackScreen extends StatefulWidget {
|
||||
final String orderId;
|
||||
const OrderTrackScreen({super.key, required this.orderId});
|
||||
|
||||
@override
|
||||
State<OrderTrackScreen> createState() => _OrderTrackScreenState();
|
||||
}
|
||||
|
||||
class _OrderTrackScreenState extends State<OrderTrackScreen> {
|
||||
bool loading = true;
|
||||
Map data = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
load();
|
||||
}
|
||||
|
||||
Future<void> load() async {
|
||||
final service = OrderService(DioClient.getInstance(context));
|
||||
final res = await service.trackOrder(widget.orderId);
|
||||
|
||||
if (res['success'] == true) {
|
||||
data = res['track'];
|
||||
}
|
||||
|
||||
loading = false;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("Track Order")),
|
||||
body: loading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Order ID: ${data['order_id']}"),
|
||||
Text("Shipment Status: ${data['shipment_status']}"),
|
||||
Text("Shipment Date: ${data['shipment_date']}"),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: Icon(
|
||||
Icons.local_shipping,
|
||||
size: 100,
|
||||
color: Colors.indigo.shade300,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user