-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Describe the bug
Hi, when I try to build my flutter app I get these errors in Xcode:
error: ../../../.pub-cache/hosted/pub.dev/toggle_switch-2.3.0/lib/src/row_to_column.dart:28:44: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
mainAxisAlignment ?? const Row().mainAxisAlignment,
^^^
../../../.pub-cache/hosted/pub.dev/toggle_switch-2.3.0/lib/src/row_to_column.dart:29:49: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
mainAxisSize: mainAxisSize ?? const Row().mainAxisSize,
^^^
../../../.pub-cache/hosted/pub.dev/toggle_switch-2.3.0/lib/src/row_to_column.dart:31:45: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
crossAxisAlignment ?? const Row().crossAxisAlignment,
^^^
../../../.pub-cache/hosted/pub.dev/toggle_switch-2.3.0/lib/src/row_to_column.dart:36:44: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
mainAxisAlignment ?? const Column().mainAxisAlignment,
^^^^^^
../../../.pub-cache/hosted/pub.dev/toggle_switch-2.3.0/lib/src/row_to_column.dart:37:49: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
mainAxisSize: mainAxisSize ?? const Column().mainAxisSize,
^^^^^^
../../../.pub-cache/hosted/pub.dev/toggle_switch-2.3.0/lib/src/row_to_column.dart:39:45: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
crossAxisAlignment ?? const Column().crossAxisAlignment,
^^^^^^Removing const in toggle_switch-2.3.0/lib/src/row_to_column.dart fixes the build issue:
Widget build(BuildContext context) {
return ((isColumnToRow ?? false) ? isVertical : !isVertical)
? Row(
mainAxisAlignment: mainAxisAlignment ?? Row().mainAxisAlignment,
mainAxisSize: mainAxisSize ?? Row().mainAxisSize,
crossAxisAlignment: crossAxisAlignment ?? Row().crossAxisAlignment,
children: children,
)
: Column(
mainAxisAlignment: mainAxisAlignment ?? Column().mainAxisAlignment,
mainAxisSize: mainAxisSize ?? Column().mainAxisSize,
crossAxisAlignment:
crossAxisAlignment ?? Column().crossAxisAlignment,
children: children,
);
}Original code (toggle_switch-2.3.0/lib/src/row_to_column.dart):
Widget build(BuildContext context) {
return ((isColumnToRow ?? false) ? isVertical : !isVertical)
? Row(
mainAxisAlignment:
mainAxisAlignment ?? const Row().mainAxisAlignment,
mainAxisSize: mainAxisSize ?? const Row().mainAxisSize,
crossAxisAlignment:
crossAxisAlignment ?? const Row().crossAxisAlignment,
children: children,
)
: Column(
mainAxisAlignment:
mainAxisAlignment ?? const Column().mainAxisAlignment,
mainAxisSize: mainAxisSize ?? const Column().mainAxisSize,
crossAxisAlignment:
crossAxisAlignment ?? const Column().crossAxisAlignment,
children: children,
);
}
To Reproduce
Code which fails to build:
Column(
children: [
ToggleSwitch(
minWidth: 100.0,
initialLabelIndex: 0,
cornerRadius: 15.0,
activeFgColor: Colors.white,
inactiveBgColor: Colors.grey,
inactiveFgColor: Colors.white,
labels: ['1', '2'],
activeBgColors: [
[Colors.yellow, Colors.green]
],
onToggle: (index) {
},
)]
)Expected behavior
toggle_switch builds without errors.
Screenshots
n/a
Additional information
toggle_switch2.3.0flutter3.7.12dart2.19.6Xcode15.4 (15F31d)
Metadata
Metadata
Assignees
Labels
No labels