office_core library

OfficeCore — A federated Flutter plugin consolidating Remote Config, Ads, Crashlytics, Analytics, Notifications, and Trial/Limits behind a single initialize() entry point with a strongly-typed configuration model.

Quick Start

  1. Add office_core to your pubspec.yaml.
  2. Initialize Firebase in main():
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:office_core/office_core.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);

  await OfficeCore.initialize(OfficeCoreConfig(
    premiumProvider: ValueNotifierPremiumProvider(ValueNotifier(false)),
    notificationBackend: NotificationBackendConfig(
      openedApiUrl: 'https://api.example.com/notification/opened',
      deviceRegistryPath: 'devices',
      topics: ['all_users'],
    ),
  ));

  runApp(MyApp());
}
  1. Access subsystems anywhere via OfficeCore.instance:
final bannerUnitId = OfficeCore.rc.current.platform.ads.units.banner;
final canDownload = OfficeCore.trial.canDownload;
OfficeCore.analytics.logEvent('my_event');

Classes

AdsConfig
AdsUnits
AdsVisibility
AiConfig
AiProvider
BatchLimit
BatchLimits
DiscountPopupConfig
DisposableInterface
Simple disposable interface (avoids importing Flutter foundation just for the dispose pattern).
FakePremiumProvider
Fake PremiumStatusProvider for tests.
FileSizeLimit
FreeLimitsConfig
Free-tier limits read from flat RC keys free_reminder_limit / free_user_limit. -1 means unlimited.
GlobalConfig
LimitsConfig
NotificationBackendConfig
Backend configuration for OfficeNotificationController.
OfficeAdsController
Controller that manages ad visibility flags and the lifecycle of app-open and interstitial ads.
OfficeAnalyticsService
Analytics service wrapping FirebaseAnalytics with a drop-in RouteObserver for automatic screen-view tracking.
OfficeBannerAd
Banner ad widget that respects Remote Config visibility flags and the user's premium status.
OfficeConnectivityService
Wraps InternetConnection and exposes a stream that fires when network connectivity is restored after an outage.
OfficeCore
Singleton that exposes every OfficeCore subsystem.
OfficeCoreConfig
Configuration object for OfficeCore.initialize.
OfficeCrashlytics
Wraps FirebaseCrashlytics with breadcrumb logging, custom keys, and a zone-guarded error capture helper.
OfficeLifecycleService
Single WidgetsBindingObserver that exposes a stream of app-resume events.
OfficeLogger
Tagged logger that respects OfficeLogLevel set at init time.
OfficeNativeAd
Native ad widget that respects Remote Config visibility flags and the user's premium status.
OfficeNotificationController
Controller wrapping FCM + FlutterLocalNotificationsPlugin.
OfficePrefs
Typed wrapper over SharedPreferences with a change stream.
OfficeRemoteConfig
Root typed Remote Config model.
OfficeRemoteConfigService
Service that fetches, parses, caches, and exposes the typed OfficeRemoteConfig.
OfficeTrialService
Net-new subsystem that consolidates limits, feature locks, and trial-day tracking into a single API.
OnboardingConfig
PaywallConfig
PaywallPlan
PaywallUi
PlanRef
Reused in multiple places: splash.subscription, result_screen.discount_popup.plan, pro_banner.trigger.
PlatformConfig
Top-level platform configuration container.
PremiumStatusProvider
Abstract seam that decouples ads and trial gating from any specific IAP or state-management solution.
ProBannerConfig
ResultScreenConfig
SplashConfig
SubscriptionConfig
TrialConfig
UpgraderConfig
Upgrader dialog controls read from flat RC keys show_upgrader, show_upgrade_later, show_upgrade_ignore.
ValueNotifierPremiumProvider
A PremiumStatusProvider backed by a ValueNotifier<bool>.

Enums

AdType
OfficeEnv
Environment selector for OfficeCore.initialize.
OfficeLogLevel
Severity levels for OfficeLogger.

Constants

kOfficeConfigKey → const String
The RC key under which the entire legacy JSON config document was stored. Retained only for backwards compatibility; the new model reads flat, per-platform keys (e.g. show_banner_android).

Functions

firebaseMessagingBackgroundHandler(RemoteMessage message) Future<void>
Top-level background message handler. Must be a top-level function (not a class method or closure) so it can be registered as a background isolate handler.