mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 13:13:44 +02:00
fix: don't use initState when the variable can be instatiated through the class definition instead
This commit is contained in:
parent
f5962acf7a
commit
1d65ac5096
1 changed files with 10 additions and 18 deletions
|
@ -49,28 +49,20 @@ class AvailabilitiesModificationScreen extends StatefulWidget {
|
||||||
|
|
||||||
class _AvailabilitiesModificationScreenState
|
class _AvailabilitiesModificationScreenState
|
||||||
extends State<AvailabilitiesModificationScreen> {
|
extends State<AvailabilitiesModificationScreen> {
|
||||||
late AvailabilityModel _availability;
|
late AvailabilityModel _availability =
|
||||||
late List<AvailabilityTemplateModel> _selectedTemplates;
|
widget.initialAvailabilities.getAvailabilities().firstOrNull ??
|
||||||
|
AvailabilityModel(
|
||||||
|
userId: "",
|
||||||
|
startDate: widget.dateRange.start,
|
||||||
|
endDate: widget.dateRange.end,
|
||||||
|
breaks: [],
|
||||||
|
);
|
||||||
|
late List<AvailabilityTemplateModel> _selectedTemplates =
|
||||||
|
widget.initialAvailabilities.getUniqueTemplates();
|
||||||
bool _clearAvailability = false;
|
bool _clearAvailability = false;
|
||||||
TimeOfDay? _startTime;
|
TimeOfDay? _startTime;
|
||||||
TimeOfDay? _endTime;
|
TimeOfDay? _endTime;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
// TODO(Joey): These can be immediately assigned to the properties
|
|
||||||
// This removes the need for an initState
|
|
||||||
_availability =
|
|
||||||
widget.initialAvailabilities.getAvailabilities().firstOrNull ??
|
|
||||||
AvailabilityModel(
|
|
||||||
userId: "",
|
|
||||||
startDate: widget.dateRange.start,
|
|
||||||
endDate: widget.dateRange.end,
|
|
||||||
breaks: [],
|
|
||||||
);
|
|
||||||
_selectedTemplates = widget.initialAvailabilities.getUniqueTemplates();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var availabilityScope = AvailabilityScope.of(context);
|
var availabilityScope = AvailabilityScope.of(context);
|
||||||
|
|
Loading…
Reference in a new issue