| 123456789101112131415161718192021222324252627282930313233 |
- import 'package:flutter/material.dart';
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import 'package:ristoris/providers/customer_provider.dart';
- class DestinationsTab extends ConsumerWidget {
- final int idCliente;
- final ThemeData theme;
- const DestinationsTab({required this.idCliente, required this.theme});
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- final destsAsync = ref.watch(customerDestinationsProvider(idCliente));
- return destsAsync.when(
- data: (dests) {
- if (dests.isEmpty) {
- return const Center(child: Text('Nessuna destinazione'));
- }
- return ListView.builder(
- itemCount: dests.length,
- itemBuilder: (_, i) => ListTile(
- leading: const Icon(Icons.location_on_outlined),
- title: Text(dests[i].descrizione ?? ''),
- subtitle: Text(
- '${dests[i].indirizzo ?? ""} ${dests[i].citta ?? ""}',
- ),
- ),
- );
- },
- loading: () => const Center(child: CircularProgressIndicator()),
- error: (e, _) => Center(child: Text('Errore: $e')),
- );
- }
- }
|