title: Why is my switch widget not sliding? I can't seem to change themes
body: <p>I can't seem to figure out what is preventing the switch from changing states. I know if I set isDark to true, I get my dark theme, and if I set isDark to false I get my light theme. It might be possible that flutter is interpreting isDark as constantly being false. However, I am unsure as to how to fix that if that were the case. Regardless, something is stopping the switch and I can't figure it out. Any help is appreciated thank you.</p>
  <pre><code> import 'package:flutter/material.dart';
      
      void main() {
        runApp(MyApp());
      }
      
      class MyApp extends StatelessWidget {
        @override
        Widget build(BuildContext context) {
          return MaterialApp(
            home: ChangeThemeButton(),
            theme: _theme,
            // theme: MyThemes.lightTheme,
            // darkTheme: MyThemes.darkTheme,
            // themeMode: ThemeMode.system,
            routes: {
              'homepage': (context) =&gt; HomePage(),
              'sign-in': (context) =&gt; SignIn(),
              'register': (context) =&gt; RegisterPage(),
            },
          );
        }
      }
      
      class ChangeThemeButton extends StatefulWidget {
        @override
        _ChangeThemeButtonState createState() =&gt; _ChangeThemeButtonState();
      }
      
      
      class _ChangeThemeButtonState extends State&lt;ChangeThemeButton&gt; {
        @override
        Widget build(BuildContext context) {
          return Scaffold(
            body: Center(
              child: Switch(
                value: isDark,
                onChanged: (val) =&gt; {
                  setState((){
                    val = isDark;
                    themeProvider(val);
                  })
                },
              ),
            ),
          );
        }
      }
      
      var _theme = (isDark == false) ? MyThemes.lightTheme : MyThemes.darkTheme;
      bool val;
      bool isDark = false;
      
      bool themeProvider (bool val) {
        switch (val) {
          case false:
            return isDark == true;
            break;
          case true:
            return isDark == false;
            break;
        }
        return null;
      }
      
      class MyThemes {
        static final lightTheme = ThemeData(
            colorScheme: ColorScheme.light(),
            iconTheme: IconThemeData(color: Colors.black),
            bottomNavigationBarTheme: BottomNavigationBarThemeData(
              unselectedItemColor: Colors.white,
              selectedItemColor: Color(0xff9D4C8F),
              showUnselectedLabels: true,
              selectedIconTheme: IconThemeData(
                color: Color(0xff9D4C8F),
              ),
              unselectedIconTheme: IconThemeData(
                color: Colors.white,
              ),
            ),
            primaryColor: Colors.deepPurpleAccent[100],
            primaryColorDark: Colors.black54,
            secondaryHeaderColor: Colors.deepPurpleAccent[50],
            scaffoldBackgroundColor: Colors.white,
            cardColor: Colors.deepPurpleAccent,
            cardTheme: CardTheme(elevation: 5));
      
        static final darkTheme = ThemeData(
            colorScheme: ColorScheme.dark(),
            iconTheme: IconThemeData(color: Colors.white),
            bottomNavigationBarTheme: BottomNavigationBarThemeData(
              unselectedItemColor: Colors.white38,
              selectedItemColor: Color(0xff9D4C8F),
              showUnselectedLabels: true,
              selectedIconTheme: IconThemeData(
                color: Color(0xff9D4C8F),
              ),
              unselectedIconTheme: IconThemeData(
                color: Colors.white,
              ),
            ),
            primaryColor: Colors.black,
            primaryColorDark: Colors.grey,
            secondaryHeaderColor: Colors.deepPurpleAccent[50],
            scaffoldBackgroundColor: Colors.white38,
            cardColor: Colors.deepPurpleAccent,
            cardTheme: CardTheme(elevation: 5)
        );
      }
  </code></pre>