diff --git a/packages/flutter/lib/src/widgets/gridpaper.dart b/packages/flutter/lib/src/widgets/gridpaper.dart new file mode 100644 index 0000000000..25d22e3a35 --- /dev/null +++ b/packages/flutter/lib/src/widgets/gridpaper.dart @@ -0,0 +1,36 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/rendering.dart'; + +import 'basic.dart'; +import 'framework.dart'; + +class GridPaper extends StatelessComponent { + GridPaper({ + Key key, + this.color: const Color(0xFF000000), + this.interval: 100.0 + }) : super(key: key); + + final Color color; + final double interval; + + Widget build(BuildContext context) { + return new IgnorePointer(child: new CustomPaint( + onPaint: (PaintingCanvas canvas, Size size) { + Paint linePaint = new Paint() + ..color = color; + for (double x = 0.0; x <= size.width; x += interval / 10.0) { + linePaint.strokeWidth = (x % interval == 0.0) ? 1.0 : (x % (interval / 2.0) == 0.0) ? 0.5: 0.25; + canvas.drawLine(new Point(x, 0.0), new Point(x, size.height), linePaint); + } + for (double y = 0.0; y <= size.height; y += interval / 10.0) { + linePaint.strokeWidth = (y % interval == 0.0) ? 1.0 : (y % (interval / 2.0) == 0.0) ? 0.5: 0.25; + canvas.drawLine(new Point(0.0, y), new Point(size.width, y), linePaint); + } + }) + ); + } +} diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 99d5a34c77..5dbb6966fd 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -3,11 +3,19 @@ // found in the LICENSE file. import 'package:flutter/animation.dart'; +import 'package:flutter/rendering.dart'; import 'basic.dart'; import 'focus.dart'; import 'framework.dart'; import 'transitions.dart'; +import 'gridpaper.dart'; + +/// Set this to true to overlay a pixel grid on the screen, with every 100 +/// pixels marked with a thick maroon line and every 10 pixels marked with a +/// thin maroon line. This can help with verifying widget positions. +bool debugShowGrid = false; +Color debugGridColor = const Color(0x7F7F2020); const String kDefaultRouteName = '/'; @@ -149,8 +157,15 @@ class NavigatorState extends State { }); } - Widget build(BuildContext context) { - List visibleRoutes = new List(); + Widget build(BuildContext context) { + List visibleRoutes = []; + + assert(() { + if (debugShowGrid) + visibleRoutes.add(new GridPaper(color: debugGridColor)); + return true; + }); + bool alreadyInsertedModalBarrier = false; Route nextContentRoute; for (int i = _history.length-1; i >= 0; i -= 1) {