resolveWith method Null safety

MaterialStateBorderSide resolveWith(
  1. MaterialPropertyResolver<BorderSide?> callback
)
override

Creates a MaterialStateBorderSide from a MaterialPropertyResolver<BorderSide?> callback function.

If used as a regular BorderSide, the border resolved in the default state (the empty set of states) will be used.

Usage:

ChipTheme(
  data: Theme.of(context).chipTheme.copyWith(
    side: MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
      if (states.contains(MaterialState.selected)) {
        return const BorderSide(width: 1, color: Colors.red);
      }
      return null;  // Defer to default value on the theme or widget.
    }),
  ),
  child: Chip(),
)

// OR

Chip(
  ...
  side: MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
    if (states.contains(MaterialState.selected)) {
      return const BorderSide(width: 1, color: Colors.red);
    }
    return null;  // Defer to default value on the theme or widget.
  }),
)

Implementation

static MaterialStateBorderSide resolveWith(MaterialPropertyResolver<BorderSide?> callback) =>
    _MaterialStateBorderSide(callback);