Skip to main content

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

A production-ready foundation kit for Flutter apps featuring multi-environment management, auth gates, crash boundaries, and session guards.

AppForge Kit ๐Ÿ› ๏ธ๐Ÿš€ #

A production-ready foundation kit for Flutter applications. Eliminates boilerplate for Multi-Environment configuration, Automatic Auth Routing, Global Crash Boundaries, Inactivity & Session Guards, and Context-less Navigation.


โšก Features #

  • ๐ŸŒ Multi-Environment Management: One-line config for Dev, Staging, and Production environments with auto-toggled logging, base URLs, and on-screen environment badges.
  • ๐Ÿ›ก๏ธ Global Crash Boundary: Eliminates the ugly red screen of death in production with a polished fallback screen, copyable stack trace, and Crashlytics/Sentry hooks.
  • ๐Ÿšช Ready-Made AuthGate: Manages the initial Splash -> Token Verification -> Login / Home routing sequence seamlessly without boilerplate.
  • โณ Inactivity & Session Guard: Monitors user interactions across the app and triggers auto-logout or PIN lock when inactive for a configured duration.
  • ๐Ÿงญ Context-less Navigation (AppForgeNav): Navigate (to, replace, toAndClearStack, back) from anywhere without needing a BuildContext.
  • ๐Ÿ” AppForgeLogger: Formatted, leveled console logger with emojis and timestamps, automatically silenced in production.

๐Ÿ“ฆ Installation #

Add appforge_kit to your pubspec.yaml:

dependencies:
  appforge_kit: ^0.0.1

๐Ÿš€ Quick Start #

1. Initialize in main() #

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize AppForge
  await AppForge.init(
    environment: AppEnvironment.dev(
      baseUrl: 'https://dev.api.example.com',
      showBanner: true, // Shows small "DEV" badge in corner
    ),
    onCrash: (error, stack) {
      // Send unhandled errors to Firebase Crashlytics or Sentry
    },
  );

  runApp(const MyApp());
}

2. Configure MaterialApp with AppForge.builder() #

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: AppForge.navigatorKey, // Context-less navigation
      builder: AppForge.builder(),         // Injects Crash Boundary & Env Badge
      home: AuthGate(
        minSplashDuration: const Duration(seconds: 1),
        isAuthenticated: () async {
          // Check token or secure storage
          return false;
        },
        splashScreen: const SplashScreen(),
        loginScreen: const LoginScreen(),
        homeScreen: const HomeScreen(),
      ),
    );
  }
}

๐ŸŒŸ Feature Guide #

1. Multi-Environment Support #

AppForge provides standard factory constructors for common environments:

// Development
AppEnvironment.dev(
  baseUrl: 'https://dev.api.com',
  showBanner: true,
  enableLogging: true,
);

// Staging / QA
AppEnvironment.staging(
  baseUrl: 'https://qa.api.com',
  showBanner: true,
);

// Production
AppEnvironment.prod(
  baseUrl: 'https://api.com',
  showBanner: false,
  enableLogging: false,
);

// Custom
AppEnvironment(
  type: EnvironmentType.custom,
  name: 'SANDBOX',
  baseUrl: 'https://sandbox.api.com',
  showBanner: true,
  extra: {'stripeKey': 'pk_test_...'},
);

Access details anywhere in your code:

final url = AppForge.baseUrl;
if (AppForge.isDev) {
  // Developer tools
}

2. Ready-Made AuthGate #

The AuthGate widget handles the common sequence of app launch:

  1. Shows splashScreen (with customizable minSplashDuration to prevent flickering).
  2. Asynchronously invokes isAuthenticated.
  3. Seamlessly transitions to homeScreen or loginScreen.
AuthGate(
  controller: authGateController, // Optional programmatic control
  minSplashDuration: const Duration(milliseconds: 1200),
  isAuthenticated: () async {
    final token = await SecureStorage.read('jwt');
    return token != null && token.isNotEmpty;
  },
  splashScreen: const SplashScreen(),
  loginScreen: const LoginScreen(),
  homeScreen: const HomeScreen(),
)

To update the auth state dynamically (e.g. on logout/login):

authGateController.setAuthenticated(false); // Transitions back to login

3. Inactivity & Session Timeout #

Ideal for banking, medical, or security-sensitive apps:

AppInactivityDetector(
  timeoutDuration: const Duration(minutes: 5),
  onTimeout: () {
    // Auto logout or prompt PIN dialog
    AppForgeNav.toAndClearStack(const LockScreen());
  },
  child: const MyApp(),
)

4. Context-Less Navigation #

Navigate from your BLoC, Riverpod notifier, service, or repository without BuildContext:

// Push a screen
AppForgeNav.to(const ProfileScreen());

// Replace screen
AppForgeNav.replace(const DashboardScreen());

// Clear stack and push
AppForgeNav.toAndClearStack(const LoginScreen());

// Pop
AppForgeNav.back();

5. AppForge Logger #

AppForgeLogger.d('Debug info');
AppForgeLogger.i('Connected to API');
AppForgeLogger.w('Token expiring soon');
AppForgeLogger.e('Request failed', error: exception, stackTrace: trace);

๐Ÿงช Testing #

Run test suite:

flutter test

๐Ÿ“„ License #

MIT License.

2
likes
150
points
233
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A production-ready foundation kit for Flutter apps featuring multi-environment management, auth gates, crash boundaries, and session guards.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on appforge_kit