Skip to content

Commit

Permalink
Merge pull request #39 from itaishalom/master
Browse files Browse the repository at this point in the history
Set initialValue to null to trigger no active value
  • Loading branch information
PramodJoshi authored Oct 20, 2021
2 parents 8f5c80b + e41a1c9 commit 0610d66
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/toggle_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class ToggleSwitch extends StatefulWidget {
/// Animation curve
final Curve curve;

/// Initial label index
int initialLabelIndex;
/// Initial label index, set to null for no chosen initial value (all options inactive)
int? initialLabelIndex;

ToggleSwitch({
Key? key,
Expand Down Expand Up @@ -219,8 +219,9 @@ class _ToggleSwitchState extends State<ToggleSwitch>
}

if (index % 2 == 1) {
final activeDivider =
active || index ~/ 2 == widget.initialLabelIndex - 1;
final activeDivider = active ||
(widget.initialLabelIndex != null &&
index ~/ 2 == widget.initialLabelIndex! - 1);

/// Returns item divider
return Container(
Expand Down

0 comments on commit 0610d66

Please sign in to comment.