@@ -95,34 +95,55 @@ class Doctor {
95
95
return buffer.toString ();
96
96
}
97
97
98
- /// Print verbose information about the state of installed tooling.
99
- Future <bool > diagnose ({ bool androidLicenses: false }) async {
98
+ /// Print information about the state of installed tooling.
99
+ Future <bool > diagnose ({ bool androidLicenses: false , bool verbose : true }) async {
100
100
if (androidLicenses)
101
101
return AndroidWorkflow .runLicenseManager ();
102
102
103
+ if (! verbose) {
104
+ printStatus ('Doctor summary (to see all details, run flutter doctor -v):' );
105
+ }
103
106
bool doctorResult = true ;
107
+ int issues = 0 ;
104
108
105
109
for (DoctorValidator validator in validators) {
106
110
final ValidationResult result = await validator.validate ();
107
111
108
- if (result.type == ValidationType .missing)
112
+ if (result.type == ValidationType .missing) {
109
113
doctorResult = false ;
114
+ }
115
+ if (result.type != ValidationType .installed) {
116
+ issues += 1 ;
117
+ }
110
118
111
119
if (result.statusInfo != null )
112
120
printStatus ('${result .leadingBox } ${validator .title } (${result .statusInfo })' );
113
121
else
114
122
printStatus ('${result .leadingBox } ${validator .title }' );
115
123
116
124
for (ValidationMessage message in result.messages) {
117
- final String text = message.message.replaceAll ('\n ' , '\n ' );
118
- if (message.isError) {
119
- printStatus (' ✗ $text ' , emphasis: true );
120
- } else {
121
- printStatus (' • $text ' );
125
+ if (message.isError || message.isHint || verbose == true ) {
126
+ final String text = message.message.replaceAll ('\n ' , '\n ' );
127
+ if (message.isError) {
128
+ printStatus (' ✗ $text ' , emphasis: true );
129
+ } else if (message.isHint) {
130
+ printStatus (' ! $text ' );
131
+ } else {
132
+ printStatus (' • $text ' );
133
+ }
122
134
}
123
135
}
136
+ if (verbose)
137
+ printStatus ('' );
138
+ }
124
139
140
+ // Make sure there's always one line before the summary even when not verbose.
141
+ if (! verbose)
125
142
printStatus ('' );
143
+ if (issues > 0 ) {
144
+ printStatus ('! Doctor found issues in $issues categor${issues > 1 ? "ies" : "y" }.' );
145
+ } else {
146
+ printStatus ('• No issues found!' );
126
147
}
127
148
128
149
return doctorResult;
@@ -159,7 +180,10 @@ abstract class DoctorValidator {
159
180
Future <ValidationResult > validate ();
160
181
}
161
182
183
+
162
184
class ValidationResult {
185
+ /// [ValidationResult.type] should only equal [ValidationResult.installed]
186
+ /// if no [messages] are hints or errors.
163
187
ValidationResult (this .type, this .messages, { this .statusInfo });
164
188
165
189
final ValidationType type;
@@ -168,20 +192,26 @@ class ValidationResult {
168
192
final List <ValidationMessage > messages;
169
193
170
194
String get leadingBox {
171
- if (type == ValidationType .missing)
172
- return '[✗]' ;
173
- else if (type == ValidationType .installed)
174
- return '[✓]' ;
175
- else
176
- return '[-]' ;
195
+ assert (type != null );
196
+ switch (type) {
197
+ case ValidationType .missing:
198
+ return '[✗]' ;
199
+ case ValidationType .installed:
200
+ return '[✓]' ;
201
+ case ValidationType .partial:
202
+ return '[!]' ;
203
+ }
204
+ return null ;
177
205
}
178
206
}
179
207
180
208
class ValidationMessage {
181
- ValidationMessage (this .message) : isError = false ;
182
- ValidationMessage .error (this .message) : isError = true ;
209
+ ValidationMessage (this .message) : isError = false , isHint = false ;
210
+ ValidationMessage .error (this .message) : isError = true , isHint = false ;
211
+ ValidationMessage .hint (this .message) : isError = false , isHint = true ;
183
212
184
213
final bool isError;
214
+ final bool isHint;
185
215
final String message;
186
216
187
217
@override
@@ -512,7 +542,7 @@ class DeviceValidator extends DoctorValidator {
512
542
if (diagnostics.isNotEmpty) {
513
543
messages = diagnostics.map ((String message) => new ValidationMessage (message)).toList ();
514
544
} else {
515
- messages = < ValidationMessage > [new ValidationMessage ( 'None ' )];
545
+ messages = < ValidationMessage > [new ValidationMessage . hint ( 'No devices available ' )];
516
546
}
517
547
} else {
518
548
messages = await Device .descriptions (devices)
0 commit comments