Skip to content

Commit

Permalink
Run dart fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaknezic committed Dec 10, 2024
1 parent a4d3ed1 commit e426cf4
Show file tree
Hide file tree
Showing 19 changed files with 457 additions and 183 deletions.
19 changes: 14 additions & 5 deletions charts_web/lib/ui/common/widget/double_option_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ class DoubleOptionInput extends HookWidget {
SizedBox(
width: 50,
child: TextField(
decoration: const InputDecoration(filled: true, isDense: true),
decoration:
const InputDecoration(filled: true, isDense: true),
controller: textEditingController,
onChanged: (value) {
final newValue = double.parse(value);
onChanged(newValue);
},
style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.bold),
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.bold),
),
)
else
Expand All @@ -61,7 +65,9 @@ class DoubleOptionInput extends HookWidget {
mini: true,
backgroundColor: Colors.grey,
onPressed: decrease,
child: const Text('-', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
child: const Text('-',
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
),
),
const SizedBox(width: 4),
Expand All @@ -73,7 +79,9 @@ class DoubleOptionInput extends HookWidget {
backgroundColor: Colors.grey,
mini: true,
onPressed: increase,
child: const Text('+', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
child: const Text('+',
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
),
),
],
Expand Down Expand Up @@ -104,5 +112,6 @@ class DoubleOptionInput extends HookWidget {
onChanged(value);
}

double roundTo(double value, double precision) => (value * precision).round() / precision;
double roundTo(double value, double precision) =>
(value * precision).round() / precision;
}
7 changes: 5 additions & 2 deletions charts_web/lib/ui/home/chart_options/chart_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ class ChartOptions extends HookConsumerWidget {
CupertinoButton.filled(
child: Row(
children: [
Opacity(opacity: 0.8, child: SvgPicture.asset(Assets.svg.showcase, width: 50)),
Opacity(
opacity: 0.8,
child: SvgPicture.asset(Assets.svg.showcase, width: 50)),
const SizedBox(width: 16),
const Text('Showcase'),
],
),
padding: const EdgeInsets.all(24),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (_) => ChartDemo()));
Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => ChartDemo()));
},
),
const SizedBox(height: 24),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import 'package:charts_web/assets.gen.dart';
import 'package:flutter/material.dart';

class FuturamaBarWidget extends StatelessWidget {
FuturamaBarWidget({Key? key, required this.stackItems, required this.listKey, required this.item}) : super(key: key);
FuturamaBarWidget(
{Key? key,
required this.stackItems,
required this.listKey,
required this.item})
: super(key: key);

final bool stackItems;
final int listKey;
Expand All @@ -22,18 +27,21 @@ class FuturamaBarWidget extends StatelessWidget {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 3.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.vertical(top: Radius.circular((!stackItems || listKey == 0) ? 12 : 0)),
borderRadius: BorderRadius.vertical(
top: Radius.circular((!stackItems || listKey == 0) ? 12 : 0)),
),
foregroundDecoration: BoxDecoration(
borderRadius: BorderRadius.vertical(top: Radius.circular((!stackItems || listKey == 0) ? 12 : 0)),
borderRadius: BorderRadius.vertical(
top: Radius.circular((!stackItems || listKey == 0) ? 12 : 0)),
color: Colors.accents[listKey].withOpacity(0.2),
border: Border.all(
width: 2,
color: Colors.accents[listKey],
),
),
child: ClipRRect(
borderRadius: BorderRadius.vertical(top: Radius.circular((!stackItems || listKey == 0) ? 12 : 0)),
borderRadius: BorderRadius.vertical(
top: Radius.circular((!stackItems || listKey == 0) ? 12 : 0)),
child: Stack(
children: [
Positioned.fill(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';

class OptionsComponentHeader extends StatelessWidget {
const OptionsComponentHeader({Key? key, required this.title, required this.subtitle}) : super(key: key);
const OptionsComponentHeader(
{Key? key, required this.title, required this.subtitle})
: super(key: key);

final String title;
final String subtitle;
Expand Down
47 changes: 33 additions & 14 deletions example/lib/charts/bar_chart_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ class _BarChartScreenState extends State<BarChartScreen> {
void _updateValues() {
final Random _rand = Random();
final double _difference = _rand.nextDouble() * 10;
targetMax = 5 + ((_rand.nextDouble() * _difference * 0.75) - (_difference * 0.25)).roundToDouble();
targetMax = 5 +
((_rand.nextDouble() * _difference * 0.75) - (_difference * 0.25))
.roundToDouble();
_values.addAll(List.generate(minItems, (index) {
return BarValue<void>(targetMax * 0.4 + _rand.nextDouble() * targetMax * 0.9);
return BarValue<void>(
targetMax * 0.4 + _rand.nextDouble() * targetMax * 0.9);
}));
targetMin = targetMax - ((_rand.nextDouble() * 3) + (targetMax * 0.2));
}
Expand All @@ -48,7 +51,8 @@ class _BarChartScreenState extends State<BarChartScreen> {
return _values[index];
}

return BarValue<void>(targetMax * 0.4 + Random().nextDouble() * targetMax * 0.9);
return BarValue<void>(
targetMax * 0.4 + Random().nextDouble() * targetMax * 0.9);
});
}

Expand Down Expand Up @@ -77,7 +81,9 @@ class _BarChartScreenState extends State<BarChartScreen> {
radius: const BorderRadius.vertical(
top: Radius.circular(24.0),
),
color: _colorfulBars ? colorForValue : Theme.of(context).colorScheme.primary,
color: _colorfulBars
? colorForValue
: Theme.of(context).colorScheme.primary,
);
},
),
Expand All @@ -86,18 +92,27 @@ class _BarChartScreenState extends State<BarChartScreen> {
showHorizontalValues: _showValues,
showVerticalValues: _showValues,
showTopHorizontalValue: _legendOnBottom ? _showValues : false,
horizontalLegendPosition:
_legendOnEnd ? HorizontalLegendPosition.end : HorizontalLegendPosition.start,
verticalLegendPosition: _legendOnBottom ? VerticalLegendPosition.bottom : VerticalLegendPosition.top,
horizontalLegendPosition: _legendOnEnd
? HorizontalLegendPosition.end
: HorizontalLegendPosition.start,
verticalLegendPosition: _legendOnBottom
? VerticalLegendPosition.bottom
: VerticalLegendPosition.top,
horizontalAxisStep: 1,
verticalAxisStep: 1,
verticalValuesPadding: const EdgeInsets.symmetric(vertical: 4.0),
horizontalValuesPadding: const EdgeInsets.symmetric(horizontal: 4.0),
verticalValuesPadding:
const EdgeInsets.symmetric(vertical: 4.0),
horizontalValuesPadding:
const EdgeInsets.symmetric(horizontal: 4.0),
textStyle: Theme.of(context).textTheme.labelMedium,
gridColor: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
gridColor: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.2),
),
TargetAreaDecoration(
targetAreaFillColor: Theme.of(context).colorScheme.error.withOpacity(0.2),
targetAreaFillColor:
Theme.of(context).colorScheme.error.withOpacity(0.2),
targetLineColor: Theme.of(context).colorScheme.error,
targetAreaRadius: BorderRadius.circular(12.0),
targetMax: targetMax,
Expand All @@ -108,13 +123,17 @@ class _BarChartScreenState extends State<BarChartScreen> {
foregroundDecorations: [
SparkLineDecoration(
lineWidth: 4.0,
lineColor: Theme.of(context).primaryColor.withOpacity(_showLine ? 1.0 : 0.0),
lineColor: Theme.of(context)
.primaryColor
.withOpacity(_showLine ? 1.0 : 0.0),
smoothPoints: _smoothPoints,
),
ValueDecoration(
alignment: Alignment.bottomCenter,
textStyle:
Theme.of(context).textTheme.labelMedium!.copyWith(color: Theme.of(context).colorScheme.onPrimary),
textStyle: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.onPrimary),
),
BorderDecoration(endWithChart: true)
],
Expand Down
36 changes: 27 additions & 9 deletions example/lib/charts/bar_target_chart_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ class _BarTargetChartScreenState extends State<BarTargetChartScreen> {
void _updateValues() {
final Random _rand = Random();
final double _difference = _rand.nextDouble() * 10;
targetMax = 5 + ((_rand.nextDouble() * _difference * 0.75) - (_difference * 0.25)).roundToDouble();
targetMax = 5 +
((_rand.nextDouble() * _difference * 0.75) - (_difference * 0.25))
.roundToDouble();
_values.addAll(List.generate(minItems, (index) {
return BarValue<void>(targetMax * 0.4 + _rand.nextDouble() * targetMax * 0.9);
return BarValue<void>(
targetMax * 0.4 + _rand.nextDouble() * targetMax * 0.9);
}));
targetMin = targetMax - ((_rand.nextDouble() * 3) + (targetMax * 0.2));
}
Expand All @@ -45,7 +48,8 @@ class _BarTargetChartScreenState extends State<BarTargetChartScreen> {
return _values[index];
}

return BarValue<void>(targetMax * 0.4 + Random().nextDouble() * targetMax * 0.9);
return BarValue<void>(
targetMax * 0.4 + Random().nextDouble() * targetMax * 0.9);
});
}

Expand Down Expand Up @@ -77,7 +81,8 @@ class _BarTargetChartScreenState extends State<BarTargetChartScreen> {
minBarWidth: 4.0,
barItemBuilder: (data) {
return BarItem(
color: _targetDecoration.getTargetItemColor(Theme.of(context).colorScheme.primary, data.item),
color: _targetDecoration.getTargetItemColor(
Theme.of(context).colorScheme.primary, data.item),
radius: const BorderRadius.vertical(
top: Radius.circular(24.0),
),
Expand All @@ -93,26 +98,39 @@ class _BarTargetChartScreenState extends State<BarTargetChartScreen> {
horizontalAxisStep: 1,
verticalAxisStep: 1,
textStyle: Theme.of(context).textTheme.labelMedium,
gridColor: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
gridColor: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.2),
),
_targetDecoration,
],
foregroundDecorations: [
SparkLineDecoration(
lineWidth: 4.0,
lineColor: Theme.of(context).primaryColor.withOpacity(_showLine ? 1.0 : 0.0),
lineColor: Theme.of(context)
.primaryColor
.withOpacity(_showLine ? 1.0 : 0.0),
smoothPoints: _smoothPoints,
),
TargetLineLegendDecoration(
legendDescription: 'Target line 👇',
legendTarget: targetMax,
legendStyle: Theme.of(context).textTheme.labelSmall!.copyWith(fontSize: 14),
legendStyle: Theme.of(context)
.textTheme
.labelSmall!
.copyWith(fontSize: 14),
padding: EdgeInsets.only(top: -8),
),
BorderDecoration(
endWithChart: true,
sidesWidth: Border.symmetric(vertical: BorderSide(width: 2.0), horizontal: BorderSide(width: 4.0)),
color: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.4),
sidesWidth: Border.symmetric(
vertical: BorderSide(width: 2.0),
horizontal: BorderSide(width: 4.0)),
color: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.4),
),
],
),
Expand Down
20 changes: 15 additions & 5 deletions example/lib/charts/bubble_chart_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class _BubbleChartScreenState extends State<BubbleChartScreen> {
targetMin: targetMin,
colorOverTarget: Theme.of(context).colorScheme.secondary,
targetLineColor: Theme.of(context).colorScheme.secondary,
targetAreaFillColor: Theme.of(context).colorScheme.secondary.withOpacity(0.2),
targetAreaFillColor:
Theme.of(context).colorScheme.secondary.withOpacity(0.2),
targetAreaRadius: BorderRadius.circular(8.0),
);

Expand All @@ -77,9 +78,12 @@ class _BubbleChartScreenState extends State<BubbleChartScreen> {
maxBarWidth: 60,
bubbleItemBuilder: (data) {
return BubbleItem(
color: tad.getTargetItemColor(Theme.of(context).colorScheme.primary, data.item));
color: tad.getTargetItemColor(
Theme.of(context).colorScheme.primary,
data.item));
},
padding: EdgeInsets.symmetric(horizontal: (1 - (_values.length / 17)) * 8.0),
padding: EdgeInsets.symmetric(
horizontal: (1 - (_values.length / 17)) * 8.0),
),
dataToValue: (BubbleValue value) => value.max ?? 0,
backgroundDecorations: [
Expand All @@ -91,8 +95,14 @@ class _BubbleChartScreenState extends State<BubbleChartScreen> {
verticalValuesPadding: EdgeInsets.only(left: 8.0),
verticalAxisStep: 4,
verticalTextAlign: TextAlign.start,
gridColor: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
textStyle: Theme.of(context).textTheme.labelMedium!.copyWith(fontSize: 13.0),
gridColor: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.2),
textStyle: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(fontSize: 13.0),
),
tad,
],
Expand Down
22 changes: 17 additions & 5 deletions example/lib/charts/candle_chart_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ class _CandleChartScreenState extends State<CandleChartScreen> {
child: CandleChart<CandleItem>(
data: _values,
height: MediaQuery.of(context).size.height * 0.4,
dataToValue: (CandleItem value) => CandleValue(value.min, value.max),
dataToValue: (CandleItem value) =>
CandleValue(value.min, value.max),
chartItemOptions: BarItemOptions(
minBarWidth: 4.0,
padding: EdgeInsets.symmetric(horizontal: 2.0),
barItemBuilder: (_) {
return BarItem(
color: Theme.of(context).colorScheme.primary.withOpacity(1.0),
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(1.0),
radius: BorderRadius.all(
Radius.circular(100.0),
),
Expand All @@ -100,8 +104,14 @@ class _CandleChartScreenState extends State<CandleChartScreen> {
verticalValuesPadding: EdgeInsets.only(left: 8.0),
horizontalAxisStep: 5,
verticalTextAlign: TextAlign.start,
gridColor: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
textStyle: Theme.of(context).textTheme.labelMedium!.copyWith(fontSize: 13.0),
gridColor: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.2),
textStyle: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(fontSize: 13.0),
),
],
foregroundDecorations: [
Expand All @@ -116,7 +126,9 @@ class _CandleChartScreenState extends State<CandleChartScreen> {
),
SelectedItemDecoration(
_selected,
backgroundColor: Theme.of(context).scaffoldBackgroundColor.withOpacity(0.5),
backgroundColor: Theme.of(context)
.scaffoldBackgroundColor
.withOpacity(0.5),
),
],
),
Expand Down
Loading

0 comments on commit e426cf4

Please sign in to comment.