flutter_spine 0.2.2
flutter_spine: ^0.2.2 copied to clipboard
Shared infrastructure for Flutter apps — MVVM base classes, effect bus, scaffold suite, network layer, and error model.
0.2.2 #
Added #
BaseWsGateway— abstract WebSocket gateway for business modules. Delegates connection lifecycle toWsClient; subclasses (Market / Asset / Swap) define type-safe subscription APIs and topic encoding.WsClientConfig.headersProvider— dynamic headers callback. Called on every connect / reconnect to fetch the latest token, eliminating the need to rebuild config after auth refresh.WsClientConfig.queryParamsProvider— dynamic query string callback. Same pattern asheadersProvider, for backends that pass auth tokens via URL query params (?token=xxx) instead of HTTP headers. Manual string concatenation avoids Dart SDKUri.replace()port:0bug.WsClientConfig.onAuthExpired+isAuthCloseCode— token expiry auto-refresh. When the server closes with an auth close code (e.g. 4001),DefaultWsClientcallsonAuthExpiredwith single-flight guarantee, then reconnects with the new token. Unsuccessful refresh transitions toWsFailed.- Close code handling in
DefaultWsClient— normal close codes (1000, 1001) now transition toWsDisconnectedwithout triggering auto-reconnect. All other close codes continue to trigger standard reconnect. - Unified
IOWebSocketChannelin_defaultFactory— always usesIOWebSocketChannel.connect(), no longer implicitly switches betweenWebSocketChannel.connect()andIOWebSocketChannelbased on parameter presence. Behavior is now consistent regardless of whether headers/queryParams are configured. WsTopicRouter.simple()— factory constructor for standard pub/sub protocols where channel name equals topic name. Auto-generatestopicExtractor,subscribeFrameBuilder, andunsubscribeFrameBuilderfrom a singlechannelKeyparameter.WsModuleRegistry+WsModuleConfig— registration pattern for WebSocket modules. Each business module defines aWsModuleConfiginstance;WsModuleRegistry.build()maps URIs to configs, replacing hand-written if-else chains inwsConfigBuilderProvideroverrides.- CLI
ws-gatewaycommand —flutter_spine:new ws-gateway <name>generates topic / topic_router / ws_gateway / providers four-file scaffold.
Changed #
- Breaking:
WsClientConfig.headersreplaced byheadersProvider(Map<String, dynamic> Function()?). Existing code must change fromheaders: {'key': 'val'}toheadersProvider: () => {'key': 'val'}. WsClientConfigconstructor now acceptsheadersProvider,queryParamsProvider,onAuthExpired, andisAuthCloseCode(all optional)._defaultFactoryno longer branches on parameter presence — always constructsIOWebSocketChannelfor consistent behavior.
Tests #
- 7 new test cases for close code handling and auth refresh (33 total in
test/network/ws/).
Example #
demo_market_ws/— fullMarketWsGatewayimplementation: topic encoding/decode (MarketTopic), protocol adapter (marketTopicRouter), RiverpodStreamProvider.autoDispose.familyfor automatic subscription lifecycle, and interactive lifecycle demo page.demo_asset_ws/&demo_swap_ws/— showcase multi-module Gateway pattern. All three modules share the same auth/heartbeat/reconnect config via a_sharedWsConfigfactory inmain.dart, each overriding only its owntopicRouter.main.dartnow demonstratesFlutterSpineConfig.extraOverrideswithWsModuleRegistry.build()replacing the if-else chain.
0.1.2 #
Added #
PagedListView.scrollViewBuilder— embed the list in aCustomScrollViewwith extra slivers.PagedListView.enableLoadMore— disable load-more footer, keep only pull-to-refresh.AppListPageScaffold.scrollViewBuilder/enableLoadMore— forwarded toPagedListView.PagedScrollViewBuildertypedef.- Example demo pages:
/demos/paged-list,/demos/app-list.
Fixed #
DioExceptionType.transformTimeoutnot found with dio 5.9.x — replaced withdefault/_fallback for forward compatibility.
0.1.1 #
Added #
- Scaffold CLI (
flutter_spine:new). generator_templates.dart— riverpod_generator support.FeatureCommand—flutter_spine:new featureone-key whole feature generation.BootstrapCommand—flutter_spine:new bootstrapapp skeleton.FlutterCoreDiagnosticsBanner.MaterialDefaultEffectHandlerctor overrides.mixin-based API:ViewModelMixin,AsyncViewModelMixin, family variants.
Changed #
- CLI templates now use
{{Name}}/{{name}}/{{name_snake}}/{{name-kebab}}/{{Title}}naming conventions. - Renamed
FlutterCoretoFlutterSpine,FlutterCoreConfigtoFlutterSpineConfig.
0.1.0 #
- Initial release.
error/: sealedAppExceptionhierarchy +safeApiCallnormalization.network/:ChannelClientMethodChannel wrapper.pagination/:PagedState+PagedNotifierMixin(family + noArg).filter/:FilterNotifierbase class.presentation/:AsyncBuilder+AsyncValueextensions.logging/:AppLoggerinterface +PrettyAppLoggerimplementation.observers/:ErrorObserver(toast callback injection) +LogObserver.storage/:KeyValueStorageabstraction +HiveStorage+keyValueStorageProvider.theme/:AppThemeExtension+ThemeModeNotifier.utils/:num_ext,string_ext,date_ext,iterable_ext,context_ext.