aptof_core 0.1.0-beta.4 copy "aptof_core: ^0.1.0-beta.4" to clipboard
aptof_core: ^0.1.0-beta.4 copied to clipboard

A reusable package for core functionality.

To Use utility: #

import 'package/aptof_core/utility.dart'

To use 'ui' #

import 'package/aptof_core/ui.dart'

To use auth, please follow the steps (guide for app created using very good cli) #

  1. In your MaterialApp (lib/app/view/app.dart in _AppView widget)
import 'package/aptof_core/l10n/l10n.dart';
... 
localizationsDelegates: const [
        ...AppLocalizations.localizationsDelegates,
        ...AptofLocalizations.localizationsDelegates,
      ],
      supportedLocales: {
        ...AppLocalizations.supportedLocales,
        ...AptofLocalizations.supportedLocales,
      }.toList(),
      ...

Here AppLocalizations is your main app localization

  1. In your App widget class (lib/app/view/app.dart)
@override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        Provider.value(value: FirebaseAuth.instance),
        Provider(
          create: (context) => AuthRepository(firebaseAuth: context.read()),
          dispose: (_, provider) => provider.dispose(),
        ),
      ],

      child: const _AppView(),
    );
  }
  1. Create a class named AppRouter like below
class AppRouter extends AptofRouter {
  AppRouter(super.authRepository);

  @override
  List<StatefulShellBranch> branches() {
    return [
      StatefulShellBranch(
        routes: [
          GoRoute(
            path: Routes.home,
            builder: (context, state) => const HomeView(),
          ),
        ],
      ),
      StatefulShellBranch(
        routes: [
          GoRoute(
            path: '/home2',
            builder: (context, state) => const PlaceholderView(title: 'Home 2'),
          ),
        ],
      ),
      StatefulShellBranch(
        routes: [
          GoRoute(
            path: '/home3',
            builder: (context, state) => const PlaceholderView(title: 'Home 3'),
          ),
        ],
      ),
    ];
  }

  @override
  List<NavigationDestination> destinations(BuildContext context) {
    return [
      const NavigationDestination(
        icon: Icon(Icons.home),
        label: 'Home',
      ),
      const NavigationDestination(
        icon: Icon(Icons.home),
        label: 'Home',
      ),
      const NavigationDestination(
        icon: Icon(Icons.home),
        label: 'Home',
      ),
    ];
  }
}
  1. Setup firebase then In your app.dart
class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        Provider.value(value: FirebaseAuth.instance),
        Provider(
          create: (context) => AuthRepository(firebaseAuth: context.read()),
          dispose: (_, provider) => provider.dispose(),
        ),
      ],

      child: const _AppView(),
    );
  }
}

class _AppView extends StatelessWidget {
  const _AppView();

  @override
  Widget build(BuildContext context) {
    final router = AppRouter(context.read());
    return MaterialApp.router(
      theme: AppTheme.light,
      darkTheme: AppTheme.dark,
      localizationsDelegates: const [
        ...AppLocalizations.localizationsDelegates,
        ...AptofLocalizations.localizationsDelegates,
      ],
      supportedLocales: {
        ...AppLocalizations.supportedLocales,
        ...AptofLocalizations.supportedLocales,
      }.toList(),
      routerConfig: router.createRouter(),
    );
  }
}
0
likes
0
points
66
downloads

Publisher

unverified uploader

Weekly Downloads

A reusable package for core functionality.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

firebase_auth, flutter, flutter_localizations, formz, freezed_annotation, go_router, intl, json_annotation, meta, provider, signals

More

Packages that depend on aptof_core