File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
lib/headlines-search/widgets Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ import 'package:flutter/material.dart' ;
2
+ import 'package:ht_shared/ht_shared.dart' ; // Import Country model
3
+
4
+ /// A simple widget to display a Country search result.
5
+ class CountryItemWidget extends StatelessWidget {
6
+ const CountryItemWidget ({required this .country, super .key});
7
+
8
+ final Country country;
9
+
10
+ @override
11
+ Widget build (BuildContext context) {
12
+ return ListTile (
13
+ leading: CircleAvatar (
14
+ backgroundImage: NetworkImage (country.flagUrl),
15
+ onBackgroundImageError: (exception, stackTrace) {
16
+ debugPrint ('Error loading country flag: $exception ' );
17
+ },
18
+ child: country.flagUrl.isEmpty
19
+ ? const Icon (Icons .public_off_outlined) // Placeholder if no flag
20
+ : null ,
21
+ ),
22
+ title: Text (country.name),
23
+ // TODO(you): Implement onTap navigation if needed for countries
24
+ onTap: () {
25
+ // Example: Navigate to a page showing headlines from this country
26
+ // context.goNamed('someCountryFeedRoute', params: {'isoCode': country.isoCode});
27
+ ScaffoldMessenger .of (context).showSnackBar (
28
+ SnackBar (content: Text ('Tapped on country: ${country .name }' )),
29
+ );
30
+ },
31
+ );
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments