I have this method which needed a context so I’m passing it as a parameter.
Future<void> myPopup(BuildContext context) {
return Dialogs.materialDialog(
context: context,
...
);
}
I tried to wrap the whole Dialogs.materialDialog with Builder in order for me not to pass the context anymore but I’m unable to do it.
Builder(
builder: (BuildContext context) {
return Dialogs.materialDialog(
context: context,
...
);
},
How can I achieve the same output using the Builder?
2
Answers
You don’t need to wrap your method in a Builder to be able to give it the context. The context can be used from the build method.
Also @rahul has a point with the method not being assignable to the child widget as the return type is different than what is expected.
not to pass the context, I think you are looking for
LookupBoundary
but currently it is on master-api.On your case it will be