question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flet ```MaterialState``` in ```ButtonStyle``` throws a TypeError

See original GitHub issue

When setting the style properties for a TextButton,MaterialState throws a type error. I was able to replicate the same with example provided in the docs.

app.py

style = ft.ButtonStyle(
    color = {
        ft.MaterialState.DEFAULT: ft.colors.WHITE,
        ft.MaterialState.HOVERED: ft.colors.LIGHT_BLUE,
    },
    bgcolor = {
        ft.MaterialState.FOCUSED: ft.colors.LIGHT_BLUE
    }
)

error

TypeError: keys must be str, int, float, bool or None, not MaterialState

Flet 0.2.4 Windows 11

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ndonkoHenricommented, Dec 8, 2022

Hum, Just had thesame issue. instead of ft.MaterialState.DEFAULT for example, you need to use ft.MaterialState.DEFAULT.value

After this change it should work now…

0reactions
FeodorFitsnercommented, Dec 8, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is MaterialStateProperty<Color>? - flutter - Stack Overflow
Interface for classes that resolve to a value of type T based on a widget's interactive "state", which is defined as a set...
Read more >
ButtonStyle class - material library - Flutter - Dart API docs
Buttons and their themes have a ButtonStyle property which defines the visual properties whose default values are to be overridden.
Read more >
ElevatedButton - Flet
ButtonStyle allows controling all visual aspects of a button, such as shape, foreground, background and shadow colors, content padding, border width and radius....
Read more >
Flutter Skill of ButtonStyle And MaterialStateProperty - Medium
When Google makes the UI response of MaterialState to the Widget, it also follows the design specifications of Material Design, such as the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found