Skip to content

Commit d40ee21

Browse files
authored
remove unnecessary .toString() (#103226)
1 parent a1a46c9 commit d40ee21

File tree

29 files changed

+58
-58
lines changed

29 files changed

+58
-58
lines changed

dev/bots/prepare_package.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ class ProcessRunner {
160160
}
161161
} on ProcessException catch (e) {
162162
final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} '
163-
'failed with:\n${e.toString()}';
163+
'failed with:\n$e';
164164
throw PreparePackageException(message);
165165
} on ArgumentError catch (e) {
166166
final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} '
167-
'failed with:\n${e.toString()}';
167+
'failed with:\n$e';
168168
throw PreparePackageException(message);
169169
}
170170

dev/bots/test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ Future<void> _dartRunTest(String workingDirectory, {
16541654
if (coverage != null)
16551655
'--coverage=$coverage',
16561656
if (perTestTimeout != null)
1657-
'--timeout=${perTestTimeout.inMilliseconds.toString()}ms',
1657+
'--timeout=${perTestTimeout.inMilliseconds}ms',
16581658
if (testPaths != null)
16591659
for (final String testPath in testPaths)
16601660
testPath,

dev/bots/unpublish_package.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ class ProcessRunner {
190190
}
191191
} on ProcessException catch (e) {
192192
final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} '
193-
'failed with:\n${e.toString()}';
193+
'failed with:\n$e';
194194
throw UnpublishException(message);
195195
} on ArgumentError catch (e) {
196196
final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} '
197-
'failed with:\n${e.toString()}';
197+
'failed with:\n$e';
198198
throw UnpublishException(message);
199199
}
200200

dev/conductor/core/lib/src/version.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ class Version {
278278
final String branchX = branchMatch.group(1)!;
279279
if (x != int.tryParse(branchX)) {
280280
throw ConductorException(
281-
'Parsed version ${toString()} has a different x value than candidate '
281+
'Parsed version $this has a different x value than candidate '
282282
'branch $candidateBranch',
283283
);
284284
}
285285
final String branchY = branchMatch.group(2)!;
286286
if (y != int.tryParse(branchY)) {
287287
throw ConductorException(
288-
'Parsed version ${toString()} has a different y value than candidate '
288+
'Parsed version $this has a different y value than candidate '
289289
'branch $candidateBranch',
290290
);
291291
}
@@ -295,7 +295,7 @@ class Version {
295295
final String branchM = branchMatch.group(3)!;
296296
if (m != int.tryParse(branchM)) {
297297
throw ConductorException(
298-
'Parsed version ${toString()} has a different m value than candidate '
298+
'Parsed version $this has a different m value than candidate '
299299
'branch $candidateBranch with type $type',
300300
);
301301
}

dev/devicelab/lib/framework/utils.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ void checkDirectoryNotExists(String directory) {
758758
void checkCollectionContains<T>(Iterable<T> values, Iterable<T> collection) {
759759
for (final T value in values) {
760760
if (!collection.contains(value)) {
761-
throw TaskResult.failure('Expected to find `$value` in `${collection.toString()}`.');
761+
throw TaskResult.failure('Expected to find `$value` in `$collection`.');
762762
}
763763
}
764764
}

dev/integration_tests/android_views/lib/motion_events_page.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
189189
if (!mounted) {
190190
return;
191191
}
192-
showMessage(context, 'Failed saving ${e.toString()}');
192+
showMessage(context, 'Failed saving $e');
193193
}
194194
}
195195

@@ -309,6 +309,6 @@ class TouchEventDiff extends StatelessWidget {
309309
for (int i = 0; i < coords.length; i++) {
310310
buffer.write('p$i x: ${coords[i]['x']} y: ${coords[i]['y']}, pressure: ${coords[i]['pressure']} ');
311311
}
312-
print(buffer.toString());
312+
print(buffer);
313313
}
314314
}

dev/integration_tests/flutter_gallery/lib/demo/material/icons_demo.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class _IconsDemoCard extends StatelessWidget {
101101
TableRow _buildIconRow(double size) {
102102
return TableRow(
103103
children: <Widget> [
104-
_centeredText('${size.floor().toString()} ${icon.toString()}'),
104+
_centeredText('${size.floor()} $icon'),
105105
_buildIconButton(size, icon, true),
106106
_buildIconButton(size, icon, false),
107107
],
@@ -122,9 +122,9 @@ class _IconsDemoCard extends StatelessWidget {
122122
children: <TableRow> [
123123
TableRow(
124124
children: <Widget> [
125-
_centeredText('Size ${icon.toString()}'),
126-
_centeredText('Enabled ${icon.toString()}'),
127-
_centeredText('Disabled ${icon.toString()}'),
125+
_centeredText('Size $icon'),
126+
_centeredText('Enabled $icon'),
127+
_centeredText('Disabled $icon'),
128128
]
129129
),
130130
_buildIconRow(18.0),

dev/integration_tests/hybrid_android_views/lib/motion_events_page.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
171171
if (!mounted) {
172172
return;
173173
}
174-
showMessage(context, 'Failed saving ${e.toString()}');
174+
showMessage(context, 'Failed saving $e');
175175
}
176176
}
177177

@@ -281,6 +281,6 @@ class TouchEventDiff extends StatelessWidget {
281281
for (int i = 0; i < coords.length; i++) {
282282
buffer.write('p$i x: ${coords[i]['x']} y: ${coords[i]['y']}, pressure: ${coords[i]['pressure']} ');
283283
}
284-
print(buffer.toString());
284+
print(buffer);
285285
}
286286
}

dev/tools/examples_smoke_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ Future<String> runCommand(
228228
);
229229
} on ProcessException catch (e) {
230230
stderr.writeln('Running "${cmd.join(' ')}" in ${workingDirectory.path} '
231-
'failed with:\n${e.toString()}');
231+
'failed with:\n$e');
232232
exitCode = 2;
233233
return utf8.decode(stdoutOutput);
234234
} on ArgumentError catch (e) {
235235
stderr.writeln('Running "${cmd.join(' ')}" in ${workingDirectory.path} '
236-
'failed with:\n${e.toString()}');
236+
'failed with:\n$e');
237237
exitCode = 3;
238238
return utf8.decode(stdoutOutput);
239239
}

dev/tools/gen_defaults/lib/template.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,6 @@ abstract class TokenTemplate {
149149

150150
/// Generate a [TextTheme] text style name for the given component token.
151151
String textStyle(String componentToken) {
152-
return '$textThemePrefix${tokens["$componentToken.text-style"]!.toString()}';
152+
return '$textThemePrefix${tokens["$componentToken.text-style"]}';
153153
}
154154
}

dev/tools/update_icons.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ void _generateIconDemo(File demoFilePath, Map<String, String> tokenPairMap) {
419419
home: Scaffold(
420420
body: Wrap(
421421
children: const [
422-
${newIconUsages.toString()}
422+
$newIconUsages
423423
],
424424
),
425425
),

packages/flutter/lib/src/foundation/assertions.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class FlutterErrorDetails with Diagnosticable {
619619
} else if (exception is Error || exception is Exception) {
620620
longMessage = exception.toString();
621621
} else {
622-
longMessage = ' ${exception.toString()}';
622+
longMessage = ' $exception';
623623
}
624624
longMessage = longMessage.trimRight();
625625
if (longMessage.isEmpty)

packages/flutter/lib/src/material/tabs.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ class _IndicatorPainter extends CustomPainter {
403403
if (!(rect.size >= insets.collapsedSize)) {
404404
throw FlutterError(
405405
'indicatorPadding insets should be less than Tab Size\n'
406-
'Rect Size : ${rect.size}, Insets: ${insets.toString()}',
406+
'Rect Size : ${rect.size}, Insets: $insets',
407407
);
408408
}
409409
return insets.deflateRect(rect);

packages/flutter/lib/src/rendering/box.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,7 @@ abstract class RenderBox extends RenderObject {
19751975
/// of those functions, call [markNeedsLayout] instead to schedule a layout of
19761976
/// the box.
19771977
Size get size {
1978-
assert(hasSize, 'RenderBox was not laid out: ${toString()}');
1978+
assert(hasSize, 'RenderBox was not laid out: $this');
19791979
assert(() {
19801980
final Size? size = _size;
19811981
if (size is _DebugSize) {

packages/flutter/lib/src/widgets/framework.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -2829,8 +2829,8 @@ class BuildOwner {
28292829
ErrorSummary('Multiple widgets used the same GlobalKey.'),
28302830
ErrorDescription(
28312831
'The key $key was used by multiple widgets. The parents of those widgets were:\n'
2832-
'- ${older.toString()}\n'
2833-
'- ${newer.toString()}\n'
2832+
'- $older\n'
2833+
'- $newer\n'
28342834
'A GlobalKey can only be specified on one widget at a time in the widget tree.',
28352835
),
28362836
]);
@@ -2840,7 +2840,7 @@ class BuildOwner {
28402840
ErrorDescription(
28412841
'The key $key was used by multiple widgets. The parents of those widgets were '
28422842
'different widgets that both had the following description:\n'
2843-
' ${parent.toString()}\n'
2843+
' $parent\n'
28442844
'A GlobalKey can only be specified on one widget at a time in the widget tree.',
28452845
),
28462846
]);

packages/flutter/test/animation/curves_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void main() {
3737
const double delta = 0.005;
3838
for (double x = 0.0; x < 1.0 - delta; x += delta) {
3939
final double deltaY = curve.transform(x) - curve.transform(x + delta);
40-
assert(deltaY.abs() < delta * maximumSlope, '${curve.toString()} discontinuous at $x');
40+
assert(deltaY.abs() < delta * maximumSlope, '$curve discontinuous at $x');
4141
}
4242
}
4343

packages/flutter/test/material/input_decorator_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ void main() {
12941294
Finder counterFinder = find.byType(Text);
12951295
expect(counterFinder, findsOneWidget);
12961296
final Text counterWidget = tester.widget(counterFinder);
1297-
expect(counterWidget.data, '0/${maxLength.toString()}');
1297+
expect(counterWidget.data, '0/$maxLength');
12981298

12991299
// When counter, counterText, and buildCounter are set, shows the counter
13001300
// widget.
@@ -1309,7 +1309,7 @@ void main() {
13091309
required bool isFocused,
13101310
}) {
13111311
return Text(
1312-
'${currentLength.toString()} of ${maxLength.toString()}',
1312+
'$currentLength of $maxLength',
13131313
key: buildCounterKey,
13141314
);
13151315
}

packages/flutter/test/material/text_field_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -4679,7 +4679,7 @@ void main() {
46794679
child: Center(
46804680
child: TextField(
46814681
buildCounter: (BuildContext context, { required int currentLength, int? maxLength, required bool isFocused }) {
4682-
return Text('${currentLength.toString()} of ${maxLength.toString()}');
4682+
return Text('$currentLength of $maxLength');
46834683
},
46844684
maxLength: 10,
46854685
),

packages/flutter/test/material/text_form_field_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ void main() {
645645
child: Center(
646646
child: TextFormField(
647647
buildCounter: (BuildContext context, { int? currentLength, int? maxLength, bool? isFocused }) {
648-
return Text('${currentLength.toString()} of ${maxLength.toString()}');
648+
return Text('$currentLength of $maxLength');
649649
},
650650
maxLength: 10,
651651
),

packages/flutter/test/material/tooltip_theme_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ void main() {
9797
'semantics: excluded',
9898
'decoration: BoxDecoration(color: Color(0xffffffff))',
9999
'textStyle: TextStyle(inherit: true, decoration: TextDecoration.underline)',
100-
'wait duration: ${wait.toString()}',
101-
'show duration: ${show.toString()}',
100+
'wait duration: $wait',
101+
'show duration: $show',
102102
'triggerMode: $triggerMode',
103103
'enableFeedback: true',
104104
]);

packages/flutter_driver/lib/src/common/handler_factory.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ mixin CommandHandlerFactory {
413413
}
414414

415415
if (text == null) {
416-
throw UnsupportedError('Type ${widget.runtimeType.toString()} is currently not supported by getText');
416+
throw UnsupportedError('Type ${widget.runtimeType} is currently not supported by getText');
417417
}
418418

419419
return GetTextResult(text);

packages/flutter_tools/lib/src/android/application_package.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class AndroidApk extends ApplicationPackage implements PrebuiltApplicationPackag
148148
}
149149
logger.printError('AndroidManifest.xml is not a valid XML document.');
150150
logger.printError('Please check $manifestLocation for errors.');
151-
throwToolExit('XML Parser error message: ${exception.toString()}');
151+
throwToolExit('XML Parser error message: $exception');
152152
}
153153

154154
final Iterable<XmlElement> manifests = document.findElements('manifest');

packages/flutter_tools/lib/src/localizations/gen_l10n.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ class LocalizationsGenerator {
12651265
final List<String> sortedClassImports = supportedLocales
12661266
.where((LocaleInfo locale) => isBaseClassLocale(locale, locale.languageCode))
12671267
.map((LocaleInfo locale) {
1268-
final String library = '${fileName}_${locale.toString()}';
1268+
final String library = '${fileName}_$locale';
12691269
if (useDeferredLoading) {
12701270
return "import '$library.$fileExtension' deferred as $library;";
12711271
} else {

packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class AppResourceBundle {
442442
} on FormatException catch (e) {
443443
throw L10nException(
444444
'The arb file ${file.path} has the following formatting issue: \n'
445-
'${e.toString()}',
445+
'$e',
446446
);
447447
}
448448

packages/flutter_tools/lib/src/resident_devtools_handler.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
161161
);
162162
} on Exception catch (e) {
163163
_logger.printError(
164-
'Failed to set DevTools server address: ${e.toString()}. Deep links to'
164+
'Failed to set DevTools server address: $e. Deep links to'
165165
' DevTools will not show in Flutter errors.',
166166
);
167167
}
@@ -215,7 +215,7 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
215215
} on Exception catch (e) {
216216
_logger.printError(e.toString());
217217
_logger.printError(
218-
'Failed to set vm service URI: ${e.toString()}. Deep links to DevTools'
218+
'Failed to set vm service URI: $e. Deep links to DevTools'
219219
' will not show in Flutter errors.',
220220
);
221221
}

packages/flutter_tools/test/general.shard/plugins_test.dart

+8-8
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ flutter:
245245
flutterProject.directory
246246
.childFile('.packages')
247247
.writeAsStringSync(
248-
'plugin1:${pluginUsingJavaAndNewEmbeddingDir.childDirectory('lib').uri.toString()}\n',
248+
'plugin1:${pluginUsingJavaAndNewEmbeddingDir.childDirectory('lib').uri}\n',
249249
mode: FileMode.append,
250250
);
251251
}
@@ -275,7 +275,7 @@ flutter:
275275
flutterProject.directory
276276
.childFile('.packages')
277277
.writeAsStringSync(
278-
'plugin1:${pluginUsingJavaAndNewEmbeddingDir.childDirectory('lib').uri.toString()}\n',
278+
'plugin1:${pluginUsingJavaAndNewEmbeddingDir.childDirectory('lib').uri}\n',
279279
mode: FileMode.append,
280280
);
281281
return pluginUsingJavaAndNewEmbeddingDir;
@@ -305,7 +305,7 @@ flutter:
305305
flutterProject.directory
306306
.childFile('.packages')
307307
.writeAsStringSync(
308-
'plugin2:${pluginUsingKotlinAndNewEmbeddingDir.childDirectory('lib').uri.toString()}\n',
308+
'plugin2:${pluginUsingKotlinAndNewEmbeddingDir.childDirectory('lib').uri}\n',
309309
mode: FileMode.append,
310310
);
311311
}
@@ -333,7 +333,7 @@ flutter:
333333
flutterProject.directory
334334
.childFile('.packages')
335335
.writeAsStringSync(
336-
'$pluginName:${pluginUsingOldEmbeddingDir.childDirectory('lib').uri.toString()}\n',
336+
'$pluginName:${pluginUsingOldEmbeddingDir.childDirectory('lib').uri}\n',
337337
mode: FileMode.append,
338338
);
339339
}
@@ -366,7 +366,7 @@ flutter:
366366
flutterProject.directory
367367
.childFile('.packages')
368368
.writeAsStringSync(
369-
'plugin4:${pluginUsingJavaAndNewEmbeddingDir.childDirectory('lib').uri.toString()}',
369+
'plugin4:${pluginUsingJavaAndNewEmbeddingDir.childDirectory('lib').uri}',
370370
mode: FileMode.append,
371371
);
372372
}
@@ -397,7 +397,7 @@ dependencies:
397397
flutterProject.directory
398398
.childFile('.packages')
399399
.writeAsStringSync(
400-
'$name:${pluginDirectory.childDirectory('lib').uri.toString()}\n',
400+
'$name:${pluginDirectory.childDirectory('lib').uri}\n',
401401
mode: FileMode.append,
402402
);
403403
return pluginDirectory;
@@ -435,7 +435,7 @@ dependencies:
435435
flutterProject.directory
436436
.childFile('.packages')
437437
.writeAsStringSync(
438-
'$name:${pluginDirectory.childDirectory('lib').uri.toString()}\n',
438+
'$name:${pluginDirectory.childDirectory('lib').uri}\n',
439439
mode: FileMode.append,
440440
);
441441
return pluginDirectory;
@@ -1076,7 +1076,7 @@ dependencies:
10761076
flutterProject.directory
10771077
.childFile('.packages')
10781078
.writeAsStringSync('''
1079-
web_plugin_with_nested:${webPluginWithNestedFile.childDirectory('lib').uri.toString()}
1079+
web_plugin_with_nested:${webPluginWithNestedFile.childDirectory('lib').uri}
10801080
''');
10811081

10821082
await injectPlugins(flutterProject, webPlatform: true);

0 commit comments

Comments
 (0)