object_extension 1.0.1 copy "object_extension: ^1.0.1" to clipboard
object_extension: ^1.0.1 copied to clipboard

unlistedoutdated

The package extends the functionality of the base class Object

example/lib/example.dart

///
/// Package examples
///
import 'package:object_extension/object_extension.dart';


///
/// Main function
///
void main() {
  /// Calls to example functions of all package methods
  print('----- toStructuredString() example -----');
  toStructuredString();
}


///
/// toStructuredString() example
///
void toStructuredString() {
  final sampleObject = {
    'value1': 'v1',
    10: 20.5,
    'value2': 'v2',
    'map1': {
      'value7': 'v7',
      'list4': ['string1', 'string2'],
      'value8': 'v8'
    },
    'list1': [0, 2, 3, 44, 55],
    'set1': {
      5,
      {
        'list2': ['a', 'b']
      },
      55
    },
    'list3': [
      {'value3': 'v3', 'value4': 'v4'},
      {'value5': 'v5', 'value6': 'v6'},
      [
        1.3,
        [100, 'string3'],
        2.8,
        {666, 777},
        4,
        5
      ],
    ]
  };

  print('Sample Object:\n$sampleObject\n');

  final structuredObject = sampleObject.toStructuredString();
  print('\nStructured Object:\n$structuredObject');

  final structuredObject2 = sampleObject.toStructuredString(withTypes: true);
  print('\nStructured Object with types:\n$structuredObject2');

  print('\nSome more examples ...');
  print(3.14.toStructuredString() + '\n');
  print(3.14.toStructuredString(withTypes: true) + '\n');
  print({1, 2, 3, 4}.toStructuredString() + '\n');
  print({
    {'key1': 'val1', 'key2': 'val2'},
    [1, 2],
    2
  }.toStructuredString(
      stringQuote: '"', keyQuote: '"', withTypes: false, tabWidth: 5));
}
0
likes
0
pub points
7%
popularity

Publisher

unverified uploader

The package extends the functionality of the base class Object

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on object_extension