Update README.md

- Fix missing GlobalKey initializer
- Add dart syntax highlighting to code snippets
This commit is contained in:
Victor Choueiri 2018-02-22 22:09:28 +02:00 committed by GitHub
parent 9ac1f3c6cf
commit 5d6a913469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,19 +34,19 @@ __Note:__ This is a WIP early implementation, use at your own risk. You can inst
Import the package: Import the package:
``` ```dart
import 'package:flutter_circular_chart/flutter_circular_chart.dart'; import 'package:flutter_circular_chart/flutter_circular_chart.dart';
``` ```
Create a [GlobalKey](https://docs.flutter.io/flutter/widgets/GlobalKey-class.html) to be able to access the chart and update its data: Create a [GlobalKey](https://docs.flutter.io/flutter/widgets/GlobalKey-class.html) to be able to access the chart and update its data:
``` ```dart
final GlobalKey<AnimatedCircularChartState> _chartKey; final GlobalKey<AnimatedCircularChartState> _chartKey = new GlobalKey<AnimatedCircularChartState>();
``` ```
Create chart data entry objects: Create chart data entry objects:
``` ```dart
List<CircularStackEntry> data = <CircularStackEntry>[ List<CircularStackEntry> data = <CircularStackEntry>[
new CircularStackEntry( new CircularStackEntry(
<CircularSegmentEntry>[ <CircularSegmentEntry>[
@ -62,7 +62,7 @@ List<CircularStackEntry> data = <CircularStackEntry>[
Create an `AnimatedCircularChart`, passing it the `_chartKey` and initial `data`: Create an `AnimatedCircularChart`, passing it the `_chartKey` and initial `data`:
``` ```dart
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new AnimatedCircularChart( return new AnimatedCircularChart(
@ -76,7 +76,7 @@ Widget build(BuildContext context) {
Call `updateData` to animate the chart: Call `updateData` to animate the chart:
``` ```dart
void _cycleSamples() { void _cycleSamples() {
List<CircularStackEntry> nextData = <CircularStackEntry>[ List<CircularStackEntry> nextData = <CircularStackEntry>[
new CircularStackEntry( new CircularStackEntry(