Issue
Beginner here
Padding( padding: const EdgeInsets.all(8.0), child: Container( width: 200, decoration: BoxDecoration( image: DecorationImage(
// ignore: prefer_const_constructors
image: AssetImage(
"assets/FeaturedPeoplePhotos/Top100/MostRecommendedBooks/1.png"),
fit: BoxFit.cover),
//color: Colors.amber,
borderRadius: BorderRadius.circular(8)),
),
),
I have written a code in flutter which shows an image of a particular book and I want to know and need some help about how i add a affiliate link in image so that user can redirect to the product page like Amazon or any other e-commerce sites
Solution
GestureDetector is the widget you're looking for. It detects all kinds of gestures on its child widget. In your case, you can wrap your Container() widget with GestureDetector() widget. Like this:
GestureDetector(
onTap: (){
//here you can redirect to your affiliate link by using url_launcher
launch("www.yourlinkhere.com");
},
child: Container( //...your image container widget ),
),
The launch() function is provided by the url_launcher package. You have to include it as a dependency in your pubspec.yaml file. Check this out.
Answered By - Muhammad Hussain
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.