Posts: 0
Threads: 0
Joined: Dec 2018
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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,
);
}
|
Posts: 0
Threads: 0
Joined: Nov 2019
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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!
|
Posts: 0
Threads: 0
Joined: Oct 2016
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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,
)))
]);
|
Posts: 0
Threads: 0
Joined: Jun 2021
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
To see ripple animation on card try to change `onTap: null` to `onTap: () {}`
|
Posts: 0
Threads: 0
Joined: Aug 2021
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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,
),
),
);
|
Posts: 0
Threads: 0
Joined: Aug 2017
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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"),
),
),
```
|
Posts: 0
Threads: 0
Joined: Jun 2021
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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!
|
Posts: 0
Threads: 0
Joined: Jan 2021
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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"),
),
))
],
));
|
Posts: 0
Threads: 0
Joined: Apr 2019
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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'),
),
],
),
),
),
|
Posts: 0
Threads: 0
Joined: Jun 2023
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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: () {},
),
),
)
|
|