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

Cannot apply theme for text of button using ButtonThemeData #29728

Closed
trietbui85 opened this issue Mar 21, 2019 · 4 comments
Closed

Cannot apply theme for text of button using ButtonThemeData #29728

trietbui85 opened this issue Mar 21, 2019 · 4 comments
Labels
a: quality A truly polished experience f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@trietbui85
Copy link

I want to use ButtonThemeData for not only for button theme but also for text theme (which is the child of that button). However I notice it only take effect on button, but not text.

Steps to Reproduce

  1. Here is source code
return MaterialApp(
      title: 'FileString demo',
      theme: ThemeData(
          primaryColor: Color(0xff2B5A95),
          buttonTheme: ButtonThemeData(
            buttonColor: Color(0xff9DCB3B),
            textTheme: ButtonTextTheme.primary,
          )),
  1. After reading source code of ButtonThemeData, I see we're allowed to theme text to some predefined colors such as ButtonTextTheme.primary, normal or accent. However I myself want to control its style (text color, text size) instead. Is it possible?

Logs

[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 6.1.7601], locale en-US)
    • Flutter version 1.2.1 at C:\DevTools\flutter
    • Framework revision 8661d8aecd (5 weeks ago), 2019-02-14 19:19:53 -0800
    • Engine revision 3757390fa4
    • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\DevTools\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = C:\DevTools\Android\sdk
    • Java binary at: C:\DevTools\Android\studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.3)
    • Android Studio at C:\DevTools\Android\studio
    • Flutter plugin version 33.4.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] IntelliJ IDEA Community Edition (version 2018.2)
    • IntelliJ at C:\Users\TrietBui\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\182.4892.20
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.io/intellij-setup/#installing-the-plugins

[√] Connected device (1 available)
    • SM G960F • 1ca85fd0cb0c7ece • android-arm64 • Android 9 (API 28)
@esarbanis
Copy link
Contributor

For a RaisedButton you can only get Colors.white or Colors.black depending on the brightness of the fill color. Check out getTextColor method.

The only way I see to override it is from the RaisedButton.textColor property.

A workaround could be to introduce a common widget for the button and use that throughout your application.

@HansMuller HansMuller added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Mar 21, 2019
@duzenko

This comment has been minimized.

@HansMuller
Copy link
Contributor

@anticafe, @esarbanis, @duzenko it's been a long time since issue was opened and I apologize for the lack of activity. If you're still interested in the topic, there's a wide-ranging proposal for updating the button widgets and their themes in #54776. The new proposal does bind the default button colors to the overall theme's ColorSchme, per the Material Design spec. It also addresses the difficult of defining the default button text color.

I'm going to close this issue in favor of #54776.

@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 Aug 22, 2021
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. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests

5 participants