maxim-saplin / data_table_2

In-place substitute for Flutter's DataTable and PaginatedDataTable with fixed/sticky header and extra features
https://pub.dev/packages/data_table_2
BSD 3-Clause "New" or "Revised" License
202 stars 135 forks source link

DataRow2 decoration property improvement #262

Open npateras opened 6 months ago

npateras commented 6 months ago

Please make it so the decoration property in DataRow2 to be able to take MaterialStateProperty similar to color.

Reason: So I came across a problem and I couldn't figure out how to do it with DataTable. I wanted when hovering over a row to show a color around the row. Now you might think this can be achieved with color property, and you are right, but not quite because I wanted the hovered color to have a corner radius! Which can be achieved with decoration, but decoration doesn't have MaterialStateProperty. Additionally, there could be an option to add an animation when the hover effect appears.

maxim-saplin commented 5 months ago

Can you demonstrate it in a picture?

npateras commented 5 months ago

So in DataRow2, you can set a color with MaterialStateProperty which changes the background color of the row when hovering over using the hover property of MaterialStateProperty. Now I am asking if it's possible to be done for decoration too so we can have rounded corners instead, like this:

Current: Left, Suggestion: Right image

Code example:

DataRow2(
    decoration: MaterialStateProperty.resolveWith(
        if (states.contains(MaterialState.hovered)) {
            return Container(color: Colors.grey)
        }
    )
)