FutureBuilder<Schedule>(
future: widget.scheduleId == null
? null
: GetIt.I<LocalDatabase>().getScheduleById(widget.scheduleId!),
builder: (context, snapshot) {
// error
if(snapshot.hasError){
return Center(child: Text("Something went wrong"),);
}
// Future build ran for the first time and Loading
if(snapshot.connectionState != ConnectionState.none && !snapshot.hasData){
return Center(child: CircularProgressIndicator());
}
// When there's Future value but variables are never been set
if(snapshot.hasData && startTime == null){
startTime = snapshot.data!.startTime;
endTime = snapshot.data!.endTime;
content = snapshot.data!.content;
selectedColorId = snapshot.data!.colorId;
}
return Widget()
}
)
Dart
복사

.png&blockId=5dd09cd0-15bf-4c57-b598-68a7ecb5727d)
.png&blockId=5dd09cd0-15bf-4c57-b598-68a7ecb5727d&width=256)