object_extension 1.0.1 object_extension: ^1.0.1 copied to clipboard
The package extends the functionality of the base class Object
///
/// 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));
}