Skip to content

Commit 6e5d1de

Browse files
committed
call out custom colors and text styles from theme
1 parent 13260f3 commit 6e5d1de

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/ff-concepts/adding-customization/common-examples.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ When referencing a Component class in your code, FlutterFlow will automatically
6363

6464
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.
6565

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.
6767

6868
Here’s an example of how to use the primary color from FlutterFlow Theme in a custom widget:
6969

@@ -95,10 +95,10 @@ class _CustomButtonState extends State<CustomButton> {
9595
Widget build(BuildContext context) {
9696
return ElevatedButton(
9797
style: ElevatedButton.styleFrom(
98-
primary: isPressed
98+
backgroundColor: isPressed
9999
? FlutterFlowTheme.of(context).primary // Primary color when pressed
100100
: FlutterFlowTheme.of(context).secondaryBackground, // Default color
101-
onPrimary: FlutterFlowTheme.of(context).secondaryText, // Text color
101+
foregroundColor: FlutterFlowTheme.of(context).secondaryText, // Text color
102102
),
103103
onPressed: toggleButton,
104104
child: Text(
@@ -109,7 +109,8 @@ class _CustomButtonState extends State<CustomButton> {
109109
}
110110
}
111111
```
112-
112+
:::info
113+
Find the list of colors,
113114

114115
### Manipulating AppState from Custom Code
115116

0 commit comments

Comments
 (0)