chart_range_selector 0.0.1
chart_range_selector: ^0.0.1 copied to clipboard
A package for range selector.
example/main.dart
import 'package:chart_range_selector/chart_range_selector.dart';
import 'package:flutter/material.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 Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home:HomePage() ,
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
double _start = 0.4;
double _end = 0.6;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("start: ${_start.toStringAsFixed(2)}, end: ${_end.toStringAsFixed(2)}",style: TextStyle(fontSize: 18),),
const SizedBox(height: 20,),
SizedBox(
width: 350,
child: ChartRangeSelector(
height: 30,
initStart: 0.4,
initEnd: 0.6,
onChartRangeChange: _onChartRangeChange,
),
),
],
),
),
);
}
void _onChartRangeChange(double start, double end) {
_start = start;
_end = end;
setState((){});
print("start:$start, end:$end");
}
}