Search

Update Widget

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
복사