Skip to content

fix: replace deprecated primaryColor with colorScheme.primary for default activeBgColor#103

Open
Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Vasusn:fix/issue-100-colorscheme-primary
Open

fix: replace deprecated primaryColor with colorScheme.primary for default activeBgColor#103
Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Vasusn:fix/issue-100-colorscheme-primary

Conversation

@Vasusn
Copy link
Copy Markdown

@Vasusn Vasusn commented Apr 26, 2026

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 #100

Copilot AI review requested due to automatic review settings April 26, 2026 09:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).primaryColor fallback with Theme.of(context).colorScheme.primary for activeBgColor.
  • 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.

Comment thread lib/toggle_switch.dart Outdated
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.
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
…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
@Vasusn Vasusn force-pushed the fix/issue-100-colorscheme-primary branch from fba0cc7 to 0d1f550 Compare April 26, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request a color scheme change

2 participants