How bhoominn/nb_utils works
Project Type and Purpose
• Type: Federated Flutter plugin package (multi-platform)
• Purpose: Provide reusable UI widgets, extensions, system/package utilities, and platform method-channel integrations to Flutter apps on Android, iOS, Web, Windows, Linux, and macOS.
Top-Level Architecture Components
A. Plugin Package (nb_utils)
– Core Dart library (lib/):
• nb_utils_platform_interface.dart: Defines abstract interface.
• nb_utils_method_channel.dart: Default MethodChannel implementation for mobile/desktop.
• nb_utils_web.dart: Web‐specific implementation.
• src/:
– /utils, /widgets, /extensions, /models, /chatgpt: Pure Dart code (no native calls).
– Platform-specific folders:
• android/src/.../NbUtilsPlugin.kt
• ios/Classes/NbUtilsPlugin.swift (+ macos Swift code)
• linux/nb_utils_plugin.cc
• windows/nb_utils_plugin.cpp
– Pub configuration files: pubspec.yaml, nb_utils.podspec
B. Example App (example/)
– Flutter application demonstrating usage on Android, iOS, macOS, web, Linux, Windows.
– Contains platform embedding for each target (Gradle, Xcode, CMake etc.).
– Depends on nb_utils via pubspec.yaml.
Relationships and Interactions
1. Flutter App → depends on → nb_utils
2. Dart API calls (e.g., initialize(), getIpAddress(), showConfirmDialog(), widget constructors, extension methods) → resolved to →
a. Pure-Dart modules under lib/src/ (no channel)
b. Platform interface if the API requires a native bridge
– The call goes from nb_utils_platform_interface to nb_utils_method_channel (MethodChannel)
– MethodChannel dispatches to native code in Android/iOS/Linux/Windows/macOS plugin classes
3. Native Plugin Code → communicates back results → via MethodChannel callbacks → to Dart side
Important Architectural Patterns and Design Principles
– Federated plugin using platform-interface + method-channel pattern
– Separation of concerns:
• UI widgets & extensions in pure Dart (cross-platform)
• Platform method-implementation only for native operations (shared_prefs, system utilities)
– Example app isolated under example/ to ensure real-world integration testing