fl_animated_linechart 0.0.7 fl_animated_linechart: ^0.0.7 copied to clipboard
Animated flutter linechart
import 'package:example/fake_chart_series.dart';
import 'package:fl_animated_linechart/fl_animated_linechart.dart';
import 'package:flutter/material.dart';
/**
* TODO: fix chart not starting at x: 0
*/
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
showPerformanceOverlay: true,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with FakeChartSeries {
@override
Widget build(BuildContext context) {
Map<DateTime, double> line1 = createLine2();
Map<DateTime, double> line2 = createLine2_2();
LineChart lineChart = LineChart.fromDateTimeMaps([line1, line2], [Colors.green, Colors.blue], ['C', 'F']);
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(width: 200, height: 200, child: Text('')),
Expanded(child: AnimatedLineChart(lineChart)),
SizedBox(width: 200, height: 200, child: Text('')),
]
),
),
);
}
}