Skip to content

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

@TahaTesser

Description

@TahaTesser

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.

Metadata

Metadata

Assignees

Labels

f: cupertinoflutter/packages/flutter/cupertino repositoryf: material designflutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions