Files
flutter_tank_web_app/lib/pages/gasstations_view.dart

57 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controller/gasstations_controller.dart';
class GasstationsPage extends GetView<GasstationsController> {
static const String namedRoute = '/gasstations-page';
const GasstationsPage({super.key});
@override
Widget build(BuildContext context) {
var staCtrl = controller;
return Scaffold(
appBar: AppBar(
toolbarHeight: 100,
backgroundColor: Colors.blueGrey,
foregroundColor: Colors.white,
title: const Text('Gas Stations'),
),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.blueGrey[800]!,
Colors.blueGrey[600]!,
Colors.blueGrey[300]!,
Colors.blue[100]!,
],
),
),
child: Center(
child: Obx(() {
if (staCtrl.isLoading.value) {
return const CircularProgressIndicator();
} else if (staCtrl.eControlData.isEmpty) {
return const Text('No gas stations found.');
} else {
return ListView.builder(
itemCount: staCtrl.eControlData.length,
itemBuilder: (context, index) {
final station = staCtrl.eControlData[index];
return ListTile(
title: Text(station.name ?? 'Unknown Station'),
subtitle: Text(station.location?.address ?? 'No address'),
trailing: Text(station.open == true ? 'Open' : 'Closed'),
);
},
);
}
}),
),
),
);
}
}