Articles in this section
Category / Section

How to disable the outer border in the Flutter DataGrid?

2 mins read

In this article, we will show you how to disable the outer border in the Flutter DataGrid.

Initialize the SfDataGrid widget with all the required properties. Use the ClipRect widget along with a custom clipper (CustomClipper) to remove the outer borders. To achieve this, create a custom clipper class by extending the CustomClipper class. In the getClip method, use Rect.fromLTWH to set the grid line stroke width for the left and top sides, and specify the appropriate size for the right and bottom sides based on the grid layout. After defining this custom clipper, wrap the SfDataGrid with the ClipRect widget to control the visibility of the borders as desired.

 @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Flutter SfDataGrid'),
        ),
        body: ClipRect(
          clipper: CustomLeftClipper(),
          child: SfDataGrid(
            columnWidthMode: ColumnWidthMode.fill,
            source: _employeeDataSource,
            gridLinesVisibility: GridLinesVisibility.both,
            headerGridLinesVisibility: GridLinesVisibility.both,
            columns: getColumns,
          ),
        ));
  }

class CustomLeftClipper extends CustomClipper<Rect> {
  @override
  Rect getClip(Size size) {
    return Rect.fromLTWH(2, 2, size.width - 4, size.height - 58);
  }

  @override
  bool shouldReclip(CustomClipper<Rect> oldClipper) => false;
}

View the GitHub sample here.

Conclusion

I hope you enjoyed learning about how to disable the outer border in the Flutter DataGrid.

You can refer to our Flutter DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Flutter DataGrid example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied