• asci's avatar
    [docs] Add document content related to chip shape (#140015) · 3b7ed000
    asci authored
    (#139572)  I would like to request an update to the document to resolve confusion.
    I actually modified the code by applying priority as in the comment in [#139572](https://github.com/flutter/flutter/issues/139572) as shown below, but I thought that if 'OutlinedBorder' was used for 'shape', the default value of side for 'OutlinedBorder' was also the developer's intention.
    
    ```
    OutlinedBorder _getShape(ThemeData theme, ChipThemeData chipTheme, ChipThemeData chipDefaults) {
      final BorderSide? resolvedSide =
          MaterialStateProperty.resolveAs<BorderSide?>(widget.side, materialStates)
              ?? MaterialStateProperty.resolveAs<BorderSide?>(chipTheme.side, materialStates);
      final BorderSide? resolvedShapeSide =
          MaterialStateProperty.resolveAs<BorderSide?>(widget.shape?.side, materialStates)
              ?? MaterialStateProperty.resolveAs<BorderSide?>(chipTheme.shape?.side, materialStates);
      final OutlinedBorder resolvedShape =
          MaterialStateProperty.resolveAs<OutlinedBorder?>(widget.shape, materialStates)
              ?? MaterialStateProperty.resolveAs<OutlinedBorder?>( chipTheme.shape, materialStates)
              ?? MaterialStateProperty.resolveAs<OutlinedBorder?>(chipDefaults.shape, materialStates)
              // TODO(tahatesser): Remove this fallback when Material 2 is deprecated.
              ?? const StadiumBorder();
      // If the side is provided, shape uses the provided side.
    
      if (resolvedSide != null) {
        return resolvedShape.copyWith(side: resolvedSide);
      }
      if (resolvedShapeSide != null) {
        return resolvedShape.copyWith(side: resolvedShapeSide);
      }
      // If the side is not provided
      // then the shape's side is used. Otherwise, the default side is used.
      return resolvedShape.copyWith(side: chipDefaults.side);
    }
    ```
    (in `chip.dart`)
    
    However, (#133856)  PR seems to be intended to ignore this and use the aspect of `chipDefault.side` even if the developer specifies `shape.side` as [Border.none] without explicitly applying `side` .
    This is probably because the default value of OutlinedBorder is [Border.none].
    I think this is an area that can cause enough confusion, but there are a lot of things that need to be modified to reduce confusion through code changes, and the impact on existing code is likely to be significant.
    I also confirmed that this is not accurately explained in the API Docs.
    So rather than modifying the code, I decided to add additional explanation to the `shape` comment.
    If the results are different from what you intended or the updated content is strange, please review. 🙏
    3b7ed000
Name
Last commit
Last update
..
lib Loading commit data...
test Loading commit data...
test_fixes Loading commit data...
test_private Loading commit data...
test_profile Loading commit data...
test_release Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
analysis_options.yaml Loading commit data...
build.yaml Loading commit data...
dart_test.yaml Loading commit data...
pubspec.yaml Loading commit data...