Skip to content

Instantly share code, notes, and snippets.

View xeladu's full-sized avatar

xeladu xeladu

View GitHub Profile
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master
@xeladu
xeladu / hover_test.dart
Created January 24, 2024 22:04
hover_test.dart
class HoverTest extends StatefulWidget {
const HoverTest({Key? key}) : super(key: key);
@override
State<HoverTest> createState() => _State();
}
class _State extends State<HoverTest> with SingleTickerProviderStateMixin {
late AnimationController controller;
late Animation<double> myAnimation;
@xeladu
xeladu / custom_class.dart
Last active January 11, 2024 21:07
custom_class.dart
class CustomClass {
final String id;
final int number;
CustomClass({required this.id, required this.number});
factory CustomClass.fromJson(Map<String, dynamic> json){
return CustomClass(
id: json.containsKey("id") ? json["id"] : "",
number: json.containsKey("number") ? json["number"] : 0
@xeladu
xeladu / line_chart_widget.dart
Last active December 20, 2023 23:53
line_chart_widget.dart
Widget _buildContent() {
return SizedBox(
height: widget.useLargeFonts ? 300 : 200,
child: LineChart(LineChartData(
// why 1? We scale all values to the interval from 0 (lowest values) to 1 (highest value).
// The axis descriptions and horizontal lines will be at 0, 0.25, 0.5, 0.75, and 1
maxY: 1,
gridData: gridData,
borderData: borderData,
titlesData: FlTitlesData(
@xeladu
xeladu / axis_values.dart
Created December 20, 2023 23:38
axis_values.dart
static List<double> getSalesAxisValues(double maxSalesValue) {
// find a good axis description range
// we either display 3 values or 5 depending on the maximum of the data
if (maxSalesValue < 10) {
return [0, 5, 10];
} else if (maxSalesValue < 20) {
return [0, 10, 20];
} else if (maxSalesValue < 50) {
return [0, 25, 50];
} else if (maxSalesValue < 100) {
@xeladu
xeladu / grid.dart
Created December 20, 2023 23:36
grid.dart
FlGridData get gridData => const FlGridData(
show: true, horizontalInterval: 0.25, verticalInterval: 1);
@xeladu
xeladu / tooltip.dart
Last active December 20, 2023 23:35
tooltip.dart
List<LineTooltipItem?> _buildTooltip(List<LineBarSpot> spots) {
// this is the position of the spot where the tooltip should appear
final index = spots.first.spotIndex;
// find the matching date description for the value
// we just create all axis titles again and grab the one at the correct index
final allDateStrings = ChartUtils.getMonths(widget.data.length);
final dateString = allDateStrings.isEmpty ? "" : allDateStrings[index];
return [
@xeladu
xeladu / axis_disabled.dart
Last active December 20, 2023 22:39
axis_disabled.dart
topTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false))
@xeladu
xeladu / sales_axis.dart
Created December 20, 2023 22:36
sales_axis.dart
AxisTitles get rightAxisTitles => AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 60,
interval: 0.25,
getTitlesWidget: (val, meta) => ...));
@xeladu
xeladu / date_axis.dart
Created December 20, 2023 22:16
date_axis.dart
AxisTitles get bottomAxisTitles => AxisTitles(
sideTitles: SideTitles(
showTitles: true,
interval: 1,
getTitlesWidget: (val, meta) => ...,
reservedSize: 42));