auth_management 1.0.3-alpha1 copy "auth_management: ^1.0.3-alpha1" to clipboard
auth_management: ^1.0.3-alpha1 copied to clipboard

Collection of auth service with advanced controlling system.

example/lib/main.dart

import 'package:auth_management/core.dart';
import 'package:auth_management_biometric_delegate/auth_management_biometric_delegate.dart';
import 'package:auth_management_google_delegate/auth_management_google_delegate.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';

import 'backup_delegate.dart';
import 'home_page.dart';
import 'login_page.dart';
import 'oauth_page.dart';
import 'register_page.dart';
import 'startup.dart';
import 'user_model.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return AuthProvider<UserModel>(
      initialCheck: true,
      controller: AuthController.getInstance<UserModel>(
        backup: UserBackupDelegate(),
        oauth: OAuthDelegates(
          // appleAuthDelegate: AppleAuthDelegate(),
          biometricAuthDelegate: BiometricAuthDelegate(),
          // facebookAuthDelegate: FacebookAuthDelegate(),
          googleAuthDelegate: GoogleAuthDelegate(
            googleSignIn: GoogleSignIn(scopes: [
              'email',
            ]),
          ),
        ),
      ),
      child: MaterialApp(
        title: 'Auth Management',
        theme: ThemeData(
          primaryColor: Colors.deepOrange,
          colorScheme: ColorScheme.fromSeed(
            seedColor: Colors.deepOrange,
            primary: Colors.deepOrange,
          ),
          elevatedButtonTheme: ElevatedButtonThemeData(
            style: ElevatedButton.styleFrom(
              backgroundColor: Colors.deepOrange,
              foregroundColor: Colors.white,
            ),
          ),
          inputDecorationTheme: InputDecorationTheme(
              border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(8),
          )),
        ),
        initialRoute: "startup",
        onGenerateRoute: routes,
      ),
    );
  }
}

Route<T>? routes<T>(RouteSettings settings) {
  final name = settings.name;
  final data = settings.arguments;
  if (name == "home") {
    return MaterialPageRoute(
      builder: (_) {
        return const HomePage();
      },
    );
  } else if (name == "login") {
    return MaterialPageRoute(
      builder: (_) {
        return const LoginPage();
      },
    );
  } else if (name == "register") {
    return MaterialPageRoute(
      builder: (_) {
        return const RegisterPage();
      },
    );
  } else if (name == "oauth") {
    return MaterialPageRoute(
      builder: (_) {
        return const OAuthPage();
      },
    );
  } else if (name == "startup") {
    return MaterialPageRoute(
      builder: (_) {
        return const StartupPage();
      },
    );
  }
  return null;
}
4
likes
0
points
142
downloads

Publisher

unverified uploader

Weekly Downloads

Collection of auth service with advanced controlling system.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

auth_management_delegates, firebase_auth, flutter, flutter_entity, shared_preferences

More

Packages that depend on auth_management