PramodJoshi / toggle_switch

A simple toggle switch widget for Flutter.
https://pub.dev/packages/toggle_switch
MIT License
113 stars 64 forks source link

Custom Widths not being honored #94

Open PfernFSU opened 3 months ago

PfernFSU commented 3 months ago

Describe the bug The customWidths property is not being honored. I saw this already opened here but they did not give more info. I have a reproducible case (I believe).

To Reproduce

    return ToggleSwitch(
      minWidth: double.maxFinite,
      cornerRadius: 20.0,
      activeFgColor: Theme.of(context).colorScheme.onPrimary,
      inactiveBgColor: Theme.of(context).disabledColor.withAlpha(50),
      inactiveFgColor: Theme.of(context).primaryColor,
      dividerColor: Theme.of(context).primaryColor,
      totalSwitches: 4,
      labels: const ['Game', 'Tournament', 'Chat', ''],
      icons: const [null, null, null, Icons.settings],
      onToggle: (index) {
        debugPrint('The index is $index');
      },
      animate: true,
      customWidths: [65.0, 200.0, 65.0, 50.0],
    );

Expected behavior It seems the width is sometimes expanded, but other times it is ignored. For instance, the one above that is 200, if I change it to 150 it is the same size. 100 is even the same size as all the others. The max width of the screen is 393, so I don't think that is an issue. It is not in any padding, just a column inside a scaffold body.

Screenshots If at 200: image

If at 150: image

If at 65.0 to match the neighbors it does shrink and matches them: image

Additional information

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/justinpfenning/Library/Android/sdk ✗ cmdline-tools component is missing Run path/to/sdkmanager --install "cmdline-tools;latest" See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.91.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.94.0

[✓] Connected device (5 available) • Justin's iPhone 14 (mobile) • 00008110-001044E10C81401E • ios • iOS 17.5.1 21F90 • iPhone 15 Pro (mobile) • 40B59F60-F887-4C6D-A36A-B01D31129D7E • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.2.1 23C71 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.2.1 23C71 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.89

[✓] Network resources • All expected network resources are available.

! Doctor found issues in 1 category.


- Any other additional information.
This is iOS if it makes a difference, running on a iPhone 15 Pro emulator with iOS 17.5
PramodJoshi commented 3 months ago

@PfernFSU great info! Let me do some digging and get back to you. Thanks!

PfernFSU commented 2 months ago

Hey @PramodJoshi - I just wanted to touch base on this and see if you were able to reproduce or troubleshoot. Thanks for everything!