abk_flutter_utils Package
A modular Flutter package for scalable app development, featuring:
- Dependency injection (GetIt)
- Secure storage
- Firebase integration
- Networking (Dio)
- Bloc state management
- Localization
- Theming
- Notification handling
- Reusable widgets
Features
- DI & Core Utilities: Easy setup and access to services via GetIt.
- Networking: Dio-based API layer with interceptors and error handling.
- Firebase: Auth, Firestore, Messaging, Analytics, Crashlytics.
- Notifications: FCM and local notifications with unified service.
- State Management: Bloc observer for debugging and lifecycle tracking.
- Theming: Light/dark theme support and centralized theme management.
- Localization: Built-in i18n support.
- Reusable Widgets: Custom buttons, text fields, snack bars, etc.
Firebase Setup
- Create a Firebase project.
- Register your app (Android/iOS).
- Download
google-services.json
/GoogleService-Info.plist
. - Run
flutterfire configure
to generatefirebase_options.dart
. - Initialize Firebase in your app:
await FirebaseInitializer.init(options: DefaultFirebaseOptions.currentPlatform);
Getting Started
- Add the package to your
pubspec.yaml
. - Initialize Firebase in
main.dart
:// if need firebase await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
- Set up DI:
// Must await locatorSetup();
- Use services via DI:
locator<ApiServices>().getRequest(...); locator<NotificationService>().init(...);
Folder Structure
lib/
├── main.dart # App entry point
├── app.dart # MyApp widget
├── core/ # Core utilities, DI, base classes
│ ├── di.dart # GetIt setup
│ ├── failures.dart # Error types
│ ├── bloc_observer.dart # Bloc observer
│ ├── secure_storage.dart # Secure storage wrapper
│ └── firebase_services.dart # Firebase service abstraction
├── shared/ # Reusable components
│ ├── reusable_widgets/ # Widgets used across app
│ └── l10n/ # Localization
├── network/ # Networking layer
│ ├── api_endpoints.dart
│ ├── api_services.dart
│ └── dio_factory.dart
├── notification/ # FCM & local notifications
│ └── fcm_service.dart
├── theme/ # Theme management
│ ├── app_theme.dart
│ ├── dark_theme.dart
│ └── light_theme.dart
├── navigation/ # Routing
│ ├── app_router.dart
│ └── app_routes.dart
├── src/ # Internal implementation (optional)
│ └── ...
└── index.dart # Barrel file exporting public API
Example Usage
// main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// if need firebase
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await locatorSetup();
runApp(const MyApp());
}
Documentation
- Each service and utility is documented in code with Dart doc comments.
- See the barrel file (
index.dart
) for all public exports. - For advanced usage, see the source files in each folder.
Contributing
Pull requests and issues are welcome!
License
MIT
Libraries
- app/di/locator
- app/my_app
- app/navigation/app_router
- app/navigation/app_routes
- cores/constants/api_endpoints
- cores/constants/app_constants/regex
- cores/constants/app_constants/ui_constants
- cores/constants/index
- cores/failure/failure
- cores/firebase/firebase_initializer
- cores/firebase/firebase_services
- cores/l10n/app_localizations
- cores/l10n/app_localizations_ar
- cores/l10n/app_localizations_en
- cores/network/api_services
- cores/network/dio_factory
- cores/network/interceptors
- cores/notification/fcm_service
- cores/reusable_widgets/custom_app_bar
- cores/reusable_widgets/custom_image
- cores/reusable_widgets/custom_snack_bar
- cores/reusable_widgets/custom_spacing/horizontal_spacing
- cores/reusable_widgets/custom_spacing/vertical_spacing
- cores/reusable_widgets/custom_text_fields/custom_email_text_field
- cores/reusable_widgets/custom_text_fields/custom_password_text_field
- cores/reusable_widgets/custom_text_fields/custom_text_field
- cores/state_managment/bloc_observer
- cores/storage/cache_storage
- cores/storage/secure_storage
- cores/theme/app_theme
- cores/theme/dark_theme
- cores/theme/light_theme
- main