supabase_auth_package 0.0.1 copy "supabase_auth_package: ^0.0.1" to clipboard
supabase_auth_package: ^0.0.1 copied to clipboard

A Flutter package for Supabase authentication, supporting email/password and Google Sign-In.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:supabase_auth_package/supabase_auth_pack.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await Supabase.initialize(
    url: 'your-supabase-url',
    anonKey: 'your-anon-key',
  );
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Authentication using supabase',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Supabase authentication'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ElevatedButton(onPressed: ()async{
              // final authRepo = AuthRepository(supabaseClient: Supabase.instance.client,);
              final googleService = GoogleAuthService(supabaseClient: Supabase.instance.client,googleSignIn:GoogleSignIn(serverClientId: ''));
              await googleService.signIn();
              // authRepo.googleSignIn('pass your server key');
            }, child: Text('Login with google')),
            SizedBox(height: 20,),

            ElevatedButton(onPressed: (){
              final authRepo = AuthRepository(supabaseClient: Supabase.instance.client);
              authRepo.signInUsingEmailPassword(email: '',password: '');
            }, child: Text('Login using email')),
            SizedBox(height: 20,),

            ElevatedButton(onPressed: (){
              final authRepo = AuthRepository(supabaseClient: Supabase.instance.client);
              authRepo.signUpUsingEmailPassword(email: '',password: '');
            }, child: Text('SignUp using email')),
            SizedBox(height: 20,),
            ElevatedButton(onPressed: (){
              final authRepo = AuthRepository(supabaseClient: Supabase.instance.client);
              authRepo.checkEmailVerify(email: '',password: '');
            }, child: Text('email verification')),
          ],
        ),
      ),
    );
  }
}
5
likes
120
points
52
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for Supabase authentication, supporting email/password and Google Sign-In.

Repository

Documentation

API reference

License

MIT (license)

Dependencies

flutter, google_sign_in, supabase_flutter

More

Packages that depend on supabase_auth_package