推荐使用 useInheritedMediaQuery 为 false #485
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
关于使用 CupertinoPageRoute,在键盘弹出时多次 rebuild 的问题研究。
参见如下资料:
flutter/flutter#116090
flutter/flutter#116090 (comment)
If we did want to avoid rebuilding when MediaQuery changes. We can use MediaQueryData.fromWindow(window) to get value, and using didChangeMetrics to update value and call setState() when it is current page, which will not break current theory and will works fine too.
Set Scaffold's resizeToAvoidBottomInset to false when you don't need adjust viewInsets, because when resizeToAvoidBottomInset is true, the Scaffold will use MediaQuery.viewInsetsOf to subscribe the changes and rebuild when it changes. So set it to false when this page doesn't need to adjust viewInsets.
Using Builder to avoid rebuild all things in a page
通过以上实践,我自己的项目已经能做到