In my chat app every message depends on MediaQuery (font scaling). When keyboard is appear on Android 11+ then bottom insets in MediaQuery are animated from 0 to keyboard height. It cause unwanted rebuilds of all messages, but they depends only from font scaling. With Provider library I can use method select for this case. How to achieve same result with MediaQuery?
How to achieve Provider.select behaviour using built in InheritedWidget like MediaQuery?
114 Views Asked by Nickolay Savchenko At
1
There are 1 best solutions below
Related Questions in PERFORMANCE
- Upsert huge amount of data by EFCore.BulkExtensions
- How can I resolve this error and work smoothly in deep learning?
- Efficiently processing many small elements of a collection concurrently in Java
- Theme Preloader for speed optimization in WordPress
- I need help to understand the time wich my simple ''hello world'' is taking to execute
- Non-blocking state update
- Do conditional checks cause bottlenecks in Javascript?
- Performance of sketch drastically decreases outside of the P5 Web Editor
- sample query for review for improvement on big query
- Is there an indexing strategy in Postgres which will operate effectively for JOINs with ORs
- Performance difference between two JavaScript code snippets for comparing arrays of strings
- C++ : Is there an objective universal way to compare the speed of iterative algorithms?
- How to configure api http request with load testing
- the difference in terms of performance two types of update in opensearch
- Sveltekit : really long to send the first page and intense CPU computation
Related Questions in FLUTTER
- Flutter + Dart: Editing name of a tab shows up a black screen
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- Way to get CustomPainter to track face in Camera Flutter MLKit
- flutter Null check error: did not show file and line number
- Creating multiple instances of a class with different initializing values in Flutter
- I want to paste stickers into to my TextField and to show the stickers beside the emojis
- Flutter plugin development android src not opening after opening example
- Module not found when building flutter app for IOS
- How to make barrier area interactive in flutter modal bottom sheet
- Can an RPC result be included in a Supabase select function in Flutter for Data Modeling?
- Why do I need to wait to reaccess to Firestore database even though it has already done before?
- Flutter web app on Windows -how to support mouse drag for horizontal and vertical scrolling as well as using mouse wheel
- I wrote this time displaying FLUTTER app, How can I improve it?
- Appwrite and / or Spring Boot Backend
- Flutter two_dimensional_scrollables Web app Chrome - cannot get horizontal scroll to work?
Related Questions in INHERITED-WIDGET
- What's the purpose of a ChangeNotifierProvider?
- Don't understand InheritedWidget
- When to use InheritedWidget, and when not to
- Does the InheritedWidget's updateShouldNotify need to exist?
- Parent widget rebuilding will not cause sub-widgets rubuild?
- Widget will not rebuild when listening to the value of Flutter Provider exposed
- Streamprovider i am getting this issue "The following ProviderNotFoundException was thrown building ConsumerStreamData
- Multiple widgets use the same global key , A globalkey can only be specified on one widget at a time in the widget tree
- Default Inherited Widget in Flutter
- How do I access my inherited widget in a dart file that doesn't build a widget in the tree?
- Does Inherited Widget changes rebuild whole application when it's the parrent of MaterialApp?
- flutter dependOnInheritedWidgetOfExactType() returns null
- Trying to make http call via VxMutation & VxState in Flutter
- Add AppBar actions from Scaffold children such as from Fragment.onCreateOptionsMenu in Android (using InheritedWidget)
- Passing data from one widget to another in the same tree
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Since there is no code provided in the question, I'll try to help based on the question description. I see multiple potential issues here.
viewInsetsanimation ofMediaQueryis probably not what's causing the rebuild.One might think the dependence on MediaQuery's
textScaleFactoris the cause of rebuilds wheneverMediaQuerychanges, but I'm willing to bet that, even if you remove the dependency and just simply return an emptyContainer, it would still rebuild during the keyboard collapse animation.For example, the total height of a
Scaffoldwould actually shrink, when a keyboard is visible. If you don't want this, you can setresizeToAvoidBottomInsetfor it, like so:If you really want to only get the text scale factor of MediaQuery, you can access it from much earlier in the widget tree, and save it as a variable, and pass it down however you like (provider, etc):
viewInsetsfromMediaQueryif you really want to.If you want to remove
viewInsets(or set it to a fixed value), you can override it by inserting anotherMediaQueryon the tree:Lastly, Flutter widgets should be prepared to be rebuilt at any time and shouldn't cause any issues. So I assume you are only noticing your widgets being rebuilt because Flutter Inspector, or you added a
printin the build method, and noticed a bunch of prints in the console. I wouldn't worry too much about it unless you are actually experiencing REAL performance issues. However, if your widgets don't behave properly when rebuilt at "unexpected times", you should fix that, because Flutter WILL rebuild your widgets all the time, not just when the keyboard is collapsed :D