Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 349 Vote(s) - 3.37 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flutter: Inkwell does not work with Card

#1
I am trying to implement and inkWell wrap on a card widget, but it does not work at all. I am leaving on tap as null because this class takes 3 arguments that I populate later on to generate multiple cards.
I cannot see what is going on that is preventing InkWell from rippling, so any help would be appreciated.



class FeedBackCardsImage extends StatelessWidget {
final String imagePath;
final String cardTitle;
final String cardTag;

FeedBackCardsImage({
this.imagePath,
this.cardTitle,
this.cardTag,
});

@override
Widget build(BuildContext context) {

return InkWell(
child: new Container(
child: new Card(
child: new Padding(
padding: new EdgeInsets.all(15.0),
child: new Column(
children: <Widget>[
new SizedBox(
height: 184.0,
child: new Stack(
children: <Widget>[
new Positioned.fill(
child: new Image.asset(
imagePath,
//package: destination.assetPackage,
fit: BoxFit.contain,
),
),
],
),
),
new Padding(
padding: new EdgeInsets.all(
7.0,
),
child: new Text(
cardTitle,
style: new TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w600,
color: Colors.black87),
),
),
new Padding(
padding: new EdgeInsets.all(
0.0,
),
child: new Text(
cardTag,
style: new TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w400,
color: Colors.black54),
),
),
],
),
),
),
),
onTap: null,

);



}

Reply

#2
For widget that have tap property to ripple, it shouldn't have a null on onTap method. Give the onTap something like ()=>null;
Hope Answered!
Reply

#3
Explanation :

> "What's going on is that the Material spec says that the splashes are
> actually ink on the Material. So when we splash, what we do is we
> literally have the Material widget do the splash. If you have
> something on top of the Material, we splash under it, and you can't
> see it."

Workaround :

return Stack(children: <Widget>[
new Card(
child: new Padding(
padding: new EdgeInsets.all(15.0),
child: new Column(
children: <Widget>[
new SizedBox(
height: 184.0,
child: new Stack(
children: <Widget>[
new Positioned.fill(
child: new Image.asset(
imagePath,
//package: destination.assetPackage,
fit: BoxFit.contain,
),
),
],
),
),
new Padding(
padding: new EdgeInsets.all(
7.0,
),
child: new Text(
cardTitle,
style: new TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w600,
color: Colors.black87),
),
),
new Padding(
padding: new EdgeInsets.all(
0.0,
),
child: new Text(
cardTag,
style: new TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w400,
color: Colors.black54),
),
),
],
),
),
),
new Positioned.fill(
child: new Material(
color: Colors.transparent,
child: new InkWell(
onTap: () => null,
)))
]);

Reply

#4
To see ripple animation on card try to change `onTap: null` to `onTap: () {}`
Reply

#5
I finally got this to work by specifying the same border radius in both the parent card widget and the child inkwell widget. The other solutions don't correctly render rounded corners for the ink well animation. The below worked perfectly for me:

Card(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
child: InkWell(
borderRadius: BorderRadius.circular(8),
onTap: (){},
child: Container(
height: 58,
),
),
);
Reply

#6
instead of using card and inkwell you can put your widget content in a `raised button` and use the `onPressed` instead of the on tap.
then you can specify a costume shape and the ripple will have the same shape.

```java
RaisedButton(
elevation: 20,
padding: EdgeInsets.all(0),
onPressed: (){},
shape: ContinuousRectangleBorder(
borderRadius: BorderRadius.circular(100),
),
color: Colors.red,
child: Container(
alignment: Alignment.topCenter, //raised button aligns to center automaticaly so you can use alignment so the widget will be aligned the way you want
margin: EdgeInsets.only(top: 16),
child: Text("cool"),
),
),
```
Reply

#7
Okay so how I did it was I just put my Inkwell inside the card.
Before the tree was like

> Inkwell -> Card -> Container.

Inkwell Ripple effect didn't work on the above one, so I did was

> Card -> Material -> Inkwell -> Container

*Let me show in code*
<h2>Before</h2>

Card(
margin: EdgeInsets.all(10.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: Container(
// My design code here
)
)

<h2>After</h2>

Card(
margin: EdgeInsets.all(10.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: Material(
child: InkWell(
splashColor: Colors.orange,
onTap: (){
print('Tapped!');
},
child: Container(
// My design code here
)
),
),
),


I hope this helps! :) Let me know if any questions!
Reply

#8
i know that this is an old post, for those who are facing the same problem , what you need to do is to stack the InkWell on top of the Custom Widget you have created , give the Material app a transparent background


Stack( children: <Widget>[
YourWidget(),//
Container(
width: width,// full width
height: width,// full height of the container the stack is in
child: Material(
// animationDuration: Duration(milliseconds:800),
color: Colors.transparent,
child: InkWell(
onTap: (){
Scaffold.of(context).showSnackBar(SnackBar(
content: Text('Tap'),
));
},
highlightColor: Colors.red,
hoverColor: Colors.red,
focusColor: Colors.red,
child: Text("wow"),
),
))
],
));

Reply

#9
The simplest solution is to have an **Inkwell** widget with a child **Container** that contains **your widget**.

The important part here is that your **onTap** property on the **InkWell** widget **cannot be null!**

**Example**:
<!-- language: dart -->
Card(
child: InkWell(
onTap: () {},
child: Container(
width: double.infinity,
padding: EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
icon,
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text('I'm a card Widget'),
),
],
),
),
),
Reply

#10
To get the Inkwell ripple effect (splash) on a card that has an image over it, you can use Ink.image class for this..This works well..

Card(
child: Ink.image(
image: AssetImage('images/dog.jpeg'),
fit: BoxFit.contain,
height: 100,
child: InkWell(
splashColor: Colors.green.withOpacity(.2),
onTap: () {},
),
),
)
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through