W3cubDocs

/Dart 2

JsonEncoder.withIndent constructor

const JsonEncoder.withIndent(String indent, [ dynamic toEncodable(dynamic object) ])

Creates a JSON encoder that creates multi-line JSON.

The encoding of elements of lists and maps are indented and put on separate lines. The indent string is prepended to these elements, once for each level of indentation.

If indent is null, the output is encoded as a single line.

The JSON encoder handles numbers, strings, booleans, null, lists and maps with string keys directly.

Any other object is attempted converted by toEncodable to an object that is of one of the convertible types.

If toEncodable is omitted, it defaults to calling .toJson() on the object.

Implementation

const JsonEncoder.withIndent(this.indent, [toEncodable(object)])
    : _toEncodable = toEncodable;

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-convert/JsonEncoder/JsonEncoder.withIndent.html