1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-08-25 01:05:36 +00:00
Files
flutter-examples/covid19_mobile_app/lib/widgets/foldable_cell_widgets.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

146 lines
4.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:folding_cell/folding_cell.dart';
import 'package:number_display/number_display.dart';
// To display data in a width-limited component
// Eg: converts 2,000,000 to 2M
String updateNumberDisplay(String number) {
final display = createDisplay(length: 4);
// we are converting number to an integer because it is a string
// and display expects an integer
return display(int.parse(number));
}
// the front widget for the foldable cell(when cell is collapsed)
Widget buildFrontWidget(
BuildContext context, String flagUrl, String country, String cases) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
children: <Widget>[
Container(
child: Image.network(
flagUrl,
width: MediaQuery.of(context).size.width * 0.2,
fit: BoxFit.cover,
)),
SizedBox(
width: 20.0,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Country: $country",
),
Text("Total Cases: ${updateNumberDisplay(cases)}"),
],
),
),
],
),
);
}
// the inner top widget for the foldable cell(when cell is expanded)
Widget buildInnerTopWidget(String country, String todayCases, String deaths,
String todayDeaths, String recovered, String critical, String cpm) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
color: Color(0xfff44e3f),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
country,
style: TextStyle(fontSize: 20.0),
),
SizedBox(
height: 10.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Today Cases: ${updateNumberDisplay(todayCases)}",
style: TextStyle(fontSize: 18.0),
),
Text(
"Deaths: ${updateNumberDisplay(deaths)}",
style: TextStyle(fontSize: 18.0),
),
Text(
"Cases/Million: ${updateNumberDisplay(cpm)}",
style: TextStyle(fontSize: 18.0),
),
],
),
SizedBox(
width: 10.0,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Recovered: ${updateNumberDisplay(recovered)}",
style: TextStyle(fontSize: 18.0),
),
Text(
"Today Deaths: ${updateNumberDisplay(todayDeaths)}",
style: TextStyle(fontSize: 18.0),
),
Text(
"Critical: ${updateNumberDisplay(critical)}",
style: TextStyle(fontSize: 18.0),
),
],
),
],
),
],
),
);
}
// the inner bottom widget for the foldable cell(when cell is expanded)
Widget buildInnerBottomWidget(String cases) {
return Builder(builder: (context) {
return Container(
color: Color(0xfff44e3f),
padding: EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Expanded(
child: Text(
"Total Cases:\n${updateNumberDisplay(cases)}",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0,
),
)),
TextButton(
onPressed: () {
SimpleFoldingCellState? foldingCellState =
context.findAncestorStateOfType<SimpleFoldingCellState>();
foldingCellState?.toggleFold();
},
style: TextButton.styleFrom(
foregroundColor: Colors.black,
shape: StadiumBorder(),
overlayColor: Colors.white.withValues(alpha: 0.5),
),
child: Text(
"Close",
),
),
],
),
);
});
}