Unverified Commit 6d9e3c3f authored by Yurii Cherniavskyi's avatar Yurii Cherniavskyi Committed by GitHub

Expose insetPadding and clipBehavior in SimpleDialog (#73571)

parent f5c0a7b3
......@@ -736,6 +736,8 @@ class SimpleDialog extends StatelessWidget {
this.backgroundColor,
this.elevation,
this.semanticLabel,
this.insetPadding = _defaultInsetPadding,
this.clipBehavior = Clip.none,
this.shape,
}) : assert(titlePadding != null),
assert(contentPadding != null),
......@@ -804,6 +806,12 @@ class SimpleDialog extends StatelessWidget {
/// value is used.
final String? semanticLabel;
/// {@macro flutter.material.dialog.insetPadding}
final EdgeInsets insetPadding;
/// {@macro flutter.material.dialog.clipBehavior}
final Clip clipBehavior;
/// {@macro flutter.material.dialog.shape}
final ShapeBorder? shape;
......@@ -890,6 +898,8 @@ class SimpleDialog extends StatelessWidget {
return Dialog(
backgroundColor: backgroundColor,
elevation: elevation,
insetPadding: insetPadding,
clipBehavior: clipBehavior,
shape: shape,
child: dialogChild,
);
......
......@@ -40,11 +40,11 @@ MaterialApp _buildAppWithDialog(Widget dialog, { ThemeData? theme, double textSc
}
Material _getMaterialFromDialog(WidgetTester tester) {
return tester.widget<Material>(find.descendant(of: find.byType(AlertDialog), matching: find.byType(Material)));
return tester.widget<Material>(find.descendant(of: find.byType(Dialog), matching: find.byType(Material)));
}
RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text) {
return tester.element<StatelessElement>(find.descendant(of: find.byType(AlertDialog), matching: find.text(text))).renderObject! as RenderParagraph;
return tester.element<StatelessElement>(find.descendant(of: find.byType(Dialog), matching: find.text(text))).renderObject! as RenderParagraph;
}
const ShapeBorder _defaultDialogShape = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0)));
......@@ -158,7 +158,7 @@ void main() {
expect(content.text.style, contentTextStyle);
});
testWidgets('Custom clipBehavior', (WidgetTester tester) async {
testWidgets('AlertDialog custom clipBehavior', (WidgetTester tester) async {
const AlertDialog dialog = AlertDialog(
actions: <Widget>[],
clipBehavior: Clip.antiAlias,
......@@ -172,6 +172,20 @@ void main() {
expect(materialWidget.clipBehavior, Clip.antiAlias);
});
testWidgets('SimpleDialog custom clipBehavior', (WidgetTester tester) async {
const SimpleDialog dialog = SimpleDialog(
children: <Widget>[],
clipBehavior: Clip.antiAlias,
);
await tester.pumpWidget(_buildAppWithDialog(dialog));
await tester.tap(find.text('X'));
await tester.pumpAndSettle();
final Material materialWidget = _getMaterialFromDialog(tester);
expect(materialWidget.clipBehavior, Clip.antiAlias);
});
testWidgets('Custom dialog shape', (WidgetTester tester) async {
const RoundedRectangleBorder customBorder =
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16.0)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment