Skip to content

Commit 1e8f186

Browse files
authored
Fix FDialog.body not allowing ScrollViews (#704)
1 parent f810297 commit 1e8f186

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

forui/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ We've improved the styles' generated documentation. They should be much easier t
4040
* **Breaking** Move barrier related fields from `FDialogStyle` to `FDialogRouteStyle`.
4141
* **Breaking** Move animation related fields from `FDialogStyle` to `FDialogMotion`.
4242

43+
* Fix `FDialog.body` not allowing `ScrollView`s.
44+
4345

4446
### `FFormField`
4547
* **Breaking** Add `FFormField(onReset: ...)`.

forui/lib/src/widgets/dialog/dialog_content.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ sealed class Content extends StatelessWidget {
4646
),
4747
),
4848
if (body case final body?)
49-
Padding(
50-
padding: const EdgeInsets.only(bottom: 4),
51-
child: Semantics(
52-
container: true,
53-
child: DefaultTextStyle.merge(textAlign: bodyTextAlign, style: style.bodyTextStyle, child: body),
49+
Flexible(
50+
child: Padding(
51+
padding: const EdgeInsets.only(bottom: 4),
52+
child: Semantics(
53+
container: true,
54+
child: DefaultTextStyle.merge(textAlign: bodyTextAlign, style: style.bodyTextStyle, child: body),
55+
),
5456
),
5557
),
5658
if (title != null && body != null) const SizedBox(height: 8),

forui/test/src/widgets/dialog/dialog_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,36 @@ void main() {
109109
expect(tester.takeException(), null);
110110
});
111111
}
112+
113+
testWidgets('scrollable body', (tester) async {
114+
await tester.pumpWidget(
115+
TestScaffold.app(
116+
child: Builder(
117+
builder: (context) => FButton(
118+
mainAxisSize: MainAxisSize.min,
119+
onPress: () => showFDialog(
120+
context: context,
121+
builder: (context, style, animation) => FDialog(
122+
style: style,
123+
animation: animation,
124+
title: const Text('Are you absolutely sure?'),
125+
body: SingleChildScrollView(child: Container(height: 5000)),
126+
actions: [
127+
FButton(style: FButtonStyle.outline(), child: const Text('Cancel'), onPress: () {}),
128+
FButton(child: const Text('Continue'), onPress: () {}),
129+
],
130+
),
131+
),
132+
child: const Text('Show Dialog'),
133+
),
134+
),
135+
),
136+
);
137+
138+
await tester.tap(find.text('Show Dialog'));
139+
await tester.pumpAndSettle();
140+
141+
expect(tester.takeException(), null);
142+
});
112143
});
113144
}

0 commit comments

Comments
 (0)