Beispiel #1
0
        public override void paint(PaintingContext context, Offset offset)
        {
            if (!_hasOverflow)
            {
                defaultPaint(context, offset);
                return;
            }

            if (size.isEmpty)
            {
                return;
            }

            context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);

            D.assert(() => {
                List <DiagnosticsNode> debugOverflowHints = new List <DiagnosticsNode> {
                    new ErrorDescription(
                        $"The overflowing {GetType()} has an orientation of {_direction}."
                        ),
                    new ErrorDescription(
                        $"The edge of the {GetType()} that is overflowing has been marked " +
                        "in the rendering with a yellow and black striped pattern. This is " +
                        "usually caused by the contents being too big for the {GetType()}."
                        ),
                    new ErrorHint(
                        "Consider applying a flex factor (e.g. using an Expanded widget) to " +
                        $"force the children of the {GetType()} to fit within the available " +
                        "space instead of being sized to their natural size."
                        ),
                    new ErrorHint(
                        "This is considered an error condition because it indicates that there " +
                        "is content that cannot be seen. If the content is legitimately bigger " +
                        "than the available space, consider clipping it with a ClipRect widget " +
                        "before putting it in the flex, or using a scrollable container rather " +
                        "than a Flex, like a ListView."
                        )
                };

                Rect overflowChildRect;
                switch (_direction)
                {
                case Axis.horizontal:
                    overflowChildRect = Rect.fromLTWH(0.0f, 0.0f, size.width + _overflow, 0.0f);
                    break;

                case Axis.vertical:
                    overflowChildRect = Rect.fromLTWH(0.0f, 0.0f, 0.0f, size.height + _overflow);
                    break;

                default:
                    throw new Exception("Unknown direction: " + _direction);
                }

                DebugOverflowIndicatorMixin.paintOverflowIndicator(this, context, offset, Offset.zero & size,
                                                                   overflowChildRect, overflowHints: debugOverflowHints);
                return(true);
            });
        }
Beispiel #2
0
        public override void paint(PaintingContext context, Offset offset)
        {
            if (this.child == null || this.size.isEmpty)
            {
                return;
            }

            if (!this._isOverflowing)
            {
                base.paint(context, offset);
                return;
            }

            context.pushClipRect(this.needsCompositing, offset, Offset.zero & this.size, base.paint);
            D.assert(() => {
                DebugOverflowIndicatorMixin.paintOverflowIndicator(this, context, offset, this._overflowContainerRect, this._overflowChildRect);
                return(true);
            });
        }