of method

ChipThemeData of (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.

class Spaceship extends StatelessWidget {
  @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.inheritFromWidgetOfExactType(ChipTheme);
  return inheritedTheme?.data ?? Theme.of(context).chipTheme;
}