Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a1b13863
Unverified
Commit
a1b13863
authored
Jul 20, 2023
by
Ian Hickson
Committed by
GitHub
Jul 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More documentation for MediaQuery and friends (#130509)
Fixes
https://github.com/flutter/flutter/issues/11697
parent
64edc55a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+10
-3
view.dart
packages/flutter/lib/src/widgets/view.dart
+11
-2
No files found.
packages/flutter/lib/src/widgets/media_query.dart
View file @
a1b13863
...
@@ -219,6 +219,10 @@ class MediaQueryData {
...
@@ -219,6 +219,10 @@ class MediaQueryData {
/// this method again when it changes to keep the constructed [MediaQueryData]
/// this method again when it changes to keep the constructed [MediaQueryData]
/// updated.
/// updated.
///
///
/// In general, [MediaQuery.of] is the appropriate way to obtain
/// [MediaQueryData] from a widget. This `fromView` constructor is primarily
/// for use in the implementation of the framework itself.
///
/// See also:
/// See also:
///
///
/// * [MediaQuery.fromView], which constructs [MediaQueryData] from a provided
/// * [MediaQuery.fromView], which constructs [MediaQueryData] from a provided
...
@@ -262,9 +266,12 @@ class MediaQueryData {
...
@@ -262,9 +266,12 @@ class MediaQueryData {
/// It is considered bad practice to cache and later use the size returned
/// It is considered bad practice to cache and later use the size returned
/// by `MediaQuery.of(context).size`. It will make the application non responsive
/// by `MediaQuery.of(context).size`. It will make the application non responsive
/// and might lead to unexpected behaviors.
/// and might lead to unexpected behaviors.
/// For instance, during startup, especially in release mode, the first returned
///
/// size might be (0,0). The size will be updated when the native platform
/// For instance, during startup, especially in release mode, the first
/// reports the actual resolution.
/// returned size might be (0,0). The size will be updated when the native
/// platform reports the actual resolution. Using [MediaQuery.of] will ensure
/// that when the size changes, any widgets depending on the size are
/// automatically rebuilt.
///
///
/// See the article on [Creating responsive and adaptive
/// See the article on [Creating responsive and adaptive
/// apps](https://docs.flutter.dev/development/ui/layout/adaptive-responsive)
/// apps](https://docs.flutter.dev/development/ui/layout/adaptive-responsive)
...
...
packages/flutter/lib/src/widgets/view.dart
View file @
a1b13863
...
@@ -21,6 +21,15 @@ import 'media_query.dart';
...
@@ -21,6 +21,15 @@ import 'media_query.dart';
/// The provided [child] is wrapped in a [MediaQuery] constructed from the given
/// The provided [child] is wrapped in a [MediaQuery] constructed from the given
/// [view].
/// [view].
///
///
/// For most use cases, using [MediaQuery.of] is a more appropriate way of
/// obtaining the information that a [FlutterView] exposes. For example, using
/// [MediaQuery] will expose the _logical_ device size ([MediaQueryData.size])
/// rather than the physical size ([FlutterView.physicalSize]). Similarly, while
/// [FlutterView.padding] conveys the information from the operating system, the
/// [MediaQueryData.padding] further adjusts this information to be aware of the
/// context of the widget; e.g. the [Scaffold] widget adjusts the values for its
/// various children.
///
/// Each [FlutterView] can be associated with at most one [View] widget in the
/// Each [FlutterView] can be associated with at most one [View] widget in the
/// widget tree. Two or more [View] widgets configured with the same
/// widget tree. Two or more [View] widgets configured with the same
/// [FlutterView] must never exist within the same widget tree at the same time.
/// [FlutterView] must never exist within the same widget tree at the same time.
...
@@ -93,7 +102,7 @@ class View extends StatelessWidget {
...
@@ -93,7 +102,7 @@ class View extends StatelessWidget {
/// The method creates a dependency on the `context`, which will be informed
/// The method creates a dependency on the `context`, which will be informed
/// when the identity of the [FlutterView] changes (i.e. the `context` is
/// when the identity of the [FlutterView] changes (i.e. the `context` is
/// moved to render into a different [FlutterView] then before). The context
/// moved to render into a different [FlutterView] then before). The context
/// will not be informed when the
properties
on the [FlutterView] itself
/// will not be informed when the
_properties_
on the [FlutterView] itself
/// change their values. To access the property values of a [FlutterView] it
/// change their values. To access the property values of a [FlutterView] it
/// is best practise to use [MediaQuery.maybeOf] instead, which will ensure
/// is best practise to use [MediaQuery.maybeOf] instead, which will ensure
/// that the `context` is informed when the view properties change.
/// that the `context` is informed when the view properties change.
...
@@ -113,7 +122,7 @@ class View extends StatelessWidget {
...
@@ -113,7 +122,7 @@ class View extends StatelessWidget {
/// The method creates a dependency on the `context`, which will be informed
/// The method creates a dependency on the `context`, which will be informed
/// when the identity of the [FlutterView] changes (i.e. the `context` is
/// when the identity of the [FlutterView] changes (i.e. the `context` is
/// moved to render into a different [FlutterView] then before). The context
/// moved to render into a different [FlutterView] then before). The context
/// will not be informed when the
properties
on the [FlutterView] itself
/// will not be informed when the
_properties_
on the [FlutterView] itself
/// change their values. To access the property values of a [FlutterView] it
/// change their values. To access the property values of a [FlutterView] it
/// is best practise to use [MediaQuery.of] instead, which will ensure that
/// is best practise to use [MediaQuery.of] instead, which will ensure that
/// the `context` is informed when the view properties change.
/// the `context` is informed when the view properties change.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment