Updated document to clarify Clip Behaviour (#157719)

Revised comments to clarify that clipping of child depends on clipBehavior of the parent widget, typically scrollable widgets that default to Clips.hard.
Noted that decoration features such as shadows , which render outside the widget boundary, may lead to undesirable effects.
Recommended using Clips.none in scenarios where shadow effects are used to avoid clipping issues.
Fixing Issue #156819
This commit is contained in:
Neutrino2711
2024-11-15 01:51:09 +05:30
committed by GitHub
parent e40306f92f
commit 4b818b56c2
3 changed files with 214 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
// Copyright 2014 The Flutter 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/material.dart';
import 'package:flutter_api_samples/widgets/sliver/decorated_sliver.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('CustomScrollView clipBehavior is Clip.none when is Clipped is false', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: example.DecoratedSliverClipExample(),
),
);
final CustomScrollView customScrollView = tester.widget(find.byType(CustomScrollView));
expect(customScrollView.clipBehavior, equals(Clip.none));
});
testWidgets('Verify the DecoratedSliver has shadow property in decoration', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: example.ResizableCustomScrollView(isClipped: false),
),
);
final DecoratedSliver decoratedSliver = tester.widget(find.byType(DecoratedSliver));
final ShapeDecoration shapeDecoration = decoratedSliver.decoration as ShapeDecoration;
expect(shapeDecoration.shadows, isNotEmpty);
});
testWidgets('Verify Slider and Switch widgets', (WidgetTester tester) async {
await tester.pumpWidget(const example.DecoratedSliverClipExampleApp());
expect(find.byType(Slider), findsOneWidget);
expect(find.byType(Switch), findsOneWidget);
});
}