Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 0 additions & 6 deletions packages/flutter/lib/src/cupertino/context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,9 @@ class CupertinoContextMenu extends StatefulWidget {
///
/// final Animation<Decoration> boxDecorationAnimation = DecorationTween(
/// begin: const BoxDecoration(
/// color: Color(0xFFFFFFFF),
/// boxShadow: <BoxShadow>[],
/// ),
/// end: const BoxDecoration(
/// color: Color(0xFFFFFFFF),
/// boxShadow: CupertinoContextMenu.kEndBoxShadow,
/// ),
/// ).animate(
Expand Down Expand Up @@ -279,11 +277,9 @@ class CupertinoContextMenu extends StatefulWidget {
///
/// final Animation<Decoration> boxDecorationAnimation = DecorationTween(
/// begin: const BoxDecoration(
/// color: Color(0xFFFFFFFF),
/// boxShadow: <BoxShadow>[],
/// ),
/// end: const BoxDecoration(
/// color: Color(0xFFFFFFFF),
/// boxShadow: CupertinoContextMenu.kEndBoxShadow,
/// ),
/// ).animate(
Expand Down Expand Up @@ -676,11 +672,9 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin

_boxDecoration = DecorationTween(
begin: const BoxDecoration(
color: Color(0xFFFFFFFF),
boxShadow: <BoxShadow>[],
),
end: const BoxDecoration(
color: Color(0xFFFFFFFF),
boxShadow: _endBoxShadow,
),
).animate(CurvedAnimation(
Expand Down
55 changes: 55 additions & 0 deletions packages/flutter/test/cupertino/context_menu_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,61 @@ void main() {
expect(findStatic(), findsOneWidget);
});

testWidgets('_DecoyChild preserves the child color', (WidgetTester tester) async {
final Widget child = getChild();
await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold(
backgroundColor: CupertinoColors.black,
child: MediaQuery(
data: const MediaQueryData(size: Size(800, 600)),
child: Center(
child: CupertinoContextMenu(
actions: const <CupertinoContextMenuAction>[
CupertinoContextMenuAction(
child: Text('CupertinoContextMenuAction'),
),
],
child: child
),
)
)
),
));

// Expect no _DecoyChild to be present before the gesture.
final Finder decoyChild = find
.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DecoyChild');
expect(decoyChild, findsNothing);

// Start press gesture on the child.
final Rect childRect = tester.getRect(find.byWidget(child));
final TestGesture gesture = await tester.startGesture(childRect.center);
await tester.pump();

// Find the _DecoyChild by runtimeType,
// find the Container descendant with the BoxDecoration,
// then read the boxDecoration property.
final Finder decoyChildDescendant = find.descendant(
of: decoyChild,
matching: find.byType(Container));
final BoxDecoration? boxDecoration = (tester.firstWidget(decoyChildDescendant) as Container).decoration as BoxDecoration?;
const List<Color?> expectedColors = <Color?>[null, Color(0x00000000)];

// `Color(0x00000000)` -> Is `Colors.transparent`.
// `null` -> Default when no color argument is given in `BoxDecoration`.
// Any other color won't preserve the child's property.
expect(expectedColors, contains(boxDecoration?.color));

// End the gesture.
await gesture.up();
await tester.pumpAndSettle();

// Expect no _DecoyChild to be present after ending the gesture.
final Finder decoyChildAfterEnding = find
.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DecoyChild');
expect(decoyChildAfterEnding, findsNothing);
});

testWidgets('CupertinoContextMenu with a basic builder opens and closes the same as when providing a child', (WidgetTester tester) async {
final Widget child = getChild();
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
Expand Down