Skip to content

Instantly share code, notes, and snippets.

@timfong888
Created July 20, 2022 20:25
Show Gist options
  • Save timfong888/2a250252f5b66d6b53f17fc4f749004e to your computer and use it in GitHub Desktop.
Save timfong888/2a250252f5b66d6b53f17fc4f749004e to your computer and use it in GitHub Desktop.
Listener routing to named Route
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FFAppState(); // Initialize FFAppState
GetSocial.addOnInitializedListener(() => {
// GetSocial SDK is ready to use
});
setupLocator();
runApp(MyApp());
locator<LandingPageData>().referralID = "defaultReferralID";
registerListeners();
}
void registerListeners() {
Invites.setOnReferralDataReceivedListener((received) {
globalReferralData = received;
print(globalReferralData);
print(globalReferralData.linkParams);
print("listener - socialdata");
String passedReferralID =
globalReferralData.linkParams['referralID'].toString();
String passedCreatorID =
globalReferralData.linkParams['creatorID'].toString();
String passedCampaignID =
globalReferralData.linkParams['\$campaign_id'].toString();
print(passedReferralID);
print(passedCreatorID);
print(passedCampaignID);
locator<NavigationService>()
.navigatorKey
.currentState
.pushReplacementNamed('landingPage'); // how can I create a named Route?
locator<LandingPageData>().referralID = passedReferralID;
locator<LandingPageData>().creatorID = passedCreatorID;
locator<LandingPageData>().campaignID = passedCampaignID;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment