I am creating a full screen loader where i want to set default circularprogressindicator if user dont pass any widget to this function..
but its showing error
whats my mistake
static void showFullScreenDialog({Widget widget=Text('hello')//showing an error} ){
showDialog(
context: Get.overlayContext!,
barrierDismissible: false,
builder: (_) => PopScope(
canPop: false,
child: Container(
height: double.infinity,
width: double.infinity,
color: Colors.transparent,
child: Center(child: widget,),
)),
);
}
2
Answers
You haven’t shared the error message, but I can guess the source of the problem. When creating a widget as a default value in function parameters, this widget needs to be created at build time. However,
Text('hello')
is created at runtime.call this function as below