ilkersevim_safe_parse 0.1.4
ilkersevim_safe_parse: ^0.1.4 copied to clipboard
Convert dynamic and JSON-like values into typed Dart values without crashes, using predictable null and fallback behavior.
ilkersevim_safe_parse #
Safe parsing helpers for dynamic / JSON-like values. Dependency-free beyond the
Dart SDK (dart:developer for parse failure logs).
Why use this package? #
- Replace repeated type checks in repositories, mappers, caches, and snapshot readers with shared conversion rules.
- Tolerate missing or unexpected values through predictable null and fallback results.
- Parse common scalar and collection shapes without coupling code to Flutter or a serialization framework.
License: Apache-2.0. Issues: github.com/redjadet/ilkersevim_safe_parse/issues.
Installation #
dependencies:
ilkersevim_safe_parse: ^0.1.1
Requires Dart >=3.12.0.
Usage #
import 'package:ilkersevim_safe_parse/ilkersevim_safe_parse.dart';
final String? name = stringFromDynamic(json['name']);
final int? count = intFromDynamic(json['count']);
final Map<String, dynamic>? map = mapFromDynamic(raw);
mapFromDynamic returns null when the value is not a map or when any key is
not a String (it never throws).
API #
stringFromDynamic/stringFromDynamicTrimmedintFromDynamic/doubleFromDynamic/boolFromDynamicmapFromDynamic/listFromDynamicparseMapOfMaps