fkernal 1.3.0
fkernal: ^1.3.0 copied to clipboard
A configuration-driven Flutter framework that handles networking, state management, storage, error handling, and theming automatically.
Changelog #
All notable changes to the FKernal package will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.3.0 - 2025-12-24 #
🚀 Major Migration: Riverpod #
This release replaces the internal provider + ValueNotifier engine with Riverpod for robust state management.
BREAKING CHANGES #
- Removed
providerdependency: Allcontext.read/context.watchcalls depending onpackage:providerwill fail. - Context Extensions:
context.useResourceis NO LONGER REACTIVE. It returns a snapshot.- Migration: Use
FKernalBuilderor convert your widget toConsumerWidgetand useref.watch.
- Migration: Use
watchThemeManagerremoved: Usecontext.themeManagerinside aListenableBuilder.
Added #
- Universal State Management:
- Architecture: Pluggable state engine supporting Riverpod (default), BLoC, GetX, MobX, Signals, and Provider.
- Adapters: New
StateAdapterandResourceStateAdapterinterfaces for custom implementations. - Configuration: New
stateManagement,stateAdapter, andlocalStateFactoryoptions inFKernalConfig.
- Riverpod Default: Optimized internal engine using
UncontrolledProviderScopeandProviderContainer. - Multi-State Bridges: Drop-in bridges (
ResourceCubit,ResourceSignal, etc.) for hybrid architectures. - StateManager: Added
stream()method for easy integration with external reactive libraries. - Improved Type Safety: Enhanced generic type stability during
ResourceStatetransitions (Loading/Error) to prevent casting issues in builders. - Global Customizability: Added
GlobalUIConfigfor default builders, custom networkinterceptorssupport, andProviderContaineroverrides. FKernalBuilder: Updated to be aConsumerStatefulWidgetwith robust type-safe state observation.
1.2.0 - 2025-12-24 #
🎉 Highlights #
This release introduces major improvements to authentication, networking performance, and testing infrastructure, while making the core package lighter by decoupling Firebase.
Added #
- Token Refresh & Dynamic Auth:
AuthConfig.dynamic()for retrieving tokens from secure storage before each request.onTokenRefreshcallback for automatic 401 handling and request retry.onTokenExpiredcallback for handling session expiration (e.g., logout).FKernal.instance.updateAuthToken()andclearAuthToken()for runtime control.
- Pagination Support:
- New
FKernalPaginatedBuilderwidget for infinite scroll lists. - Automatic load-more logic and state management (loading more, has more data).
- New
- Advanced Caching:
- Wildcard pattern invalidation:
storageManager.invalidateCachePattern('/users*'). - Endpoint-specific cache clearing:
storageManager.clearEndpointCache('/users').
- Wildcard pattern invalidation:
- Testing Utilities:
- Comprehensive mocks in
package:fkernal/testing.dart. MockNetworkClientwith request recording and response/error mocking.MockStorageProviderandMockSecureStorageProviderfor in-memory testing.
- Comprehensive mocks in
- Performance Optimizations:
- Request Deduplication: Concurrent identical GET requests are now automatically merged into a single network call.
- Per-Widget Cancellation: Requests are now cancellable at the endpoint level via
FKernal.instance.cancelEndpoint().
Changed #
- Firebase Decoupling: Moved
cloud_firestore,firebase_auth, andfirebase_storageto a separate optional module.- Import
package:fkernal/fkernal_firebase.dartif you need Firebase integration.
- Import
- Improved Error Mapping: Detailed mapping of
DioExceptiontypes to granularFKernalErrorType(timeout, rateLimited, cancelled, etc.).
Fixed #
- Request deduplication now correctly handles cache hits and misses.
- Improved path parameter substitution logic to prevent accidental overlaps.
1.1.0 - 2025-12-24 #
🎉 Highlights #
This release focuses on improving developer experience with comprehensive documentation, a consolidated example app, and new features for type safety and observability.
Added #
Documentation & Examples
- Comprehensive Example App: Consolidated all individual examples into a single, feature-complete
example/main.dartdemonstrating:- FKernal initialization with full configuration
- Networking with endpoints, caching, and invalidation
- State management with
FKernalBuilder - Local state with all slice types (Value, Toggle, Counter, List, Map)
- Theme switching between light/dark modes
- Error handling patterns
- All context extensions
- Documentation Overhaul: Complete rewrite of
README.mdincluding:- Table of contents for easy navigation
- Detailed API reference for all widgets
- Cache strategy explanation with TTL recommendations
- Advanced patterns (dependent fetches, optimistic updates, pagination)
- FAQ section addressing common questions
- Migration guides from BLoC and Riverpod
Type Safety
ResourceKey<T>: Introduced compile-time type-safe resource access// Define typed keys const usersKey = ResourceKey<List<User>>('getUsers'); // Use with type safety final users = context.useResourceKey(usersKey); // Type inferred!
Observability
KernelObserver: Abstract class for implementing custom observersKernelEvent: Sealed class hierarchy for all kernel events:RequestStarted- Fired when an API request beginsRequestCompleted- Fired on successful completion with durationRequestFailed- Fired on error with error detailsCacheHit/CacheMiss- Cache access eventsStateChanged- Resource state transitions
- Integration Support: Easy integration with analytics (Firebase, Mixpanel) and crash reporting (Sentry, Crashlytics)
Firebase Integration
FirebaseNetworkClient: Drop-in network client for Firebase/Firestoreawait FKernal.init( config: config.copyWith( networkClientOverride: FirebaseNetworkClient(FirebaseFirestore.instance), ), endpoints: endpoints, );
Architecture Improvements
INetworkClient: Interface for custom network implementations (GraphQL, gRPC, etc.)IStorageProvider: Interface for custom cache storage (SQLite, Redis, etc.)ISecureStorageProvider: Interface for custom secure storage (Keychain, biometric, etc.)
Changed #
- Widget Naming: Standardized all widget names with
FKernalprefix:FBuilder→FKernalBuilderFActionBuilder→FKernalActionBuilderFLocalBuilder→FKernalLocalBuilder
- Local Slices: Enhanced with history tracking and undo/redo support
LocalSlice<MyState>( initialState: MyState(), enableHistory: true, // Enable undo/redo maxHistoryLength: 50, ); - Error Messages: Improved error messages in development mode with actionable suggestions
Fixed #
- Cache invalidation now properly handles path parameters
- Theme persistence works correctly across app restarts
- Memory leak in
StateManagerwhen disposing resources
Deprecated #
FBuilder- UseFKernalBuilderinstead (will be removed in 2.0.0)FActionBuilder- UseFKernalActionBuilderinstead (will be removed in 2.0.0)
1.0.0 - 2025-12-19 #
🎉 Initial Release #
The first stable release of FKernal - the configuration-driven Flutter framework.
Added #
Core Framework
FKernal: Main entry point withinit()for framework initializationFKernalApp: Widget wrapper that provides kernel context to the widget treeFKernalConfig: Comprehensive configuration object including:baseUrl: Base URL for all API requestsenvironment: Development, Staging, or Productionfeatures: Feature flags for caching, retry, logging, etc.theme: Theme configuration with Material 3 supportauth: Authentication configuration (Bearer, API Key, Custom)pagination: Pagination defaultserrorConfig: Global error handling configuration
Declarative Networking
Endpoint: Immutable endpoint definition with:- Path parameters support (
/users/{id}) - Query parameters
- Custom headers
- Cache configuration
- Response parser
- Cache invalidation rules
- Path parameters support (
HttpMethod: Enum for GET, POST, PUT, PATCH, DELETE- Built-in Dio integration with interceptors for:
- Authentication header injection
- Request/response logging (development only)
- Error normalization
- Automatic retry with exponential backoff
State Management
ResourceState<T>: Sealed class for API resource states:ResourceInitial- Not yet fetchedResourceLoading- Request in progressResourceData<T>- Successful response with dataResourceError- Failed with error details
StateManager: Centralized state orchestration usingValueNotifierfor efficient updates- Pattern Matching: Full support for Dart 3 sealed class pattern matching
Local State Slices
LocalSlice<T>: Generic state container for complex UI stateToggleSlice: Boolean state withtoggle()methodCounterSlice: Numeric state withincrement(),decrement(), optional min/max boundsListSlice<T>: List state withadd(),remove(),insert(),clear()methodsMapSlice<K, V>: Map state withset(),remove(),clear()methods
Smart Caching
- Hive-backed binary storage for efficient cache persistence
- TTL-based expiration with configurable duration
- Stale-While-Revalidate pattern support
- Cache presets:
none,short(1m),medium(5m),long(1h),persistent(24h) - Automatic invalidation on mutations via
invalidatesconfiguration
Theming System
ThemeConfig: Design token configuration:- Primary, secondary, tertiary, error colors
- Typography (font family)
- Spacing (border radius, padding)
- Material 3 toggle
ThemeManager: Runtime theme control with:- Light/dark theme generation
toggleTheme()methodsetThemeMode(ThemeMode)method- Automatic persistence of user preference
Error Handling
FKernalError: Normalized error type with:type: Enum categorizing the error (network, server, validation, etc.)message: Human-readable messagestatusCode: HTTP status code (if applicable)originalError: Underlying exceptionstackTrace: Stack trace for debugging
- Error Types:
network,server,unauthorized,forbidden,notFound,validation,rateLimited,timeout,cancelled,parse,unknown - Auto-retry: Configurable retry logic with exponential backoff
Widgets
FKernalBuilder<T>: Reactive data consumption with:- Automatic loading/error/empty states
- Custom builders for each state
onDataandonErrorcallbacks
FKernalActionBuilder<T>: Mutation widget with loading feedbackFKernalLocalBuilder<T>: Local state consumptionFKernalToggleBuilder: Specialized toggle state builderFKernalCounterBuilder: Specialized counter state builderFKernalListBuilder<T>: Specialized list state builderAutoLoadingWidget: Default loading indicatorAutoErrorWidget: Default error display with retryAutoEmptyWidget: Default empty state display
Context Extensions
Zero-boilerplate helpers accessible from any BuildContext:
context.fetchResource<T>(id)- Imperative fetchcontext.refreshResource<T>(id)- Force refreshcontext.performAction<T>(id, payload)- Perform mutationcontext.useResource<T>(id)- Reactive state accesscontext.localState<T>(id)- Local state valuecontext.localSlice<T>(id)- Local slice instancecontext.updateLocal<T>(id, updater)- Update local statecontext.stateManager- State manager instancecontext.storageManager- Storage manager instancecontext.themeManager- Theme manager instancecontext.watchThemeManager()- Reactive theme accesscontext.errorHandler- Error handler instance
Dependencies #
dio: ^5.4.0- HTTP clienthive: ^2.2.3- Local storagehive_flutter: ^1.1.0- Hive Flutter integration
0.1.0 - 2025-12-15 (Pre-release) #
Added #
- Initial pre-release for internal testing
- Core architecture design
- Basic networking and state management
Roadmap #
Planned for 2.0.0 #
- ❌ Code generation for endpoints (compile-time safety)
- ❌ GraphQL first-class support
- ❌ WebSocket/real-time subscriptions
- ❌ Offline-first mode with sync queue
- ❌ DevTools extension for debugging
Under Consideration #
- ❌ Built-in pagination widget
- ❌ Form validation integration
- ❌ Push notification handling
- ❌ Deep linking support