Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thumbColor & focusColor aren't provided to Cupertino variant of Switch.adaptive #126669

Closed
2 tasks done
TahaTesser opened this issue May 12, 2023 · 3 comments · Fixed by #126688
Closed
2 tasks done

thumbColor & focusColor aren't provided to Cupertino variant of Switch.adaptive #126669

TahaTesser opened this issue May 12, 2023 · 3 comments · Fixed by #126688
Assignees
Labels
f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on

Comments

@TahaTesser
Copy link
Member

TahaTesser commented May 12, 2023

Is there an existing issue for this?

Steps to reproduce

  1. Run the code sample which contains:
  • Switch
  • Switch.adaptive (Android)
  • CupertinoSwitch
  • Switch. adaptive (iOS)
  1. The sample provides thumbColor and focusColor to all switch versions.

Expected results

Provided thumbColor & focusColor are applied to all variants

Screenshot 2023-05-12 at 16 09 13

Actual results

Cupertino variant of Switch.adaptive doesn't use provided thumbColor & focusColor

Screenshot 2023-05-12 at 15 40 50

Code sample

Code sample
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _switchValue = false;
  final Color _thumbColor = Colors.redAccent;
  final Color _focusColor = Colors.yellow;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Column(
                    children: <Widget>[
                      const Text('Switch'),
                      const SizedBox(height: 5),
                      Switch(
                        value: _switchValue,
                        thumbColor:
                            MaterialStatePropertyAll<Color?>(_thumbColor),
                        focusColor: _focusColor,
                        onChanged: (bool value) {
                          setState(() {
                            _switchValue = value;
                          });
                        },
                      ),
                      Theme(
                        data: ThemeData(
                          platform: TargetPlatform.android,
                          useMaterial3: true,
                        ),
                        child: Column(
                          children: <Widget>[
                            const Text('Switch.adaptive (Android)'),
                            const SizedBox(height: 5),
                            Switch.adaptive(
                              value: _switchValue,
                              thumbColor:
                                  MaterialStatePropertyAll<Color?>(_thumbColor),
                              focusColor: _focusColor,
                              onChanged: (bool value) {
                                setState(() {
                                  _switchValue = value;
                                });
                              },
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                  Column(
                    children: <Widget>[
                      const Text('CupertinoSwitch'),
                      const SizedBox(height: 5),
                      CupertinoSwitch(
                        value: _switchValue,
                        thumbColor: _thumbColor,
                        focusColor: _focusColor,
                        onChanged: (bool value) {
                          setState(() {
                            _switchValue = value;
                          });
                        },
                      ),
                      Theme(
                        data: ThemeData(
                          platform: TargetPlatform.iOS,
                          useMaterial3: true,
                        ),
                        child: Column(
                          children: <Widget>[
                            const Text('Switch.adaptive (iOS)'),
                            const SizedBox(height: 5),
                            Switch.adaptive(
                              value: _switchValue,
                              thumbColor:
                                  MaterialStatePropertyAll<Color?>(_thumbColor),
                              focusColor: _focusColor,
                              onChanged: (bool value) {
                                setState(() {
                                  _switchValue = value;
                                });
                              },
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

No response

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[!] Flutter (Channel master, 3.11.0-5.0.pre.49, on macOS 13.3.1 22E772610a
    darwin-arm64, locale en-EE)
    • Flutter version 3.11.0-5.0.pre.49 on channel master at
      /Users/tahatesser/Code/flutter
    ! Upstream repository git@github.com:TahaTesser/flutter.git is not the same
      as FLUTTER_GIT_URL
    • FLUTTER_GIT_URL = git@github.com:NevercodeHQ/flutter.git
    • Framework revision 4eefced8bc (5 hours ago), 2023-05-12 01:05:20 -0700
    • Engine revision ef5c349f04
    • Dart version 3.1.0 (build 3.1.0-94.0.dev)
    • DevTools version 2.23.1
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/tahatesser/Code/android-sdk
    • Platform android-33, build-tools 33.0.2
    • ANDROID_SDK_ROOT = /Users/tahatesser/Code/android-sdk
    • Java binary at: /Applications/Android Studio
      Preview.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.0

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

[✓] Android Studio
    • Android Studio at /Applications/Android Studio Preview.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
      17.0.6+0-17.0.6b829.9-10027231)

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

[✓] VS Code (version 1.79.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.3.1 22E772610a
      darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 113.0.5672.92

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

! Doctor found issues in 1 category.
@TahaTesser TahaTesser added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: cupertino flutter/packages/flutter/cupertino repository has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 labels May 12, 2023
@TahaTesser TahaTesser self-assigned this May 12, 2023
@github-project-automation github-project-automation bot moved this to To do in Nevercode May 12, 2023
@leighajarett
Copy link
Contributor

Thanks for flagging this @TahaTesser!

@TahaTesser
Copy link
Member Author

@leighajarett
I noticed this issue while fixing #126637.

@TahaTesser TahaTesser moved this from To do to In progress in Nevercode May 12, 2023
@TahaTesser TahaTesser moved this from In progress to PR submitted in Nevercode May 12, 2023
@github-project-automation github-project-automation bot moved this from PR submitted to Done (PR merged) in Nevercode May 12, 2023
auto-submit bot pushed a commit that referenced this issue May 12, 2023
…to Cupertino variant of `Switch.adaptive` (#126688)

fixes #126637
fixes #126669

##  ~~To be merged after #126684

### Description

1.  Fix the Cupertino variant of `Switch.adaptive` requires two tab key presses to focus.
2.  Fix `thumbColor` & `focusColor` aren't applied.

### Before
Requires two tab presses to focus. and `thumbColor` & `focusColor` aren't applied.

https://github.com/flutter/flutter/assets/48603081/24635551-0794-443f-8320-32fdaa5de57a

### After
Single tab key to focus (no additional focus node) and `thumbColor` & `focusColor` are applied.

https://github.com/flutter/flutter/assets/48603081/9bf42fd8-c7e0-475a-b933-192a94650b0c
CaseyHillers pushed a commit to CaseyHillers/flutter that referenced this issue May 24, 2023
…to Cupertino variant of `Switch.adaptive` (flutter#126688)

fixes flutter#126637
fixes flutter#126669

##  ~~To be merged after flutter#126684

### Description

1.  Fix the Cupertino variant of `Switch.adaptive` requires two tab key presses to focus.
2.  Fix `thumbColor` & `focusColor` aren't applied.

### Before
Requires two tab presses to focus. and `thumbColor` & `focusColor` aren't applied.

https://github.com/flutter/flutter/assets/48603081/24635551-0794-443f-8320-32fdaa5de57a

### After
Single tab key to focus (no additional focus node) and `thumbColor` & `focusColor` are applied.

https://github.com/flutter/flutter/assets/48603081/9bf42fd8-c7e0-475a-b933-192a94650b0c
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. found in release: 3.10 Found to occur in 3.10 found in release: 3.11 Found to occur in 3.11 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on
Projects
Status: Done (PR merged)
2 participants