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

RadioListTile Theme Property for selected #42621

Closed
workerbee22 opened this issue Oct 13, 2019 · 17 comments
Closed

RadioListTile Theme Property for selected #42621

workerbee22 opened this issue Oct 13, 2019 · 17 comments
Labels
a: quality A truly polished experience f: material design flutter/packages/flutter/material repository. found in release: 1.21 Found to occur in 1.21 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@workerbee22
Copy link

When using RadioListTile it uses a radio Button. But activeColor property doc for this widget says uses the Theme accentColor property by default. Which I think is true.

But if you use controlAffinity property of RadioListTile to put radio button to right side, then the color of the selected item in the list follows the RadioButton activeColor property which defaults to the theme toggleableActiveColor property.

Expected behaviour, both widgets RadioListTile and RadioButton to use the same consistent theme property when no color is provided.

@janmoppel janmoppel added the framework flutter/packages/flutter repository. See also f: labels. label Oct 14, 2019
@janmoppel
Copy link

Hello @workerbee22 !

Thank you for posting an issue.
Can you please also provide the flutter doctor -v output?

@janmoppel janmoppel added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 14, 2019
@workerbee22
Copy link
Author

flutter doctor -v
[✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Mac OS X 10.14.6 18G103, locale en-AU)
    • Flutter version 1.9.1+hotfix.4 at /Users/gamma/Documents/flutter
    • Framework revision cc949a8e8b (2 weeks ago), 2019-09-27 15:04:59 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/gamma/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /Users/gamma/Library/Android/sdk
    • Java binary at: /Applications/Android Studio 3.5 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.1, Build version 11A1027
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio 3.5 Preview.app/Contents
    • Flutter plugin version 40.1.2
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

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

[✓] Connected device (2 available)
    • Nexus 6P                  • CVH7N15A17000241 • android-arm64 • Android 8.1.0 (API 27)
    • Android SDK built for x86 • emulator-5554    • android-x86   • Android 10 (API 29) (emulator)

• No issues found!
gamma (master *) flutterio_2018 $ 

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 14, 2019
@HansMuller HansMuller added the f: material design flutter/packages/flutter/material repository. label Oct 14, 2019
@TahaTesser TahaTesser added the a: quality A truly polished experience label Apr 15, 2020
@AyushBherwani1998
Copy link
Member

When using RadioListTile it uses a radio Button. But activeColor property doc for this widget says uses the Theme accentColor property by default. Which I think is true.

The doc surely mentions that the activeColor defaults to Theme.accentColor which is not true, since only ListTileTheme.selectedColor is defaulted to the Theme.accentColor but activeColor for the Radio is never defaulted to Theme.accentColor.

selectedColor: activeColor ?? Theme.of(context).accentColor,

But if you use controlAffinity property of RadioListTile to put radio button to right side, then the color of the selected item in the list follows the RadioButton activeColor property which defaults to the theme toggleableActiveColor property.

Going through the source code, the controlAffinity won't matter here to change the activeColor, since the ListTileTheme.selectedColor doesn't apply on Radio.

The issue has reproducibile steps here.

SS

@AyushBherwani1998
Copy link
Member

@shihaohong I would like to work on this issue, can we make the activeColor default to Theme.accentColor when creatingn a Radio since the doc mentions, activeColor defaults to accent color of the current Theme ?

@shihaohong
Copy link
Contributor

Based on the name of the properties, I would imagine that toggleableActiveColor would make the most sense as the default. Also, it sounds like this will likely be a breaking change, so it might be worth familiarizing yourself with the policy.

@HansMuller might know more about the history of the different color parameters and which one we should really default to or if we should just keep it as-is and update the API docs.

@AyushBherwani1998
Copy link
Member

@shihaohong Sure, till then I'll go through the breaking change policy.

@AyushBherwani1998
Copy link
Member

AyushBherwani1998 commented Jun 25, 2020

@shihaohong I went through the breaking change policy, and I agree, we can change the ListTileTheme.selectedColor to toggleableActiveColor to have a consist theme because, if activeColor is not null, then it is used for selectedColor instead of accentColor.

@AyushBherwani1998
Copy link
Member

@shihaohong should I create a design document for proposing the change, or wait for the take from @HansMuller on the solution?

@HansMuller
Copy link
Contributor

Sorry about the delay, I'll review this today!

@shihaohong
Copy link
Contributor

I'm going to assign Hans for now just so that there is a reminder for him to provide some feedback when his week starts

@HansMuller
Copy link
Contributor

@shihaohong OK, that worked :-).

This issue depends on the theme's accent color, which is becoming obsolete: https://docs.google.com/document/d/1kzIOQN4QYfVsc5lMZgy_A-FWGXBAJBMySGqZqsJytcE/edit#heading=h.2hl3s1i2nq6o

RadioButton and RadioListTile currently do not conform to the patterns described in the "Theme System Updates" document - flutter.dev/go/material-theme-system-updates. Migrating them will require breaking changes, as Shi Hao pointed out, and will likely require us to update test repo and internal applications. So although this fixing this issue might seem straightforward on the surface, it's likely to be difficult.

@shihaohong
Copy link
Contributor

From Hans' outline, it seems like it will be a multi-step breaking change that would also require a Googler to fix issues that surface in internal applications. That being said, I see two options:

  1. Go through the breaking change process and update RadioListTile to properly use toggleableActiveColor over accentColor, which would reduce some strain on the bigger breaking change. This would require a Googler to be involved since internal repos would need to be fixed to conform to the breaking change.
  2. Make this fix as part of the wider theme updates mentioned in flutter.dev/go/material-theme-system-updates, which would be a larger-scale breaking change.

@AyushBherwani1998
Copy link
Member

I know since this won't priority but if the team decides to go with the first option in the future, I'll be more than happy to contribute if any external contribution required :)

@markusaksli-nc
Copy link
Member

Reproducible on the latest master 1.21.0-2.0.pre.66.

flutter doctor -v
[√] Flutter (Channel master, 1.21.0-2.0.pre.66, on Microsoft Windows [Version 10.0.18362.900], locale et-EE)
   • Flutter version 1.21.0-2.0.pre.66 at C:\Development\flutter_master
   • Framework revision 54c9441723 (3 days ago), 2020-07-17 18:56:12 -0400
   • Engine revision d327828632
   • Dart version 2.9.0 (build 2.9.0-21.0.dev 9dca49e71e)


[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
   • Android SDK at C:\Users\Isa\AppData\Local\Android\sdk
   • Platform android-30, build-tools 30.0.0
   • Java binary at: C:\Users\Isa\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\193.6626763\jre\bin\java
   • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
   • 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.6.4)
   • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
   • Visual Studio Community 2019 version 16.6.30309.148
   • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.0)
   • Android Studio at C:\Users\Isa\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\193.6626763
   • Flutter plugin version 47.1.2
   • Dart plugin version 193.7361
   • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.47.2)
   • VS Code at C:\Users\Isa\AppData\Local\Programs\Microsoft VS Code
   • Flutter extension version 3.12.2

[√] Connected device (5 available)
   • SM G950F (mobile)       • ce12171c51cc001c03 • android-arm64  • Android 9 (API 28)
   • sdk gphone x86 (mobile) • emulator-5554      • android-x86    • Android 11 (API 30) (emulator)
   • Windows (desktop)       • windows            • windows-x64    • Microsoft Windows [Version 10.0.18362.900]
   • Web Server (web)        • web-server         • web-javascript • Flutter Tools
   • Chrome (web)            • chrome             • web-javascript • Google Chrome 84.0.4147.89

• No issues found!

@markusaksli-nc markusaksli-nc added found in release: 1.21 Found to occur in 1.21 has reproducible steps The issue has been confirmed reproducible and is ready to work on labels Jul 20, 2020
@huycozy
Copy link
Member

huycozy commented Nov 3, 2022

Hi @workerbee22
There are changes in the usage of theme colors for accentColor and toggleableActiveColor:

  • @Deprecated(
    'Use colorScheme.secondary instead. '
    'For more information, consult the migration guide at '
    'https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. '
    'This feature was deprecated after v2.3.0-0.1.pre.',
    )
    Color? accentColor,

  • @Deprecated(
    'No longer used by the framework, please remove any reference to it. '
    'For more information, consult the migration guide at '
    'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
    'This feature was deprecated after v3.4.0-19.0.pre.',
    )
    Color? toggleableActiveColor,

Also, when using controlAffinity, RadioListTile keeps using color that is defined in ThemeData, please see in demo and sample code below:

Demo

Screenshot 2022-11-03 at 18 57 57

Sample code
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Application';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      theme: ThemeData(
        accentColor: Colors.red,
        toggleableActiveColor: Colors.green,
        colorScheme: const ColorScheme.light(secondary: Colors.yellow),
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: const MyStatefulWidget(),
      ),
    );
  }
}

/// stateful widget that the main application instantiates
class MyStatefulWidget extends StatefulWidget {
  const MyStatefulWidget({Key? key}) : super(key: key);

  @override
  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}

enum Fruit { apple, banana }

/// private State class that goes with MyStatefulWidget
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  Fruit? _fruit = Fruit.apple;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: <Widget>[
          RadioListTile<Fruit>(
            // activeColor: Colors.red,
            controlAffinity: ListTileControlAffinity.trailing,
            title: const Text('Apple'),
            value: Fruit.apple,
            groupValue: _fruit,
            onChanged: (Fruit? value) {
              setState(() {
                _fruit = value;
              });
            },
          ),
          RadioListTile<Fruit>(
            // activeColor: Colors.red,
            title: const Text('Banana'),
            value: Fruit.banana,
            groupValue: _fruit,
            onChanged: (Fruit? value) {
              setState(() {
                _fruit = value;
              });
            },
          ),
        ],
      ),
    );
  }
}
flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.3.7, on macOS 13.0 22A380 darwin-x64, locale en-VN)
    • Flutter version 3.3.7 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e99c9c7cd9 (27 hours ago), 2022-11-01 16:59:00 -0700
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode14.0.1.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.3)
    • 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.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2022.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 70.0.5
    • Dart plugin version 222.4167.21

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

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 12 (API 31)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 13.0 22A380 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 107.0.5304.87

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
[!] Flutter (Channel master, 3.5.0-12.0.pre.93, on macOS 13.0 22A380 darwin-x64, locale en-VN)
    • Flutter version 3.5.0-12.0.pre.93 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 92a66683a1 (6 hours ago), 2022-11-02 16:50:38 -0400
    • Engine revision 840a7b3462
    • Dart version 2.19.0 (build 2.19.0-364.0.dev)
    • DevTools version 2.19.0
    • 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 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode14.0.1.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.3)
    • 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.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2022.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 70.0.5
    • Dart plugin version 222.4167.21

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

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 12 (API 31)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 13.0 22A380 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 107.0.5304.87

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

Please retry and confirm again. Thanks!

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 3, 2022
@github-actions
Copy link

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

@github-actions
Copy link

github-actions bot commented Mar 5, 2023

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 Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: quality A truly polished experience f: material design flutter/packages/flutter/material repository. found in release: 1.21 Found to occur in 1.21 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

8 participants