user3808307
user3808307

Reputation: 1471

Wrap TableRow in InkWell

Is there a way to have a hover color on hovering a TableRow?

I found there is a TableRowInkWell but does not seem to be what I am looking for.

Thank you

Edit: To be clear: This is the problem

I have something like:

TableRow tableRow({@required rowData}) {    

  return TableRow(
    key: ValueKey<String>(tableRowModel.shortcutState.keyString),
    children: [],      
  );
})

When attempting to wrap the tableRow, this is not allowed.

Widget tableRow({@required rowData}) {    

  return MouseRegion(child:TableRow(
    key: ValueKey<String>(tableRowModel.shortcutState.keyString),
    children: [],      
  ));
})

 Error: A value of type 'Widget' can't be assigned to a variable of type 'TableRow'.

This is most likely because the MouseRegion is being used as a direct child of Table (i.e. Table(children[tableRow(), tableRow(), tableRow()])) where tableRow now is a MouseRegion)

Upvotes: 1

Views: 607

Answers (1)

AVEbrahimi
AVEbrahimi

Reputation: 19184

InkWell is not for hovering, it's for clicking.

To implement hovering you may use MouseRegion, it's easy to use:

https://api.flutter.dev/flutter/widgets/MouseRegion-class.html

Check the example in the link above and set the background color state of your object in MouseRegion, piece of cake.

Upvotes: 1

Related Questions