sleep_stages_chart 1.0.0
sleep_stages_chart: ^1.0.0 copied to clipboard
A customizable Flutter chart widget visualizing sleep stages like Apple Health.
import 'package:flutter/material.dart';
import 'package:sleep_stages_chart/sleep_stages_chart.dart';
void main() => runApp(const ExampleApp());
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
final day = DateTime(2025, 1, 1);
final segs = <SleepSegment>[
SleepSegment(
start: DateTime(2025, 1, 1, 0, 0),
end: DateTime(2025, 1, 1, 1, 0),
stage: SleepStage.deep,
),
SleepSegment(
start: DateTime(2025, 1, 1, 1, 0),
end: DateTime(2025, 1, 1, 3, 0),
stage: SleepStage.light,
),
SleepSegment(
start: DateTime(2025, 1, 1, 3, 0),
end: DateTime(2025, 1, 1, 4, 0),
stage: SleepStage.rem,
),
SleepSegment(
start: DateTime(2025, 1, 1, 4, 0),
end: DateTime(2025, 1, 1, 4, 30),
stage: SleepStage.awake,
),
];
return MaterialApp(
title: 'Sleep Stages Chart Example',
home: Scaffold(
appBar: AppBar(title: const Text('Sleep Stages Chart Example')),
body: Padding(
padding: const EdgeInsets.all(16),
child: SleepStagesChart(day: day, segments: segs),
),
),
);
}
}