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
4d73cf5c
Commit
4d73cf5c
authored
Jan 21, 2016
by
kgiesing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add device pixel ratio to MediaQuery
parent
72931955
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
11 deletions
+16
-11
material_app.dart
packages/flutter/lib/src/material/material_app.dart
+8
-8
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+2
-2
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+6
-1
No files found.
packages/flutter/lib/src/material/material_app.dart
View file @
4d73cf5c
...
...
@@ -77,15 +77,11 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
GlobalObjectKey
_navigator
;
Size
_size
;
EdgeDims
_padding
;
LocaleQueryData
_localeData
;
void
initState
()
{
super
.
initState
();
_navigator
=
new
GlobalObjectKey
(
this
);
_size
=
ui
.
window
.
size
;
_padding
=
_getPadding
(
ui
.
window
);
didChangeLocale
(
ui
.
window
.
locale
);
WidgetFlutterBinding
.
instance
.
addObserver
(
this
);
}
...
...
@@ -106,10 +102,10 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
return
result
;
}
void
didChange
Size
(
Size
size
)
{
void
didChange
Metrics
(
)
{
setState
(()
{
_size
=
size
;
_padding
=
_getPadding
(
ui
.
window
);
// The properties of ui.window have changed. We use them in our build
// function, so we need setState(), but we don't cache anything locally.
});
}
...
...
@@ -150,7 +146,11 @@ class _MaterialAppState extends State<MaterialApp> implements BindingObserver {
ThemeData
theme
=
config
.
theme
??
new
ThemeData
.
fallback
();
Widget
result
=
new
MediaQuery
(
data:
new
MediaQueryData
(
size:
_size
,
padding:
_padding
),
data:
new
MediaQueryData
(
size:
ui
.
window
.
size
,
devicePixelRatio:
ui
.
window
.
devicePixelRatio
,
padding:
_getPadding
(
ui
.
window
)
),
child:
new
LocaleQuery
(
data:
_localeData
,
child:
new
AnimatedTheme
(
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
4d73cf5c
...
...
@@ -14,7 +14,7 @@ import 'framework.dart';
class
BindingObserver
{
bool
didPopRoute
()
=>
false
;
void
didChange
Size
(
Size
size
)
{
}
void
didChange
Metrics
(
)
{
}
void
didChangeLocale
(
ui
.
Locale
locale
)
{
}
void
didChangeAppLifecycleState
(
ui
.
AppLifecycleState
state
)
{
}
}
...
...
@@ -62,7 +62,7 @@ class WidgetFlutterBinding extends BindingBase with Scheduler, Gesturer, Rendere
void
handleMetricsChanged
()
{
super
.
handleMetricsChanged
();
for
(
BindingObserver
observer
in
_observers
)
observer
.
didChange
Size
(
ui
.
window
.
size
);
observer
.
didChange
Metrics
(
ui
.
window
.
size
);
}
void
handleLocaleChanged
()
{
...
...
packages/flutter/lib/src/widgets/media_query.dart
View file @
4d73cf5c
...
...
@@ -16,11 +16,16 @@ enum Orientation {
/// The result of a media query.
class
MediaQueryData
{
const
MediaQueryData
({
this
.
size
,
this
.
padding
});
const
MediaQueryData
({
this
.
size
,
this
.
devicePixelRatio
,
this
.
padding
});
/// The size of the media (e.g, the size of the screen).
final
Size
size
;
/// The number of device pixels for each logical pixel. This number might not
/// be a power of two. Indeed, it might not even be an integer. For example,
/// the Nexus 6 has a device pixel ratio of 3.5.
final
double
devicePixelRatio
;
/// The padding around the edges of the media (e.g., the screen).
final
EdgeDims
padding
;
...
...
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