testera_auth 1.0.1
testera_auth: ^1.0.1 copied to clipboard
A Flutter plugin that provides a simple authentication layer using a code-based validation system.
TesteraAuth #
A Flutter plugin that provides a simple authentication layer for your app using a code-based validation system.
Features #
- Code-based authentication (default code: 123456)
- Configurable expiration duration
- Persistent authentication state
- Customizable UI
- Built with GetX for state management
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
testera_auth: ^1.0.0
Usage #
- Wrap your app with
GetMaterialAppand useTesteraAuthas the home widget:
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:testera_auth/testera_auth.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'My App',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const TesteraAuth(
child: HomeScreen(),
),
);
}
}
- Create your main screen that will be shown after successful authentication:
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('My App'),
),
body: const Center(
child: Text('Welcome to the authenticated app!'),
),
);
}
}
Configuration #
The TesteraAuth widget accepts the following parameters:
child(required): The widget to display when authenticatedexpirationDuration(optional): How long the authentication should remain valid (default: 7 days)loadingWidget(optional): Custom widget to show during loadingerrorWidget(optional): Custom widget to show when an error occurs
Authentication #
The plugin uses a simple code-based authentication system:
- Default access code:
123456 - Authentication state persists until expiration
- Expiration duration is configurable (default: 7 days)
State Management #
The plugin uses GetX for state management. You can access the AuthController anywhere in your app:
final authController = Get.find<AuthController>();
Available observable states:
isLoading: Whether the authentication is in progressisAuthenticated: Whether the user is authenticatederrorMessage: Any error message that occurred during authentication
Example #
Check out the example directory for a complete working example.
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
This project is licensed under the MIT License - see the LICENSE file for details.