Closed RebecaMPS closed 2 years ago
this can be solucionate assign your variable to initialLabelIndex
ToggleSwitch( minWidth: 150, initialLabelIndex: faceToFace, totalSwitches: 2, labels: const ['FACE-TO_FACE', 'NON-FACE-TO_FACE'], onToggle: (index) { print('switched to: $index'); setState(() { faceToFace= index!; }); }, )
Describe the bug A clear and concise description of what the bug is. I need to change the value of a variable (to show/hide options) when the user presses the Toggle.
To Reproduce Complete runnable code to reproduce the bug/issue.
Expected behavior A clear and concise description of what you expected to happen. The visual change is expected to act as normal, the same as when the "SetState" is not included
Screenshots If applicable, add screenshots to help explain your problem.
Additional information
toggle_switch
version -> toggle_switch 2.0.1flutter doctor -v
[√] Flutter (Channel dev, 2.11.0-0.1.pre, on Microsoft Windows [Versión 10.0.22000.613], locale es-ES) • Flutter version 2.11.0-0.1.pre at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b101bfe32f (3 months ago), 2022-02-16 07:36:54 -0800 • Engine revision e355993572 • Dart version 2.17.0 (build 2.17.0-69.2.beta) • DevTools version 2.10.0-dev.1
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\Rebeca\AppData\Local\Android\sdk • Platform android-31, build-tools 30.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted.
[√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.5.5) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.5.30104.148 • Windows 10 SDK version 10.0.18362.0
[√] Android Studio (version 2020.3) • Android Studio at C:\Program Files\Android\Android Studio • 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.10+0-b96-7249189)
[√] VS Code (version 1.65.1) • VS Code at C:\Users\Rebeca\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.38.1
[√] Connected device (4 available) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Versión 10.0.22000.613] • Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.75 • Edge (web) • edge • web-javascript • Microsoft Edge 99.0.1150.52
[√] HTTP Host Availability • All required HTTP hosts are available
• No issues found!