Skip to content

Add support to set background color of SnackBarAction when clicked #109933

@akshdeep-singh

Description

@akshdeep-singh

Use case

The background color for SnackBarAction should be allowed to change when SnackBarAction.textColor is set to some custom color.

For example, in below code, I have set textColor to Colors.green, and I want the background color (blue in the image) to be set to green with some alpha value.

ScaffoldMessenger.of(context).showSnackBar(
  SnackBar(
    content: const Text('Awesome Snackbar!'),
    action: SnackBarAction(
      label: 'Action',
      onPressed: () {
        // Code to execute.
      },
      textColor: Colors.green,
    ),
  ),
);

Screenshot_1661040438

Proposal

I can think of 2 options:

  1. Add a parameter to SnackBarAction which can be used to set the background color.
  2. When SnackBarAction.textColor is set, then set the background color to some alpha value of this textColor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions