testera_auth 1.1.0 copy "testera_auth: ^1.1.0" to clipboard
testera_auth: ^1.1.0 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
  • App usage tracking and analytics
  • Package name and installer store detection
  • Automatic usage logging to cloud functions

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
    testera_auth: ^1.1.0

Usage #

  1. Wrap your app with GetMaterialApp and use TesteraAuth as 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(),
      ),
    );
  }
}
  1. 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 authenticated
  • expirationDuration (optional): How long the authentication should remain valid (default: 7 days)
  • loadingWidget (optional): Custom widget to show during loading
  • errorWidget (optional): Custom widget to show when an error occurs

Usage Tracking #

The plugin automatically tracks and logs app usage to the configured cloud function. The following events are tracked:

  • App start
  • App background
  • App close

Each usage log includes:

  • Validation code
  • Session duration
  • Package name
  • Installer store information

The usage data is sent to: https://us-central1-testera-cc9ab.cloudfunctions.net/usageLog

Error Handling #

The plugin includes robust error handling for:

  • Network connectivity issues
  • Invalid codes
  • Package info retrieval
  • Lifecycle state changes
  • Usage logging failures

All errors are gracefully handled to prevent app crashes and maintain a smooth user experience.

Security #

  • Authentication state is persisted securely using SharedPreferences
  • Validation codes are stored securely and cleared on expiration
  • All network requests are made over HTTPS
  • Error messages are sanitized to prevent information leakage

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 progress
  • isAuthenticated: Whether the user is authenticated
  • errorMessage: 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.

0
likes
120
points
6
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin that provides a simple authentication layer using a code-based validation system.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, package_info_plus, shared_preferences, url_launcher

More

Packages that depend on testera_auth

Packages that implement testera_auth