You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ff-concepts/adding-customization/common-examples.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ When referencing a Component class in your code, FlutterFlow will automatically
63
63
64
64
When building custom widgets, you often need to style parts of the widget, such as setting colors. Instead of using hardcoded color values, you can directly access the **FlutterFlow Theme**. This theme provides consistent styling across your app and reflects colors set by you or your project developer.
65
65
66
-
To access theme colors in your custom widget, use the `FlutterFlowTheme.of(context)` method. This allows you to retrieve any theme color, such as the **primary color, accent color**, or **background color**, ensuring that your custom widget aligns with the app’s overall theme.
66
+
To access theme colors in your custom widget, use the `FlutterFlowTheme.of(context)` method. This allows you to retrieve any theme property, such as the default `primary`, `primaryBackground`, or other custom-created colors, as well as text styles like `bodyLarge` or `bodyMedium`, ensuring that your custom widget aligns with the app’s overall theme.
67
67
68
68
Here’s an example of how to use the primary color from FlutterFlow Theme in a custom widget:
69
69
@@ -95,10 +95,10 @@ class _CustomButtonState extends State<CustomButton> {
95
95
Widget build(BuildContextcontext) {
96
96
returnElevatedButton(
97
97
style:ElevatedButton.styleFrom(
98
-
primary: isPressed
98
+
backgroundColor: isPressed
99
99
?FlutterFlowTheme.of(context).primary// Primary color when pressed
100
100
:FlutterFlowTheme.of(context).secondaryBackground, // Default color
101
-
onPrimary:FlutterFlowTheme.of(context).secondaryText, // Text color
101
+
foregroundColor:FlutterFlowTheme.of(context).secondaryText, // Text color
102
102
),
103
103
onPressed: toggleButton,
104
104
child:Text(
@@ -109,7 +109,8 @@ class _CustomButtonState extends State<CustomButton> {
0 commit comments