fix: replace deprecated primaryColor with colorScheme.primary for default activeBgColor#103
Open
Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Open
fix: replace deprecated primaryColor with colorScheme.primary for default activeBgColor#103Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates ToggleSwitch’s default active background color fallback to avoid Flutter 3.x deprecation warnings by switching from Theme.of(context).primaryColor to Theme.of(context).colorScheme.primary, aligning the widget with Material color schemes.
Changes:
- Replace deprecated
Theme.of(context).primaryColorfallback withTheme.of(context).colorScheme.primaryforactiveBgColor. - Update the adjacent inline documentation comment to match the new source of the fallback color.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Theme.of(context).primaryTextTheme.bodyLarge!.color; | ||
|
|
||
| /// Assigns active background color to default primary theme color if it's null/not provided. | ||
| /// Assigns active background color to default primary color scheme if it's null/not provided. |
There was a problem hiding this comment.
Doc comment is a bit ambiguous: this fallback uses Theme.of(context).colorScheme.primary (a color), not a “primary color scheme”. Consider rephrasing to explicitly mention the theme’s colorScheme.primary (or “primary color from the color scheme”).
Suggested change
| /// Assigns active background color to default primary color scheme if it's null/not provided. | |
| /// Assigns active background color to the theme's `colorScheme.primary` | |
| /// if it's null/not provided. |
…ault activeBgColor ## Problem The fallback active background color used `Theme.of(context).primaryColor`, which was deprecated in Flutter 3.x. This caused deprecation warnings and could produce unexpected colors depending on the theme configuration. ## Solution Replace `Theme.of(context).primaryColor` with `Theme.of(context).colorScheme.primary`, aligning with the modern Material Design 3 color system. ## Changes - lib/toggle_switch.dart: updated default activeBgColor fallback to use `colorScheme.primary` Fixes PramodJoshi#100
fba0cc7 to
0d1f550
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The fallback active background color used
Theme.of(context).primaryColor, which was deprecated in Flutter 3.x. This caused deprecation warnings and could produce unexpected colors depending on the theme configuration.Solution
Replace
Theme.of(context).primaryColorwithTheme.of(context).colorScheme.primary, aligning with the modern Material Design 3 color system.Changes
colorScheme.primaryFixes #100