Complete the code to show a loading spinner while data is loading.
return Center(child: CircularProgressIndicator[1]);
The CircularProgressIndicator widget requires parentheses to be called as a constructor.
Complete the code to display an error message when loading fails.
return Center(child: Text('Error: $[1]'))
The variable errorMessage holds the error text to show to the user.
Fix the error in the code to show loading or error states correctly.
if (isLoading) { return CircularProgressIndicator[1]; } else if (hasError) { return Text(errorMessage); }
CircularProgressIndicator must be called with parentheses to create the widget instance.
Fill both blanks to show a loading spinner or an error message with a retry button.
if (isLoading) { return Center(child: CircularProgressIndicator[1]); } else if (hasError) { return Column( children: [ Text(errorMessage), ElevatedButton(onPressed: [2], child: Text('Retry')) ], ); }
The CircularProgressIndicator needs parentheses. The retry button's onPressed should call the retryLoadData function.
Fill all three blanks to create a widget that shows loading, error, or data states.
Widget buildContent() {
if ([1]) {
return Center(child: CircularProgressIndicator[2]);
} else if ([3]) {
return Text(errorMessage);
} else {
return Text(data);
}
}Use isLoading to check loading state, call CircularProgressIndicator with parentheses, and check hasError for errors.