diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index 1d71ebeaab..c2deec75e8 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -372,7 +372,7 @@ class _CupertinoAlertDialogState extends State { Widget _buildBody(BuildContext context) { final Color backgroundColor = CupertinoDynamicColor.resolve(_kDialogColor, context); - const Color dividerColor = CupertinoColors.separator; + final Color dividerColor = CupertinoDynamicColor.resolve(CupertinoColors.separator, context); // Remove view padding here because the `Scrollbar` widget uses the view // padding as padding, which is unwanted. // https://github.com/flutter/flutter/issues/150544 @@ -407,7 +407,14 @@ class _CupertinoAlertDialogState extends State { top: contentSection, bottom: Column( children: [ - _Divider(dividerColor: dividerColor, hiddenColor: backgroundColor, hidden: false), + SizedBox( + width: double.infinity, + child: _Divider( + dividerColor: dividerColor, + hiddenColor: backgroundColor, + hidden: false, + ), + ), Flexible(child: scrolledActionsSection), ], ), diff --git a/packages/flutter/test/cupertino/dialog_test.dart b/packages/flutter/test/cupertino/dialog_test.dart index 3046d85a44..96bbcc16e9 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart @@ -1988,6 +1988,50 @@ void main() { kIsWeb ? SystemMouseCursors.click : SystemMouseCursors.basic, ); }); + + testWidgets('CupertinoAlertDialog divider spans full width and applies color', ( + WidgetTester tester, + ) async { + const double kCupertinoDialogWidth = 270.0; + const double kDividerThickness = 0.3; + const Size expectedSize = Size(kCupertinoDialogWidth, kDividerThickness); + + await tester.pumpWidget( + CupertinoApp( + home: MediaQuery( + data: const MediaQueryData(platformBrightness: Brightness.dark), + child: CupertinoAlertDialog( + title: const Text('The Title'), + content: const Text('Content'), + actions: [ + CupertinoDialogAction( + isDefaultAction: true, + onPressed: () {}, + child: const Text('Cancel'), + ), + const CupertinoDialogAction(child: Text('OK')), + ], + ), + ), + ), + ); + + final Finder decoratedBoxFinder = find.byType(DecoratedBox); + + expect(decoratedBoxFinder, findsAny, reason: 'There should exist at least one DecoratedBox'); + + final Iterable elements = decoratedBoxFinder.evaluate().where(( + Element decoratedBoxElement, + ) { + final DecoratedBox decoratedBox = decoratedBoxElement.widget as DecoratedBox; + return (decoratedBox.decoration is BoxDecoration?) && + (decoratedBox.decoration as BoxDecoration?)?.color == + CupertinoDynamicColor.resolve(CupertinoColors.separator, decoratedBoxElement) && + tester.getSize(find.byWidget(decoratedBox)) == expectedSize; + }); + + expect(elements.length, 1, reason: 'No DecoratedBox matches the specified criteria.'); + }); } RenderBox findActionButtonRenderBoxByTitle(WidgetTester tester, String title) {