Search code examples
androidflutterdarturl-launcher

How to launch Amazon app using product link in flutter?


I want to open Amazon App when someone press the elevated button. I am using url_launcher package and using affiliate product link.

ElevatedButton(
      onPressed: () {
        launch("https://www.amazon.com/");
      },
      child: Text("amazon"),
    ),

Solution

  • Try below code hope its helpful to you.

    You must use url_launcher package from here add this dependency in your pubspec.yaml file

    You can refer my answer here also for open app from URL

    create one widget

    InkWell(
          hoverColor: Colors.transparent,
          child: Image.network(
            'https://upload.wikimedia.org/wikipedia/commons/d/de/Amazon_icon.png',
            width: 70,
            height: 70,
          ),
          onTap: () => amazon(),
        )
    

    Create ontap function

    amazon() async {
        const url =
            'https://www.amazon.com/';// or add your URL here
        if (await canLaunch(url)) {
          await launch(url);
        } else {
          throw 'Could not launch $url';
        }
      }