Skip to content

Add BorderRadiusGeometry Support to Divider Widget for Customizable Border Radius #162239

@walid-ashik

Description

@walid-ashik

Use case

I can't set border radius to divider. this is necessary when you have a thick rounded border and almost all the cases, if you have a thick divider, you might have some corner radius. In this below SS, see that the edges are very sharp and there's no default way to make divider edge's rounded.
Image
this is the code that produces above divider,

Divider(
  indent: 200,
  endIndent: 200,
  height: 40,
  thickness: 5,
  color: Colors.grey,
)

Proposal

Add an way to pass the BorderRadiusGeometry to the divider as it's used a Container to construct the divider. So, this radius geometry value will pass to the Container's BoxDecoration field. something like this,

    @override
    Widget build(BuildContext context) {
      final ThemeData theme = Theme.of(context);
      final DividerThemeData dividerTheme = DividerTheme.of(context);
      final DividerThemeData defaults =
          theme.useMaterial3 ? _DividerDefaultsM3(context) : _DividerDefaultsM2(context);
      final double height = this.height ?? dividerTheme.space ?? defaults.space!;
      final double thickness = this.thickness ?? dividerTheme.thickness ?? defaults.thickness!;
      final double indent = this.indent ?? dividerTheme.indent ?? defaults.indent!;
      final double endIndent = this.endIndent ?? dividerTheme.endIndent ?? defaults.endIndent!;
  
      return SizedBox(
        height: height,
        child: Center(
          child: Container(
            height: thickness,
            margin: EdgeInsetsDirectional.only(start: indent, end: endIndent),
            decoration: BoxDecoration(
+             borderRadius: radius,
              border: Border(bottom: createBorderSide(context, color: color, width: thickness)),
            ),
          ),
        ),
      );
    }

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions