flutter_timetable/lib/src/timetable.dart

57 lines
1.2 KiB
Dart
Raw Normal View History

2022-08-24 09:39:36 +02:00
part of timetable;
class Timetable extends StatefulWidget {
2022-08-24 11:01:50 +02:00
const Timetable({
this.scrollController,
this.startHour = 0,
this.endHour = 24,
Key? key,
}) : super(key: key);
/// Hour at which the timetable starts.
final int startHour;
/// Hour at which the timetable ends.
final int endHour;
/// The scroll controller to control the scrolling of the timetable.
final ScrollController? scrollController;
2022-08-24 09:39:36 +02:00
@override
State<Timetable> createState() => _TimetableState();
}
class _TimetableState extends State<Timetable> {
2022-08-24 11:01:50 +02:00
late ScrollController _scrollController;
@override
void initState() {
super.initState();
_scrollController = widget.scrollController ?? ScrollController();
}
@override
void dispose() {
if (widget.scrollController == null) {
_scrollController.dispose();
}
super.dispose();
}
2022-08-24 09:39:36 +02:00
@override
Widget build(BuildContext context) {
2022-08-24 11:01:50 +02:00
return SingleChildScrollView(
physics: const BouncingScrollPhysics(),
controller: _scrollController,
child: Stack(
children: [
Table(
startHour: widget.startHour,
endHour: widget.endHour,
),
],
),
);
2022-08-24 09:39:36 +02:00
}
}