-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add FloatingActionButtonTheme #179736
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
Add FloatingActionButtonTheme #179736
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces FloatingActionButtonTheme, an InheritedTheme that allows for theming FloatingActionButton widgets within a subtree. This is a standard pattern in Flutter and brings FloatingActionButton in line with other Material components that have their own theme widgets. The implementation correctly uses dependOnInheritedWidgetOfExactType and falls back to Theme.of(context).floatingActionButtonTheme. The documentation for FloatingActionButton and FloatingActionButtonThemeData has been updated to reflect this change. Two new tests have been added to verify the behavior of the new theme, ensuring that it overrides the app-level theme and that widget-level properties take precedence. The changes are well-implemented and follow existing conventions in the Flutter framework.
packages/flutter/test/material/floating_action_button_theme_test.dart
Outdated
Show resolved
Hide resolved
6541307 to
d5be232
Compare
QuncCccccc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
| const FloatingActionButtonTheme({super.key, this.data, required super.child}); | ||
|
|
||
| /// The properties for descendant [FloatingActionButton] widgets. | ||
| final FloatingActionButtonThemeData? data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any cases that data might be null? I'm thinking maybe we can just make the type be FloatingActionButtonThemeData.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh very good catch!
I used MaterialBannerTheme as an inspiration when writing this PR and I just realized that it is the only theme where data is nullable. Probably by mistake.
|
|
||
| await tester.pumpWidget( | ||
| MaterialApp( | ||
| theme: ThemeData().copyWith( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
| theme: ThemeData().copyWith( | |
| theme: ThemeData( |
91f3124 to
c3b7c9b
Compare
c3b7c9b to
2b321e0
Compare
Description
This PR adds the
FloatingActionButtonThemesubclass of InheritedTheme. Similarly to other theme classes.This missing theme class was mentioned in flutter.dev/go/material-theme-system-updates:
"FloatingActionButtonThemeData is conformant but there’s no FloatingActionButtonTheme class. "
Related Issue
Fixes Missing FloatingActionButtonTheme
Tests
Adds 2 tests.