1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-04-03 22:32:01 +00:00

Added covid-19 example app and Updated the readme (#73)

This commit is contained in:
Mohammed Mehdi
2021-07-26 00:26:58 +05:30
committed by GitHub
parent 48f14caf15
commit 3eaedb619c
72 changed files with 2166 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';
import 'package:bezier_chart/bezier_chart.dart';
// Widget that will build the graph
Widget buildGraph(
BuildContext context, List<Map<String, dynamic>> datesAndValues) {
// Data is avalaible from a particular date and we are getting that here
final fromDate = datesAndValues[0]['date'];
// Data is avalaible until a particular date and we are getting that here
final toDate = datesAndValues.last['date'];
// Add dates and values corresponding to those dates
// in a list
List<DataPoint<DateTime>> dataPoints = [];
for (final dateAndValue in datesAndValues) {
dataPoints.add(DataPoint<DateTime>(
value: double.parse(dateAndValue['value'].toString()),
xAxis: dateAndValue['date']));
}
return Center(
child: Container(
decoration: BoxDecoration(
color: Colors.red,
),
height: MediaQuery.of(context).size.height / 2,
width: MediaQuery.of(context).size.width,
child: BezierChart(
fromDate: fromDate,
bezierChartScale: BezierChartScale.WEEKLY,
toDate: toDate,
selectedDate: toDate,
series: [
BezierLine(
data: dataPoints,
),
],
config: BezierChartConfig(
physics: BouncingScrollPhysics(),
verticalIndicatorStrokeWidth: 3.0,
verticalIndicatorColor: Colors.black26,
showVerticalIndicator: true,
verticalIndicatorFixedPosition: false,
backgroundColor: Colors.transparent,
footerHeight: 30.0,
),
),
),
);
}