ajolote 0.2.1
ajolote: ^0.2.1 copied to clipboard
Cliente Flutter para el servicio de autenticación centralizado de Anfibia/4Quinas. Multi-tenant, JWT, OTP por SMS, biometría.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:ajolote/ajolote.dart';
import 'package:app_links/app_links.dart';
import 'package:local_auth/local_auth.dart' as la;
import 'screens/login_screen.dart';
import 'screens/home_screen.dart';
import 'screens/splash_screen.dart';
import 'local_auth_wrapper.dart';
import 'app_links_adapter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final authClient = AjoloteClient(
appId: 'example-app',
baseUrl: Uri.parse(
const String.fromEnvironment(
'AUTH_URL',
defaultValue: 'http://localhost:3000',
),
),
);
await authClient.init();
final biometric = BiometricAuth(
storage: SecureTokenStorage(),
storagePrefix: 'ajolote-visitar',
authenticator: LocalAuthBiometricAuthenticator(la.LocalAuthentication()),
);
// OAuth social — vía app_links.
final socialAuth = SocialAuth(SocialAuthConfig(
client: authClient,
deepLinkListener: AppLinksAdapter(AppLinks()),
appScheme: 'exampleapp',
),);
runApp(MyApp(
authClient: authClient,
biometric: biometric,
socialAuth: socialAuth,
),);
}
class MyApp extends StatelessWidget {
final AjoloteClient authClient;
final BiometricAuth biometric;
final SocialAuth socialAuth;
const MyApp({
super.key,
required this.authClient,
required this.biometric,
required this.socialAuth,
});
@override
Widget build(BuildContext context) {
return AuthProvider(
client: authClient,
child: MaterialApp(
title: 'VisitAr',
theme: ThemeData(
colorSchemeSeed: const Color(0xFF00E5B0),
useMaterial3: true,
),
home: AuthBuilder(
loading: (_) => const SplashScreen(),
authenticated: (user) => HomeScreen(user: user),
unauthenticated: (_) => LoginScreen(
biometric: biometric,
socialAuth: socialAuth,
),
),
),
);
}
}