of static method

ChipThemeData of(
  1. BuildContext context
)

Returns the data from the closest ChipTheme instance that encloses the given context.

Defaults to the ambient ThemeData.chipTheme if there is no ChipTheme in the given build context.

link
class Spaceship extends StatelessWidget {
  const Spaceship({super.key});

  @override
  Widget build(BuildContext context) {
    return ChipTheme(
      data: ChipTheme.of(context).copyWith(backgroundColor: Colors.red),
      child: ActionChip(
        label: const Text('Launch'),
        onPressed: () { print('We have liftoff!'); },
      ),
    );
  }
}

See also:

  • ChipThemeData, which describes the actual configuration of a chip theme.

Implementation

static ChipThemeData of(BuildContext context) {
  final ChipTheme? inheritedTheme = context.dependOnInheritedWidgetOfExactType<ChipTheme>();
  return inheritedTheme?.data ?? Theme.of(context).chipTheme;
}