Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
# Name/Organization <email address>

Google Inc.
Sarbagya Dhaubanjar <mail@sarbagyastha.com.np>
13 changes: 12 additions & 1 deletion packages/animations/lib/src/open_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class OpenContainer<T extends Object> extends StatefulWidget {
this.transitionDuration = const Duration(milliseconds: 300),
this.transitionType = ContainerTransitionType.fade,
this.useRootNavigator = false,
this.clipBehavior = Clip.antiAlias,
}) : assert(closedColor != null),
assert(openColor != null),
assert(closedElevation != null),
Expand All @@ -108,6 +109,7 @@ class OpenContainer<T extends Object> extends StatefulWidget {
assert(tappable != null),
assert(transitionType != null),
assert(useRootNavigator != null),
assert(clipBehavior != null),
super(key: key);

/// Background color of the container while it is closed.
Expand Down Expand Up @@ -257,6 +259,15 @@ class OpenContainer<T extends Object> extends StatefulWidget {
/// to the nearest navigator.
final bool useRootNavigator;

/// The [closedBuilder] will be clipped (or not) according to this option.
///
/// Defaults to [Clip.antiAlias], and must not be null.
///
/// See also:
///
/// * [Material.clipBehavior], which is used to implement this property.
final Clip clipBehavior;

@override
_OpenContainerState<T> createState() => _OpenContainerState<T>();
}
Expand Down Expand Up @@ -308,7 +319,7 @@ class _OpenContainerState<T> extends State<OpenContainer<T>> {
child: GestureDetector(
onTap: widget.tappable ? openContainer : null,
child: Material(
clipBehavior: Clip.antiAlias,
clipBehavior: widget.clipBehavior,
color: widget.closedColor,
elevation: widget.closedElevation,
shape: widget.closedShape,
Expand Down
56 changes: 56 additions & 0 deletions packages/animations/test/open_container_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,62 @@ void main() {
expect(value, isTrue);
});

testWidgets('closedBuilder has anti-alias clip by default',
(WidgetTester tester) async {
final GlobalKey closedBuilderKey = GlobalKey();
final Widget openContainer = OpenContainer(
closedBuilder: (BuildContext context, VoidCallback action) {
return Text('Close', key: closedBuilderKey);
},
openBuilder:
(BuildContext context, CloseContainerActionCallback<bool> action) {
return const Text('Open');
},
);

await tester.pumpWidget(
_boilerplate(child: openContainer),
);

final Finder closedBuilderMaterial = find
.ancestor(
of: find.byKey(closedBuilderKey),
matching: find.byType(Material),
)
.first;

final Material material = tester.widget<Material>(closedBuilderMaterial);
expect(material.clipBehavior, Clip.antiAlias);
});

testWidgets('closedBuilder has no clip', (WidgetTester tester) async {
final GlobalKey closedBuilderKey = GlobalKey();
final Widget openContainer = OpenContainer(
closedBuilder: (BuildContext context, VoidCallback action) {
return Text('Close', key: closedBuilderKey);
},
openBuilder:
(BuildContext context, CloseContainerActionCallback<bool> action) {
return const Text('Open');
},
clipBehavior: Clip.none,
);

await tester.pumpWidget(
_boilerplate(child: openContainer),
);

final Finder closedBuilderMaterial = find
.ancestor(
of: find.byKey(closedBuilderKey),
matching: find.byType(Material),
)
.first;

final Material material = tester.widget<Material>(closedBuilderMaterial);
expect(material.clipBehavior, Clip.none);
});

Widget _createRootNavigatorTest({
@required Key appKey,
@required Key nestedNavigatorKey,
Expand Down