Commit f27fa0ec authored by Hans Muller's avatar Hans Muller Committed by GitHub

Gallery animation demo: lazily compute screen dimensions (#5715)

parent 1152fd60
......@@ -71,7 +71,7 @@ class _PointDemoPainter extends CustomPainter {
final Paint paint = new Paint();
if (arc.center != null)
drawPoint(canvas, arc.center, Colors.blue[400]);
drawPoint(canvas, arc.center, Colors.grey[400]);
paint
..color = Colors.green[500].withOpacity(0.25)
......@@ -115,6 +115,7 @@ class _PointDemoState extends State<_PointDemo> {
CurvedAnimation _animation;
_DragTarget _dragTarget;
Size _screenSize;
Point _begin;
Point _end;
......@@ -177,8 +178,11 @@ class _PointDemoState extends State<_PointDemo> {
@override
Widget build(BuildContext context) {
final Size screenSize = MediaQuery.of(context).size;
_begin = new Point(screenSize.width * 0.5, screenSize.height * 0.2);
_end = new Point(screenSize.width * 0.1, screenSize.height * 0.4);
if (_screenSize == null || _screenSize != screenSize) {
_screenSize = screenSize;
_begin = new Point(screenSize.width * 0.5, screenSize.height * 0.2);
_end = new Point(screenSize.width * 0.1, screenSize.height * 0.4);
}
final MaterialPointArcTween arc = new MaterialPointArcTween(begin: _begin, end: _end);
return new RawGestureDetector(
......@@ -276,6 +280,7 @@ class _RectangleDemoState extends State<_RectangleDemo> {
CurvedAnimation _animation;
_DragTarget _dragTarget;
Size _screenSize;
Rect _begin;
Rect _end;
......@@ -337,14 +342,17 @@ class _RectangleDemoState extends State<_RectangleDemo> {
@override
Widget build(BuildContext context) {
final Size screenSize = MediaQuery.of(context).size;
_begin = new Rect.fromLTWH(
screenSize.width * 0.5, screenSize.height * 0.2,
screenSize.width * 0.4, screenSize.height * 0.2
);
_end = new Rect.fromLTWH(
screenSize.width * 0.1, screenSize.height * 0.4,
screenSize.width * 0.3, screenSize.height * 0.3
);
if (_screenSize == null || _screenSize != screenSize) {
_screenSize = screenSize;
_begin = new Rect.fromLTWH(
screenSize.width * 0.5, screenSize.height * 0.2,
screenSize.width * 0.4, screenSize.height * 0.2
);
_end = new Rect.fromLTWH(
screenSize.width * 0.1, screenSize.height * 0.4,
screenSize.width * 0.3, screenSize.height * 0.3
);
}
final MaterialRectArcTween arc = new MaterialRectArcTween(begin: _begin, end: _end);
return new RawGestureDetector(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment