-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
50 lines (38 loc) · 1.82 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// ignore_for_file: avoid_print
import 'dart:convert';
import 'package:dart_format/dart_format.dart';
void main(List<String> arguments)
{
const String unformattedText = 'class C{void m(){print("Hello world");}}';
print('Unformatted text:');
print('$unformattedText\n');
final Config configAll = Config.all();
final Formatter formatter = Formatter(configAll);
final String formattedText = formatter.format(unformattedText);
print('Formatted text:');
print(formattedText);
final Config configAllMinusSemicolon = Config.all(addNewLineAfterSemicolon: false);
print('Config "all settings enabled" with AddNewLineAfterSemicolon turned off:');
print(jsonEncode(configAllMinusSemicolon.toJson()));
print('');
final Config configNonePlusSemicolon = Config.none(addNewLineAfterSemicolon: true);
print('Config "no settings enabled" with AddNewLineAfterSemicolon turned on:');
print(jsonEncode(configNonePlusSemicolon.toJson()));
}
/*
Output:
Unformatted text:
class C{void m(){print("Hello world");}}
Formatted text:
class C
{
void m()
{
print("Hello world");
}
}
Config "all settings enabled" with AddNewLineAfterSemicolon turned off:
{"AddNewLineAfterClosingBrace":true,"AddNewLineAfterOpeningBrace":true,"AddNewLineAfterSemicolon":false,"AddNewLineAtEndOfText":true,"AddNewLineBeforeClosingBrace":true,"AddNewLineBeforeOpeningBrace":true,"IndentationSpacesPerLevel":4,"MaxEmptyLines":1,"RemoveTrailingCommas":true}
Config "no settings enabled" with AddNewLineAfterSemicolon turned on:
{"AddNewLineAfterClosingBrace":false,"AddNewLineAfterOpeningBrace":false,"AddNewLineAfterSemicolon":true,"AddNewLineAtEndOfText":false,"AddNewLineBeforeClosingBrace":false,"AddNewLineBeforeOpeningBrace":false,"IndentationSpacesPerLevel":-1,"MaxEmptyLines":-1,"RemoveTrailingCommas":false}
*/