flutter_simple_candlesticks 1.0.1 copy "flutter_simple_candlesticks: ^1.0.1" to clipboard
flutter_simple_candlesticks: ^1.0.1 copied to clipboard

outdated

An elegant Flutter candlesticks chart

example/lib/main.dart

import 'package:example/data.dart';
import 'package:flutter/material.dart';
import 'package:flutter_simple_candlesticks/flutter_simple_candlesticks.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter candlestick',
      theme: ThemeData(
          scaffoldBackgroundColor: const Color(0xFF0b112e),
          appBarTheme: const AppBarTheme(backgroundColor: Color(0xFF0b112e), elevation: 0)),
      home: const MyHomePage(title: 'Flutter candlestick'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    const style = CandlestickChartStyle(
        yLegendStyle: CandlestickChartYLegendStyle(
            textStyle: TextStyle(color: Colors.white),
            numberOfLabels: 5,
            lineStyle: CandlestickChartLineStyle(width: 1, color: Colors.white)),
        candlestickStyle: CandlestickStyle(bullishColor: Color(0xFF38bbbf), bearishColor: Color(0xFFed7b9e)),
        candlestickSelectedStyle: CandlestickStyle(bullishColor: Color(0xff25787b), bearishColor: Color(0xff9d4963)));

    const style2 = CandlestickChartStyle(
        yLegendStyle: CandlestickChartYLegendStyle(
            textStyle: TextStyle(color: Colors.white),
            numberOfLabels: 5,
            lineStyle: CandlestickChartDashedLineStyle(width: 1, color: Colors.white)),
        candlestickStyle: CandlestickStyle(bullishColor: Color(0xFF38bbbf), bearishColor: Color(0xFFed7b9e)),
        candlestickSelectedStyle: CandlestickStyle(bullishColor: Color(0xff25787b), bearishColor: Color(0xff9d4963)));

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              CandlesticksChart<CandleModel>(
                height: 200,
                data: data,
                style: style,
                options: const CandlestickChartOptions(isScrollable: true),
                getHightCallback: (e) => e.hight,
                getCloseCallback: (e) => e.close,
                getLowCallback: (e) => e.low,
                getOpenCallback: (e) => e.open,
                getTimeCallback: (e) => e.date,
              ),
              CandlesticksChart<CandleModel>(
                height: 200,
                data: data,
                style: style2,
                getHightCallback: (e) => e.hight,
                getCloseCallback: (e) => e.close,
                getLowCallback: (e) => e.low,
                getOpenCallback: (e) => e.open,
                getTimeCallback: (e) => e.date,
              )
            ],
          ),
        ),
      ),
    );
  }
}
6
likes
80
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

An elegant Flutter candlesticks chart

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on flutter_simple_candlesticks