login method

Future login(
  1. BuildContext context
)

Implementation

Future login(BuildContext context) async {
  String? clientId = Preferences.prefs?.getString("ClientId");
  String? clientSecret = Preferences.prefs?.getString("ClientSecret");

  ApplicationRegistration appRegis = ApplicationRegistration();
  while (clientId == null || clientSecret == null) {
    await appRegis.registerApplication();

    clientId = Preferences.prefs?.getString("ClientId");
    clientSecret = Preferences.prefs?.getString("ClientSecret");
  }

  LoginManager login = LoginManager(!kIsWeb && Platform.isAndroid);
  Preferences.prefs!
      .setString("AccessToken", (await login.login(clientId, clientSecret))!);

  // ignore: use_build_context_synchronously
  Navigator.pushReplacement(
    context,
    MaterialPageRoute(
      builder: (context) => returnToWidget,
    ),
  );
}