DEV Community

timfong888
timfong888

Posted on

2 1

Suggestions on how to deep link and route using Flutter?

Hello, I built an app using a third-party deep-linking service called GetSocial.

Locally, on Xcode, I have been able to get the listener in main() to display the parameters that I pass through the deep link.

However, I need to then route to a specific page and pass values to that page (ideally as a persisted local variable).

But I am stuck.

ReferralData globalReferralData;
    List<BuildContext> buildContextList = [];
    BuildContext context;


    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp();

      FFAppState(); // Initialize FFAppState

      GetSocial.addOnInitializedListener(() => {
            // GetSocial SDK is ready to use
          });

      runApp(MyApp());
      registerListeners();
    }

    void registerListeners() {
      Invites.setOnReferralDataReceivedListener((received) {
        globalReferralData = received;
        print(globalReferralData);
        print(globalReferralData.linkParams);
        print(globalReferralData.linkParams['referralID']);

        // pass value and open route -- this line failed to do anything

        Navigator.pushNamed(context, '/landingPage');

        // showAlert(buildContextList.last, 'Referral Data Received', '$received');
      });
    }
Enter fullscreen mode Exit fullscreen mode

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay