Index: pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart |
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart |
index 59fc1c0e8292a773c0a752bf681e9952601eca12..6ca579ff5049645c803814a7c7bb8127a62cb1b7 100644 |
--- a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart |
+++ b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart |
@@ -6,7 +6,6 @@ library services.completion.contributor.dart.arglist; |
import 'dart:async'; |
-import 'package:analysis_server/src/ide_options.dart'; |
import 'package:analysis_server/src/protocol_server.dart' |
hide Element, ElementKind; |
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart'; |
@@ -253,6 +252,21 @@ class ArgListContributor extends DartCompletionContributor { |
completion += ': '; |
} |
int selectionOffset = completion.length; |
+ |
+ // Optionally add Flutter child widget details. |
+ Element element = parameter.enclosingElement; |
+ if (element is ConstructorElement) { |
+ if (isFlutterWidget(element.enclosingElement) && |
+ parameter.name == 'children') { |
+ String value = getDefaultStringParameterValue(parameter); |
+ if (value != null) { |
+ completion += value; |
+ // children: <Widget>[] |
+ selectionOffset = completion.length - 1; // before closing ']' |
+ } |
+ } |
+ } |
+ |
if (appendComma) { |
completion += ','; |
} |
@@ -271,22 +285,6 @@ class ArgListContributor extends DartCompletionContributor { |
suggestion.element = convertElement(parameter); |
} |
- String defaultValue = _getDefaultValue(parameter, request.ideOptions); |
- if (defaultValue != null) { |
- StringBuffer sb = new StringBuffer(); |
- sb.write('${parameter.name}: '); |
- int offset = sb.length; |
- sb.write(defaultValue); |
- if (appendComma) { |
- sb.write(','); |
- } |
- suggestion.defaultArgumentListString = sb.toString(); |
- suggestion.defaultArgumentListTextRanges = [ |
- offset, |
- defaultValue.length |
- ]; |
- } |
- |
suggestions.add(suggestion); |
} |
} |
@@ -316,19 +314,6 @@ class ArgListContributor extends DartCompletionContributor { |
} |
} |
- String _getDefaultValue(ParameterElement param, IdeOptions options) { |
- if (options?.generateFlutterWidgetChildrenBoilerPlate == true) { |
- Element element = param.enclosingElement; |
- if (element is ConstructorElement) { |
- if (isFlutterWidget(element.enclosingElement) && |
- param.name == 'children') { |
- return getDefaultStringParameterValue(param); |
- } |
- } |
- } |
- return null; |
- } |
- |
bool _isFollowedByAComma(DartCompletionRequest request) { |
// new A(^); NO |
// new A(one: 1, ^); NO |