[CupertinoActionSheet & AlertDialog] Improve documentation and type for scrollController parameters (#152647)

This PR:
* Improves doc for `scrollController` parameters, replacing the unclear "typically unneeded" with better reasons.
* Makes `scrollController` non-nullable on private classes, since they're always provided by their parents.
* Remove a redundant parameter from a private class.
This commit is contained in:
Tong Mu 2024-08-01 10:46:40 -07:00 committed by GitHub
parent 735958ef9a
commit 5edec61f0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -260,8 +260,8 @@ class CupertinoAlertDialog extends StatefulWidget {
/// A scroll controller that can be used to control the scrolling of the /// A scroll controller that can be used to control the scrolling of the
/// [content] in the dialog. /// [content] in the dialog.
/// ///
/// Defaults to null, and is typically not needed, since most alert messages /// Defaults to null, which means the [CupertinoDialogAction] will create a
/// are short. /// scroll controller internally.
/// ///
/// See also: /// See also:
/// ///
@ -272,7 +272,8 @@ class CupertinoAlertDialog extends StatefulWidget {
/// A scroll controller that can be used to control the scrolling of the /// A scroll controller that can be used to control the scrolling of the
/// actions in the dialog. /// actions in the dialog.
/// ///
/// Defaults to null, and is typically not needed. /// Defaults to null, which means the [CupertinoDialogAction] will create an
/// action scroll controller internally.
/// ///
/// See also: /// See also:
/// ///
@ -397,7 +398,6 @@ class _CupertinoAlertDialogState extends State<CupertinoAlertDialog> {
); );
} }
final Widget scrolledActionsSection = _OverscrollBackground( final Widget scrolledActionsSection = _OverscrollBackground(
scrollController: _effectiveActionScrollController,
color: backgroundColor, color: backgroundColor,
child: actionsSection, child: actionsSection,
); );
@ -928,14 +928,15 @@ class CupertinoActionSheet extends StatefulWidget {
/// A scroll controller that can be used to control the scrolling of the /// A scroll controller that can be used to control the scrolling of the
/// [message] in the action sheet. /// [message] in the action sheet.
/// ///
/// This attribute is typically not needed, as alert messages should be /// Defaults to null, which means the [CupertinoActionSheet] will create a
/// short. /// scroll controller internally.
final ScrollController? messageScrollController; final ScrollController? messageScrollController;
/// A scroll controller that can be used to control the scrolling of the /// A scroll controller that can be used to control the scrolling of the
/// [actions] in the action sheet. /// [actions] in the action sheet.
/// ///
/// This attribute is typically not needed. /// Defaults to null, which means the [CupertinoActionSheet] will create an
/// action scroll controller internally.
final ScrollController? actionScrollController; final ScrollController? actionScrollController;
/// The optional cancel button that is grouped separately from the other /// The optional cancel button that is grouped separately from the other
@ -1479,7 +1480,6 @@ class _Divider extends StatelessWidget {
class _OverscrollBackground extends StatefulWidget { class _OverscrollBackground extends StatefulWidget {
const _OverscrollBackground({ const _OverscrollBackground({
required this.color, required this.color,
required this.scrollController,
required this.child, required this.child,
}); });
@ -1488,7 +1488,6 @@ class _OverscrollBackground extends StatefulWidget {
// This value must be a resolved color instead of, for example, a // This value must be a resolved color instead of, for example, a
// CupertinoDynamicColor. // CupertinoDynamicColor.
final Color color; final Color color;
final ScrollController? scrollController;
final Widget child; final Widget child;
@override @override
@ -1571,7 +1570,7 @@ class _ActionSheetActionSection extends StatelessWidget {
final int? pressedIndex; final int? pressedIndex;
final Color dividerColor; final Color dividerColor;
final Color backgroundColor; final Color backgroundColor;
final ScrollController? scrollController; final ScrollController scrollController;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -1624,7 +1623,7 @@ class _ActionSheetMainSheet extends StatelessWidget {
final int? pressedIndex; final int? pressedIndex;
final _PressedUpdateHandler onPressedUpdate; final _PressedUpdateHandler onPressedUpdate;
final ScrollController? scrollController; final ScrollController scrollController;
final List<Widget> actions; final List<Widget> actions;
final Widget? contentSection; final Widget? contentSection;
final Color dividerColor; final Color dividerColor;
@ -1632,7 +1631,6 @@ class _ActionSheetMainSheet extends StatelessWidget {
Widget _scrolledActionsSection(BuildContext context) { Widget _scrolledActionsSection(BuildContext context) {
final Color backgroundColor = CupertinoDynamicColor.resolve(_kActionSheetBackgroundColor, context); final Color backgroundColor = CupertinoDynamicColor.resolve(_kActionSheetBackgroundColor, context);
return _OverscrollBackground( return _OverscrollBackground(
scrollController: scrollController,
color: backgroundColor, color: backgroundColor,
child: _ActionSheetActionSection( child: _ActionSheetActionSection(
actions: actions, actions: actions,
@ -1693,7 +1691,7 @@ class _CupertinoAlertContentSection extends StatelessWidget {
const _CupertinoAlertContentSection({ const _CupertinoAlertContentSection({
this.title, this.title,
this.message, this.message,
this.scrollController, required this.scrollController,
this.titlePadding, this.titlePadding,
this.messagePadding, this.messagePadding,
this.titleTextStyle, this.titleTextStyle,
@ -1716,10 +1714,7 @@ class _CupertinoAlertContentSection extends StatelessWidget {
// A scroll controller that can be used to control the scrolling of the // A scroll controller that can be used to control the scrolling of the
// content in the dialog. // content in the dialog.
// final ScrollController scrollController;
// Defaults to null, and is typically not needed, since most alert contents
// are short.
final ScrollController? scrollController;
// Paddings used around title and message. // Paddings used around title and message.
// CupertinoAlertDialog and CupertinoActionSheet have different paddings. // CupertinoAlertDialog and CupertinoActionSheet have different paddings.
@ -1805,10 +1800,7 @@ class _CupertinoAlertActionSection extends StatelessWidget {
// A scroll controller that can be used to control the scrolling of the // A scroll controller that can be used to control the scrolling of the
// actions in the dialog. // actions in the dialog.
// final ScrollController scrollController;
// Defaults to null, and is typically not needed, since most alert dialogs
// don't have many actions.
final ScrollController? scrollController;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {