auth_management 0.1.5 copy "auth_management: ^0.1.5" to clipboard
auth_management: ^0.1.5 copied to clipboard

Collection of auth service with advanced controlling system.

example/lib/main.dart

import 'dart:developer';

import 'package:auth_management/core.dart';
import 'package:example/home_page.dart';
import 'package:example/login_page.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const Application());
}

class UserBackup extends BackupDataSourceImpl {
  @override
  Future<void> onCreated(Auth data) async {
    // Store authorized user data in remote server
    log("Authorized user data : $data");
  }

  @override
  Future<void> onDeleted(String id) async {
    // Clear unauthorized user data from remote server
    log("Unauthorized user id : $id");
  }
}

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

  @override
  Widget build(BuildContext context) {
    return AuthProvider(
      controller: AuthController(backup: UserBackup()),
      child: MaterialApp(
        title: 'Auth Management',
        home: AuthObserver(
          listener: (context, value) {
            if (value.isError) {
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text(value.error)),
              );
            }
            if (value.isMessage) {
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text(value.message)),
              );
            }
          },
          builder: (context, value) {
            if (value.isAuthenticated) {
              return const HomePage();
            } else {
              return const LoginPage();
            }
          },
        ),
      ),
    );
  }
}
4
likes
0
pub points
42%
popularity

Publisher

unverified uploader

Collection of auth service with advanced controlling system.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

firebase_auth, flutter, flutter_andomie, flutter_facebook_auth, google_sign_in, local_auth, sign_in_with_apple

More

Packages that depend on auth_management