configwire 0.0.3
configwire: ^0.0.3 copied to clipboard
Pure-Dart ConfigWire client (fetch, cache, typed getters, realtime).
0.0.3 #
Added #
get<T>(lib/src/configwire_base.dart): generic typed getter. Returns the value forkeyasT, orfallbackwhen missing or mistyped. Coerces ints viatoDouble()whenTisdouble(parity withgetDouble). With nofallback, a missing/mistyped key returnsnullfor nullableTand throws a cast error for non-nullableT. Maps and lists are returned as defensive copies. Note: server collections decode asList<dynamic>/Map<String, dynamic>, so a directget<List<String>>over server values misses — usegetList/getMapfor those.getList<T>(lib/src/configwire_base.dart): typed list getter. Eagerly checks every element (plusint->doublecoercion whenTisdouble); defaultsfallbacktoconst []. On any error (missing key, mistyped value, or mistyped element) returnsfallback; whenfallbackis null the error is rethrown.getMap<T>(lib/src/configwire_base.dart): typed map getter. Eagerly checks every entry isString->T(plusint->doublecoercion whenTisdouble); defaultsfallbacktoconst {}. On any error (missing key, mistyped value, non-String key, or mistyped entry) returnsfallback; whenfallbackis null the error is rethrown.
Changed #
- Breaking:
getJSON(key)is removed. It returned an untypedMap<String, Object?>(or{}on miss/mistype). Migrate:getJSON('k')->getMap<Object?>('k'), or pick a value type such asgetMap<int>('k')/getMap<String>('k').
0.0.2 #
Added #
TargetingContext(lib/src/targeting.dart, exported frompackage:configwire/configwire.dart): carriesuserId,platform,appVersion,locale,country,customAttrsfor server-side rule evaluation. Empty fields are omitted from the fetch query;customAttrsis sent as?attrs=<json>. IncludescopyWith,empty, andtoQueryParameters().
Changed #
- Breaking:
fetchAndActivateandensureInitializednow take only{TargetingContext? context, bool force}. The flattenedString? userId/platform/appVersion/locale/countryandMap? customAttrsparams are removed. Migrate:fetchAndActivate(userId: 'u')->fetchAndActivate(context: const TargetingContext(userId: 'u')); single-field update ->fetchAndActivate(context: cw.targeting.copyWith(platform: 'ios')). - Targeting is sticky: a non-null
contextreplacescw.targetingfor this and all future fetches, includingconnectRealtimepoll/SSE refreshes (fetchAndActivate(force: true)reuses the stored context).setTargetingreplaces the stored context without fetching.
0.0.1 #
- Initial release of the pure-Dart
configwireclient.