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
b6655330
Unverified
Commit
b6655330
authored
Mar 30, 2020
by
Ayush Bherwani
Committed by
GitHub
Mar 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MediaQueryData] adds assertions to MediaQueryData Constructor (#53003)
parent
e4a61dfd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
181 additions
and
1 deletion
+181
-1
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+15
-1
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+166
-0
No files found.
packages/flutter/lib/src/widgets/media_query.dart
View file @
b6655330
...
...
@@ -102,7 +102,21 @@ class MediaQueryData {
this
.
highContrast
=
false
,
this
.
disableAnimations
=
false
,
this
.
boldText
=
false
,
});
})
:
assert
(
size
!=
null
),
assert
(
devicePixelRatio
!=
null
),
assert
(
textScaleFactor
!=
null
),
assert
(
platformBrightness
!=
null
),
assert
(
padding
!=
null
),
assert
(
viewInsets
!=
null
),
assert
(
systemGestureInsets
!=
null
),
assert
(
viewPadding
!=
null
),
assert
(
physicalDepth
!=
null
),
assert
(
alwaysUse24HourFormat
!=
null
),
assert
(
accessibleNavigation
!=
null
),
assert
(
invertColors
!=
null
),
assert
(
highContrast
!=
null
),
assert
(
disableAnimations
!=
null
),
assert
(
boldText
!=
null
);
/// Creates data for a media query based on the given window.
///
...
...
packages/flutter/test/widgets/media_query_test.dart
View file @
b6655330
...
...
@@ -564,4 +564,170 @@ void main() {
expect
(
outsideBoldTextOverride
,
false
);
expect
(
insideBoldTextOverride
,
true
);
});
test
(
'size parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
size:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'size != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'devicePixelRatio parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
devicePixelRatio:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'devicePixelRatio != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'textScaleFactor parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
textScaleFactor:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'textScaleFactor != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'platformBrightness parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
platformBrightness:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'platformBrightness != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'padding parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
padding:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'padding != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'viewInsets parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
viewInsets:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'viewInsets != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'systemGestureInsets parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
systemGestureInsets:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'systemGestureInsets != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'viewPadding parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
viewPadding:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'viewPadding != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'physicalDepth parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
physicalDepth:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'physicalDepth != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'alwaysUse24HourFormat parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
alwaysUse24HourFormat:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'alwaysUse24HourFormat != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'accessibleNavigation parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
accessibleNavigation:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'accessibleNavigation != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'invertColors parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
invertColors:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'invertColors != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'highContrast parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
highContrast:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'highContrast != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'disableAnimations parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
disableAnimations:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'disableAnimations != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
test
(
'boldText parameter in MediaQueryData cannot be null'
,
()
{
try
{
MediaQueryData
(
boldText:
null
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'boldText != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
return
;
}
fail
(
'The assert was never called when it should have been'
);
});
}
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