"No MediaQuery widget ancestor found." Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "No MediaQuery widget ancestor found." answered properly. Developers are finding an appropriate answer about No MediaQuery widget ancestor found. related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like No MediaQuery widget ancestor found.. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on No MediaQuery widget ancestor found..
No MediaQuery widget ancestor found.
Its because, the showModalBottomSheet tries to access the ancestor of type
MaterialApp from the given context.
Use Builder widget to get new context with MaterialApp ancestor or Separate
your MaterialAapp and Scaffold widgets into separate widgets.
Using Builder :
floatingActionButton: Builder(
builder: (context) => FloatingActionButton(
child: Icon(Icons.add),
onPressed: () { showModalBottomSheet(
context: context,
builder: (context) {
return Text('Modal bottom sheet', style: TextStyle(fontSize: 30));
});
}
),
),
reference:
https://stackoverflow.com/questions/59864150/flutter-exception-caught-by-gesture-no-mediaquery-widget-found-inside-showmodal
All those coders who are working on the Whatever based application and are stuck on No MediaQuery widget ancestor found. can get a collection of related answers to their query. Programmers need to enter their query on No MediaQuery widget ancestor found. related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about No MediaQuery widget ancestor found. for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of No MediaQuery widget ancestor found. while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "No MediaQuery widget ancestor found.". Visit this developer's friendly online web community, CodeProZone, and get your queries like No MediaQuery widget ancestor found. resolved professionally and stay updated to the latest Whatever updates.