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 { ...@@ -71,7 +71,7 @@ class _PointDemoPainter extends CustomPainter {
final Paint paint = new Paint(); final Paint paint = new Paint();
if (arc.center != null) if (arc.center != null)
drawPoint(canvas, arc.center, Colors.blue[400]); drawPoint(canvas, arc.center, Colors.grey[400]);
paint paint
..color = Colors.green[500].withOpacity(0.25) ..color = Colors.green[500].withOpacity(0.25)
...@@ -115,6 +115,7 @@ class _PointDemoState extends State<_PointDemo> { ...@@ -115,6 +115,7 @@ class _PointDemoState extends State<_PointDemo> {
CurvedAnimation _animation; CurvedAnimation _animation;
_DragTarget _dragTarget; _DragTarget _dragTarget;
Size _screenSize;
Point _begin; Point _begin;
Point _end; Point _end;
...@@ -177,8 +178,11 @@ class _PointDemoState extends State<_PointDemo> { ...@@ -177,8 +178,11 @@ class _PointDemoState extends State<_PointDemo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Size screenSize = MediaQuery.of(context).size; final Size screenSize = MediaQuery.of(context).size;
_begin = new Point(screenSize.width * 0.5, screenSize.height * 0.2); if (_screenSize == null || _screenSize != screenSize) {
_end = new Point(screenSize.width * 0.1, screenSize.height * 0.4); _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); final MaterialPointArcTween arc = new MaterialPointArcTween(begin: _begin, end: _end);
return new RawGestureDetector( return new RawGestureDetector(
...@@ -276,6 +280,7 @@ class _RectangleDemoState extends State<_RectangleDemo> { ...@@ -276,6 +280,7 @@ class _RectangleDemoState extends State<_RectangleDemo> {
CurvedAnimation _animation; CurvedAnimation _animation;
_DragTarget _dragTarget; _DragTarget _dragTarget;
Size _screenSize;
Rect _begin; Rect _begin;
Rect _end; Rect _end;
...@@ -337,14 +342,17 @@ class _RectangleDemoState extends State<_RectangleDemo> { ...@@ -337,14 +342,17 @@ class _RectangleDemoState extends State<_RectangleDemo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Size screenSize = MediaQuery.of(context).size; final Size screenSize = MediaQuery.of(context).size;
_begin = new Rect.fromLTWH( if (_screenSize == null || _screenSize != screenSize) {
screenSize.width * 0.5, screenSize.height * 0.2, _screenSize = screenSize;
screenSize.width * 0.4, screenSize.height * 0.2 _begin = new Rect.fromLTWH(
); screenSize.width * 0.5, screenSize.height * 0.2,
_end = new Rect.fromLTWH( screenSize.width * 0.4, screenSize.height * 0.2
screenSize.width * 0.1, screenSize.height * 0.4, );
screenSize.width * 0.3, screenSize.height * 0.3 _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); final MaterialRectArcTween arc = new MaterialRectArcTween(begin: _begin, end: _end);
return new RawGestureDetector( 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