@@ -1,4 +1,4 @@
Loading
1 -
import 'dart:convert' as dartConvert;
1 +
import 'dart:convert' as dart_convert;
2 2
3 3
import 'package:json_string/src/functions.dart';
4 4
import 'package:json_string/src/utils.dart';
@@ -44,9 +44,9 @@
Loading
44 44
  /// Attention: this is just a wrapper around the Dart built-in
45 45
  /// function `json.encode()`, you should use this in special cases only.
46 46
  /// Check the other encoding functions for more common usages.
47 -
  JsonString.encode(Object value, {encoder(object)})
48 -
      : this.source = _encodeSafely(value, encoder: encoder),
49 -
        this._cachedValue = null;
47 +
  JsonString.encode(Object value, {Function(Object object) encoder})
48 +
      : source = _encodeSafely(value, encoder: encoder),
49 +
        _cachedValue = null;
50 50
51 51
  /// Constructs a [JsonString] converting [value] into a valid JSON
52 52
  /// primitive value.
@@ -105,7 +105,8 @@
Loading
105 105
  /// The JSON data directly decoded as a dynamic type.
106 106
  ///
107 107
  /// (this is the most general one.)
108 -
  dynamic get decodedValue => wrapJsonUtilOperation(() => _decodedValue.value);
108 +
  dynamic get decodedValue =>
109 +
      wrapJsonUtilOperation<dynamic>(() => _decodedValue.value);
109 110
110 111
  /// The JSON data decoded as an instance of [Map<String, dynamic>].
111 112
  ///
@@ -182,7 +183,7 @@
Loading
182 183
  // <<private getters>>
183 184
184 185
  DecodedValue get _decodedValue =>
185 -
      (_cachedValue != null) ? _cachedValue : DecodedValue.from(this.source);
186 +
      (_cachedValue != null) ? _cachedValue : DecodedValue.from(source);
186 187
187 188
  // <<private static methods>>
188 189
@@ -193,7 +194,7 @@
Loading
193 194
  }
194 195
195 196
  static String _encode(Object value, {Function(Object) encoder}) {
196 -
    return dartConvert.jsonEncode(value, toEncodable: encoder);
197 +
    return dart_convert.jsonEncode(value, toEncodable: encoder);
197 198
  }
198 199
199 200
  static String _encodeSafely(Object value, {Function(Object) encoder}) {

@@ -9,6 +9,6 @@
Loading
9 9
/// An object that can be encoded into some valid JSON.
10 10
mixin Jsonable implements _Jsonable {
11 11
  Map<String, dynamic> toMap() {
12 -
    return this.toJson();
12 +
    return toJson();
13 13
  }
14 14
}

@@ -2,22 +2,24 @@
Loading
2 2
import 'package:json_string/src/jsonable.dart';
3 3
import 'package:json_util/json_util.dart';
4 4
5 +
/// Makes an object ready to be encoded.
5 6
Map<String, dynamic> disassembleObject<T extends Object>(T value,
6 7
    {JsonObjectEncoder<T> builder}) {
7 -
  final T dartObject = value;
8 +
  final dartObject = value;
8 9
  if (builder != null) {
9 10
    return builder(dartObject);
10 11
  } else if (dartObject is Jsonable) {
11 12
    return dartObject.toMap();
12 13
  }
13 14
  throw JsonEncodingError(
14 -
      "this is not a Jsonable object: provide a valid encoder.");
15 +
      'this is not a Jsonable object: provide a valid encoder.');
15 16
}
16 17
18 +
/// Makes a list of objects ready to be encoded.
17 19
List<Map<String, dynamic>> disassembleObjectList<T extends Object>(
18 20
    List<T> value,
19 21
    {JsonObjectEncoder<T> builder}) {
20 -
  final List<T> dartObjectList = value;
22 +
  final dartObjectList = value;
21 23
  return dartObjectList.map((e) {
22 24
    if (e == null) {
23 25
      return e as Map<String, dynamic>;
@@ -26,7 +28,8 @@
Loading
26 28
  }).toList();
27 29
}
28 30
29 -
T wrapJsonUtilOperation<T>(T exec()) {
31 +
/// Wrap a generic operation from json_util library
32 +
T wrapJsonUtilOperation<T>(T Function() exec) {
30 33
  try {
31 34
    return exec();
32 35
  } on DecodedValueError catch (e) {
Files Coverage
lib/src 100.00%
Project Totals (3 files) 100.00%
Untitled

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading