flutter_shared_utilities 1.0.2
flutter_shared_utilities: ^1.0.2 copied to clipboard
A comprehensive Flutter utilities package with extensions, models, and utility functions.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.2 #
Added #
-
Enhanced Serialization Extensions: Major improvements to
fromSerializable<T>()methodList<DateTime>support - Convert arrays of ISO strings, timestamps, and DateTime objectsList<Duration>support - Convert arrays of microsecond integers, strings, and Duration objectsMap<String, DateTime>support - Handle JSON objects with date fieldsMap<String, Duration>support - Handle configuration objects with time values- Early error detection with
assert()statements in debug mode - Comprehensive type validation with
_isSupportedType()helper method
-
Safe Conversion Helpers: New helper methods for robust type conversion
_safeDateTime()- Handles ISO strings, timestamps, with Unix epoch fallback_safeDuration()- Handles microseconds, strings, with zero duration fallback- Graceful error handling for all invalid inputs
-
Developer Experience Improvements:
- Clear, detailed assert error messages guide developers to supported types
- Immediate feedback during development for unsupported type usage
- Better documentation in error messages with examples
Changed #
-
Simplified Architecture: Removed complex recursive type conversion logic
- Direct type checking for better performance and maintainability
- Eliminated
_extractGenericType()and_extractMapValueType()helper methods - Removed
_convertToType()recursive method for cleaner code - Streamlined error handling with assert-first approach
-
Improved Type Safety: Enhanced type checking and conversion
- Fixed string-to-int conversion to handle decimal strings like "95.5" → 95
- Better handling of mixed data types in collections
- More robust JSON string parsing for typed collections
Fixed #
- Type casting issues with
Map<String, DateTime>andMap<String, Duration> - Decimal string parsing in
_safeInt()method (e.g., "95.5" now converts to 95) - Eliminated runtime
UnsupportedErrorthrows in favor of development-time asserts
Technical Details #
- Supported Simple Types:
int,double,String,bool,DateTime,Duration,Uri,Object?,dynamic - Supported List Types:
List<int>,List<double>,List<String>,List<bool>,List<DateTime>,List<Duration>,List<Object?> - Supported Map List Types:
List<Map<String, Object?>>,List<Map<String, dynamic>> - Supported Map Types:
Map<String, int>,Map<String, double>,Map<String, String>,Map<String, bool>,Map<String, DateTime>,Map<String, Duration>,Map<String, Object?>,Map<String, dynamic>
Migration Notes #
- No breaking changes - all existing functionality preserved
- Assert statements only trigger in debug mode, no impact on production builds
- New DateTime/Duration collection support is additive
- Developers using unsupported nested types will now get immediate feedback via asserts
1.0.1 #
Added #
- Comprehensive documentation and examples in README
- Production-ready package structure
- Badges for pub.dev, license, and Flutter version
- Detailed API reference with code examples
- Contributing guidelines
- Issue and feedback links
Changed #
- Updated package description for better clarity
- Enhanced documentation with emojis and better formatting
- Improved code examples with practical use cases
Fixed #
- Package naming consistency (flutter_shared_utilities)
- Documentation structure and completeness
1.0.0 #
Added #
-
String Extensions: Case-insensitive string operations, JSON validation, and utility methods
compareWithoutCase()- Case-insensitive string comparisonstartsWithIgnoreCase()- Case-insensitive prefix checkingcontainsWithoutCase()- Case-insensitive substring searchisNullString,isNullEmpty- Null and empty string checksisJsonObject,isJsonArray,isJsonPrimitive- JSON format validation
-
List Extensions: Smart list operations with duplicate prevention
insertIfNotExists()- Insert item only if it doesn't existaddAllIfNotExists()- Add multiple items, skipping duplicatesremoveIfExist()- Remove item if it exists in the list- Custom equality checker support for complex objects
-
Safe Parser: Robust JSON parsing with error handling
safeEncodeJson()- Safe JSON encoding with error handlingsafeDecodeJson()- Safe JSON decoding with validationparseIterable()- Type-safe iterable parsing
-
Base Data Model: Abstract class for consistent data handling
fromMap()- Convert Map to model instancetoMap()- Convert model to MapfromJson()- Convert JSON string to model instancetoJson()- Convert model to JSON string- Equatable integration for value equality
-
Object Serialization Extensions: Safe type conversion utilities
fromSerializable<T>()- Safe type conversion with null safety
-
Interfaces: Abstract interfaces for common services
AppLogger- Application logging interfaceConnectivityService- Network connectivity management interface
-
Utility Functions: Additional helper utilities
safeDebugLog()- Safe debug logging with stack trace support
-
Color Extensions: Enhanced color manipulation utilities
-
Map Extensions: Safe map parsing and utility functions
-
Iterable Extensions: Utility functions for iterable collections
Technical Features #
- Full null safety support
- Comprehensive type checking
- Error handling and safe parsing
- Custom lint rules for code quality
- Flutter 3.0+ compatibility
- Dart SDK 3.8.1+ support
Dependencies #
equatable: ^2.0.7- For value equalitycollection: ^1.19.1- For collection utilitiescustom_lint: ^0.7.5- For custom linting rulesflutter_custom_lints: ^1.0.2- For Flutter-specific linting