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

Clean architecture Flutter authentication kit for Apple, Google, Facebook, and custom third-party providers.

example/lib/main.dart

import 'package:auth_kit/auth_kit.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _authKit = AuthKit();
  String _status = 'Not signed in';

  @override
  void initState() {
    super.initState();
    _configureAuth();
  }

  Future<void> _configureAuth() async {
    await _authKit.configure(
      const AuthKitConfiguration(
        providers: {
          AuthProvider.apple: ProviderAuthConfiguration.apple(),
          AuthProvider.google: ProviderAuthConfiguration.google(
            clientId: 'YOUR_GOOGLE_CLIENT_ID',
            serverClientId: 'YOUR_GOOGLE_SERVER_CLIENT_ID',
          ),
          AuthProvider.facebook: ProviderAuthConfiguration.facebook(
            clientId: 'YOUR_FACEBOOK_APP_ID',
          ),
        },
      ),
    );
  }

  Future<void> _signInWithApple() async {
    setState(() => _status = 'Signing in...');

    try {
      final result = await _authKit.signInWithApple();
      setState(
        () => _status = 'Signed in: ${result.user.email ?? result.user.id}',
      );
    } on AuthKitException catch (error) {
      setState(() => _status = '${error.code}: ${error.message}');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('AuthKit example')),
        body: Padding(
          padding: const EdgeInsets.all(24),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Text(_status, textAlign: TextAlign.center),
              const SizedBox(height: 16),
              FilledButton(
                onPressed: _signInWithApple,
                child: const Text('Sign in with Apple'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
34
downloads

Documentation

API reference

Publisher

verified publisherit36vn.com

Weekly Downloads

Clean architecture Flutter authentication kit for Apple, Google, Facebook, and custom third-party providers.

Homepage

License

unknown (license)

Dependencies

flutter, flutter_facebook_auth, google_sign_in, plugin_platform_interface

More

Packages that depend on auth_kit

Packages that implement auth_kit