m3eDialogActionScope function

Widget m3eDialogActionScope({
  1. required Color color,
  2. required TextStyle textStyle,
  3. required Color? overlay(
    1. Color color,
    2. Set<WidgetState> states
    ),
  4. required Widget child,
})

Applies the dialog action tokens to text buttons in child.

color drives the label and hover layer; overlay maps states to it.

Implementation

Widget m3eDialogActionScope({
  required Color color,
  required TextStyle textStyle,
  required Color? Function(Color color, Set<WidgetState> states) overlay,
  required Widget child,
}) {
  return M3EButtonDecorationScope(
    styles: const <M3EButtonStyle>{M3EButtonStyle.text},
    decoration: M3EButtonDecoration(
      foregroundColor: WidgetStateProperty.resolveWith(
        (Set<WidgetState> states) =>
            states.contains(WidgetState.disabled) ? null : color,
      ),
      overlayColor: WidgetStateProperty.resolveWith(
        (Set<WidgetState> states) => overlay(color, states),
      ),
      textStyle: textStyle,
    ),
    child: child,
  );
}