Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The OutlinedButton mouse cursor code would throw exception if only one is given #118071

Closed
@timnew

Description

@timnew

The OutlinedButton.styleFrom is declared as:

static ButtonStyle styleFrom({
Color? foregroundColor,
Color? backgroundColor,
Color? disabledForegroundColor,
Color? disabledBackgroundColor,
Color? shadowColor,
Color? surfaceTintColor,
double? elevation,
TextStyle? textStyle,
EdgeInsetsGeometry? padding,
Size? minimumSize,
Size? fixedSize,
Size? maximumSize,
BorderSide? side,
OutlinedBorder? shape,
MouseCursor? enabledMouseCursor,
MouseCursor? disabledMouseCursor,
VisualDensity? visualDensity,
MaterialTapTargetSize? tapTargetSize,
Duration? animationDuration,
bool? enableFeedback,
AlignmentGeometry? alignment,
InteractiveInkFeatureFactory? splashFactory,
@Deprecated(
'Use foregroundColor instead. '
'This feature was deprecated after v3.1.0.'
)
Color? primary,
@Deprecated(
'Use disabledForegroundColor instead. '
'This feature was deprecated after v3.1.0.'
)
Color? onSurface,
}) {

where disabledMouseCursor and enabledMouseCursor are nullable, and have no restriction around it.

But later it is used as:

final MaterialStateProperty<MouseCursor>? mouseCursor = (enabledMouseCursor == null && disabledMouseCursor == null)
? null
: _OutlinedButtonDefaultMouseCursor(enabledMouseCursor!, disabledMouseCursor!);

Both has ! but the condition only excluded the case that both values are null.

So if only one value is given, the code gonna throw.

Metadata

Metadata

Assignees

Labels

a: error messageError messages from the Flutter frameworka: null-safetySupport for Dart's null safety featuref: material designflutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions