Flutter Store Redirect

Flutter Store Redirect:

In this tutorial, we are going to study Flutter Store Redirect, store redirect means redirecting the user to the particular app in google play store OR apple app store to download the particular app that we redirected using the app ID we provided in our App.

This is helpful for an eCommerce business to redirect the user directly to the app store by providing the app Id to download the Aap. Here customer no need to search the particular app in App stores this will increase the app installs.

Implementing Store Redirect in Flutter:

Add the dependency package:

To implement Flutter Store Redirect we need to add the dependency package to pubspec.yaml file. use the below code to add dependency package. After adding the dependency package run the get package method to import all the required files to the app.

dependencies:
store_redirect: ^1.0.1

Install the package:

You can install the package from the command line using the below code with Flutter as shown.

$ flutter packages get

Importing the Package:

After, Adding the dependency package to the pubspec.yaml file, you can now import the package into the dart code by using the below code. without adding the dependency package to the pubspec.yaml file if you import it will show package not found an error.

import 'package:store_redirect/store_redirect.dart';

Use the below method to redirect the user to the store:

If we don’t pass the arguments it will considers the current page 

StoreRedirect.redirect();

Flutter store Redirect to a Particular App:

If you want the user is redirected to particular app for Android app redirect provide the app path and for IOS app redirect provide the IOSAppId as shown in below example code 

StoreRedirect.redirect(androidAppId: "com.iyaffle.rangoli",
iOSAppId: "585027354")

Complete Examle Code for Flutter Store Redirect.

Copy and Paste the below code into your main.dart file

main.dart

import 'package:flutter/material.dart';
import 'package:store_redirect/store_redirect.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State {
@override
initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(title: new Text('Launch App Redirect')),
body: new Center(
child: new RaisedButton(
child: new Text("Redirect App"),
onPressed: () {
StoreRedirect.redirect(
androidAppId: "com.iyaffle.rangoli",
iOSAppId: "585027354");
}))));
}
}

Congratulations You Have Learned Flutter Store Redirecting to Google Play Store & Apple App Store….!!!

If It Is Helpful Share It With Your Friends….!!!

Leave a Reply

Categories