Used Provider-Package to encapsulate state management
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../model/flood_station.dart';
|
||||
import '../pages/flood_station_page.dart';
|
||||
|
||||
class FloodStationListView extends StatelessWidget {
|
||||
const FloodStationListView({super.key, required List<FloodStation> stations})
|
||||
const FloodStationListView(
|
||||
{super.key,
|
||||
required List<FloodStation> stations,
|
||||
required this.onItemTapped})
|
||||
: _stations = stations;
|
||||
|
||||
final List<FloodStation> _stations;
|
||||
final void Function(FloodStation) onItemTapped;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -20,9 +23,7 @@ class FloodStationListView extends StatelessWidget {
|
||||
final item = _stations.elementAt(index);
|
||||
return ListTile(
|
||||
isThreeLine: true,
|
||||
onTap: () => Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => FloodStationPage(floodStation: item),
|
||||
)),
|
||||
onTap: () => onItemTapped(item),
|
||||
title: Text(item.label),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
Reference in New Issue
Block a user