supabase / gotrue-dart

A dart client library for GoTrue.
MIT License
46 stars 37 forks source link

feat: fail to getSessionFromUrl throws error on onAuthStateChange #99

Closed dshukertjr closed 2 years ago

dshukertjr commented 2 years ago

Feature Proposal

Currently using supabase-flutter, there is no way to detect the exception thrown to parse deep links other than the initial link using initialSession

try {
  await SupabaseAuth.initialSession;
} catch(error) {
  // handle initial error here
}

This PR allows the users to use onAuthStateChange to listen to exceptions thrown during deep link parsing like this:

supabase.auth.onAuthStateChange.listen(
  (data) {
    // handle auth state change here
  },
  onError: (error) {
    // handle parsing error here.
  }
);

Fixes https://github.com/supabase-community/supabase-flutter/issues/211