Skip to content

🐛 ButtonStyle.textStyle is not applied to button's Text child #1318

@jacksonb-cs

Description

@jacksonb-cs

Describe the bug
Giving a ButtonStyle to either Button or FilledButton does not have any effect on descendent Text widgets. It is also not applied if the ButtonStyle is defined in the app's top-level theme data.

I have encountered this behavior on fluent_ui v4.15.1 and v4.13.0

To Reproduce
Here is a minimally-reproduceable code sample.

import 'package:fluent_ui/fluent_ui.dart';

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

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return FluentApp(
      home: ScaffoldPage(
        content: Center(
          child: FilledButton(
            style: ButtonStyle(
              textStyle: WidgetStatePropertyAll(TextStyle(color: Colors.black)),
            ),
            onPressed: () {},
            child: const Text('Press Me'),
          ),
        ),
      ),
    );
  }
}

In this example, I would expect the button's text to be black, but it stays the default color of white.

Expected behavior
I expect to be able to give my app's top-level theme data a ButtonStyle with a specified ButtonStyle.textStyle that is applied to the buttons' descendent text. This bug prevents me from easily and consistently theming my app's buttons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions