Akbar Pulatov
Akbar Pulatov

Reputation: 3319

showDialog function is not passing parent context to its children in Flutter? is it conceived this way?

Does builder function creates new context here, and how to pass context then.

showDialog(context: context, builder: (context) => Center(
  child: Container(
  child: Text('some text'),),));

result:

enter image description here

Upvotes: 0

Views: 315

Answers (1)

Josteve Adekanbi
Josteve Adekanbi

Reputation: 12673

Wrap the Center in Dialog widget to get a white background.

Dialog(
 child: Center(...)
)

If you want to keep it transparent, wrap the Center in Material

Material(
 child: Center(...)
)

Upvotes: 1

Related Questions