1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-08-24 16:50:47 +00:00
Files
flutter-examples/covid19_mobile_app/lib/screens/countrylist.dart
Nishant Srivastava 5c53498119 refactor: standardize Dart and Android config across all 54 apps
- Bump all apps to sdk >=3.0.0 <4.0.0 and add flutter_lints + a shared
  analysis_options.yaml to every app (flutter analyze is now green repo-wide)
- Fix real compile errors in firebase_google_authentication and image_editor,
  plus deprecated APIs (Matrix4, SvgPicture.color, textScaleFactor),
  missing async 'mounted' guards, and misc lints via dart fix + manual fixes
- Align pubspec 'name' with each folder and Android namespace/applicationId
  with the documented github.nisrulz.* convention
- Convert bmi_calculator from a legacy Flutter module to a standard app
  with a proper android/ scaffold; fix missing android:exported in launcher
  manifests across 22 apps so all Android builds pass
- Untrack generated build files (GeneratedPluginRegistrant,
  .flutter-plugins-dependencies) and ignore them
2026-08-17 17:26:39 +02:00

104 lines
3.7 KiB
Dart

import 'package:covid19_mobile_app/resources/fetch_data_functions.dart';
import 'package:covid19_mobile_app/widgets/foldable_cell_widgets.dart';
import '../screens/searchCountry.dart';
import '../widgets/drawer.dart';
import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:folding_cell/folding_cell.dart';
class CountryList extends StatelessWidget {
const CountryList({super.key});
@override
Widget build(BuildContext context) {
List<dynamic> results = [];
return Scaffold(
drawer: DrawerWidget(),
appBar: AppBar(
title: Text("Affected Countries"),
centerTitle: true,
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {
showSearch(
context: context,
delegate: CountrySearchDelegate(results),
);
},
),
],
),
body: FutureBuilder(
future: getAllCountriesData(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
}
if (snapshot.hasError) {
return Center(
child: Text("Error! please check you wifi connection"),
);
}
results = jsonDecode(snapshot.data);
return ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: results.length,
itemBuilder: (context, index) {
var foldingCellKey = GlobalKey<SimpleFoldingCellState>();
return Container(
color: Color(0xFF2e282a),
alignment: Alignment.topCenter,
child: SimpleFoldingCell.create(
key: foldingCellKey,
frontWidget: Builder(
builder: (BuildContext context) {
return GestureDetector(
onTap: () {
SimpleFoldingCellState? foldingCellState =
context.findAncestorStateOfType<
SimpleFoldingCellState>();
foldingCellState?.toggleFold();
},
child: Container(
color: Color(0xff000000),
child: buildFrontWidget(
context,
results[index]['countryInfo']['flag'],
results[index]['country'],
results[index]['cases'].toString())),
);
},
),
innerWidget: Column(
children: [
buildInnerTopWidget(
results[index]['country'],
results[index]['todayCases'].toString(),
results[index]['deaths'].toString(),
results[index]['todayDeaths'].toString(),
results[index]['recovered'].toString(),
results[index]['critical'].toString(),
results[index]['casesPerOneMillion'].toString(),
),
buildInnerBottomWidget(
results[index]['cases'].toString()),
],
),
cellSize: Size(MediaQuery.of(context).size.width, 125),
padding: EdgeInsets.all(15),
animationDuration: Duration(milliseconds: 300),
borderRadius: 10,
),
);
},
);
},
),
);
}
}