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 { ...@@ -736,6 +736,8 @@ class SimpleDialog extends StatelessWidget {
this.backgroundColor, this.backgroundColor,
this.elevation, this.elevation,
this.semanticLabel, this.semanticLabel,
this.insetPadding = _defaultInsetPadding,
this.clipBehavior = Clip.none,
this.shape, this.shape,
}) : assert(titlePadding != null), }) : assert(titlePadding != null),
assert(contentPadding != null), assert(contentPadding != null),
...@@ -804,6 +806,12 @@ class SimpleDialog extends StatelessWidget { ...@@ -804,6 +806,12 @@ class SimpleDialog extends StatelessWidget {
/// value is used. /// value is used.
final String? semanticLabel; final String? semanticLabel;
/// {@macro flutter.material.dialog.insetPadding}
final EdgeInsets insetPadding;
/// {@macro flutter.material.dialog.clipBehavior}
final Clip clipBehavior;
/// {@macro flutter.material.dialog.shape} /// {@macro flutter.material.dialog.shape}
final ShapeBorder? shape; final ShapeBorder? shape;
...@@ -890,6 +898,8 @@ class SimpleDialog extends StatelessWidget { ...@@ -890,6 +898,8 @@ class SimpleDialog extends StatelessWidget {
return Dialog( return Dialog(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
elevation: elevation, elevation: elevation,
insetPadding: insetPadding,
clipBehavior: clipBehavior,
shape: shape, shape: shape,
child: dialogChild, child: dialogChild,
); );
......
...@@ -40,11 +40,11 @@ MaterialApp _buildAppWithDialog(Widget dialog, { ThemeData? theme, double textSc ...@@ -40,11 +40,11 @@ MaterialApp _buildAppWithDialog(Widget dialog, { ThemeData? theme, double textSc
} }
Material _getMaterialFromDialog(WidgetTester tester) { 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) { 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))); const ShapeBorder _defaultDialogShape = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0)));
...@@ -158,7 +158,7 @@ void main() { ...@@ -158,7 +158,7 @@ void main() {
expect(content.text.style, contentTextStyle); expect(content.text.style, contentTextStyle);
}); });
testWidgets('Custom clipBehavior', (WidgetTester tester) async { testWidgets('AlertDialog custom clipBehavior', (WidgetTester tester) async {
const AlertDialog dialog = AlertDialog( const AlertDialog dialog = AlertDialog(
actions: <Widget>[], actions: <Widget>[],
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
...@@ -172,6 +172,20 @@ void main() { ...@@ -172,6 +172,20 @@ void main() {
expect(materialWidget.clipBehavior, Clip.antiAlias); 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 { testWidgets('Custom dialog shape', (WidgetTester tester) async {
const RoundedRectangleBorder customBorder = const RoundedRectangleBorder customBorder =
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16.0))); 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