draw_graph 1.0.0 draw_graph: ^1.0.0 copied to clipboard
Do you want to display a graph in your app? This package can help. It has a widget that draws line graph for you.
import 'package:flutter/material.dart';
import 'package:draw_graph/draw_graph.dart';
import 'package:draw_graph/models/feature.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
home: Scaffold(
appBar: AppBar(
title: Text("DrawGraph Package"),
),
body: MyScreen(),
),
);
}
}
class MyScreen extends StatelessWidget {
final List<Feature> features = [
Feature(
title: "Drink Water",
color: Colors.blue,
data: [0.2, 0.8, 0.4, 0.7, 0.6],
),
Feature(
title: "Exercise",
color: Colors.pink,
data: [1, 0.8, 0.6, 0.7, 0.3],
),
Feature(
title: "Study",
color: Colors.cyan,
data: [0.5, 0.4, 0.85, 0.4, 0.7],
),
Feature(
title: "Water Plants",
color: Colors.green,
data: [0.6, 0.2, 0, 0.1, 1],
),
Feature(
title: "Grocery Shopping",
color: Colors.amber,
data: [0.25, 1, 0.3, 0.8, 0.6],
),
];
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 64.0),
child: Text(
"Tasks Track",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
letterSpacing: 2,
),
),
),
LineGraph(
features: features,
size: Size(320, 400),
labelX: ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'],
labelY: ['20%', '40%', '60%', '80%', '100%'],
showDescription: true,
graphColor: Colors.white30,
graphOpacity: 0.2,
verticalFeatureDirection: true,
descriptionHeight: 130,
),
SizedBox(
height: 50,
)
],
);
}
}