unnecessary escapes fixes (#50178)

* unnecessary escapes fixes

* replace some strings with raw strings

* update regexp

* address review comments
diff --git a/dev/devicelab/bin/tasks/flutter_attach_test_android.dart b/dev/devicelab/bin/tasks/flutter_attach_test_android.dart
index 0f80aca..f44c6f1 100644
--- a/dev/devicelab/bin/tasks/flutter_attach_test_android.dart
+++ b/dev/devicelab/bin/tasks/flutter_attach_test_android.dart
@@ -128,7 +128,7 @@
         // If the next line fails, your device may not support regexp search.
         final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]);
         print('Found observatory line: $observatoryLine');
-        final String observatoryUri = RegExp('Observatory listening on ((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)').firstMatch(observatoryLine)[1];
+        final String observatoryUri = RegExp(r'Observatory listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)').firstMatch(observatoryLine)[1];
         print('Extracted observatory port: $observatoryUri');
 
         section('Launching attach with given port');
diff --git a/dev/devicelab/bin/tasks/named_isolates_test.dart b/dev/devicelab/bin/tasks/named_isolates_test.dart
index af0bf60..b8a7a1c 100644
--- a/dev/devicelab/bin/tasks/named_isolates_test.dart
+++ b/dev/devicelab/bin/tasks/named_isolates_test.dart
@@ -47,7 +47,7 @@
     await device.shellExec('am', <String>['start', '-n', _kActivityId]);
     final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]);
     print('Found observatory line: $observatoryLine');
-    final String observatoryUri = RegExp('Observatory listening on ((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)').firstMatch(observatoryLine)[1];
+    final String observatoryUri = RegExp(r'Observatory listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)').firstMatch(observatoryLine)[1];
     print('Extracted observatory port: $observatoryUri');
     final Process attachProcess =
       await _run(device: device, command: <String>['attach', '--debug-uri',
diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart
index 25ba815..53e1634 100644
--- a/dev/devicelab/lib/framework/utils.dart
+++ b/dev/devicelab/lib/framework/utils.dart
@@ -589,7 +589,7 @@
 final RegExp _obsRegExp =
   RegExp('An Observatory debugger .* is available at: ');
 final RegExp _obsPortRegExp = RegExp('(\\S+:(\\d+)/\\S*)\$');
-final RegExp _obsUriRegExp = RegExp('((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)');
+final RegExp _obsUriRegExp = RegExp(r'((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
 
 /// Tries to extract a port from the string.
 ///
diff --git a/dev/devicelab/lib/tasks/hot_mode_tests.dart b/dev/devicelab/lib/tasks/hot_mode_tests.dart
index c9bb93b..36005c1 100644
--- a/dev/devicelab/lib/tasks/hot_mode_tests.dart
+++ b/dev/devicelab/lib/tasks/hot_mode_tests.dart
@@ -55,7 +55,7 @@
               .transform<String>(utf8.decoder)
               .transform<String>(const LineSplitter())
               .listen((String line) {
-            if (line.contains('\] Reloaded ')) {
+            if (line.contains('] Reloaded ')) {
               if (hotReloadCount == 0) {
                 // Update the file and reload again.
                 final File appDartSource = file(path.join(
@@ -108,7 +108,7 @@
               .transform<String>(utf8.decoder)
               .transform<String>(const LineSplitter())
               .listen((String line) {
-            if (line.contains('\] Reloaded ')) {
+            if (line.contains('] Reloaded ')) {
               process.stdin.writeln('q');
             }
             print('stdout: $line');
diff --git a/dev/devicelab/lib/tasks/run_without_leak.dart b/dev/devicelab/lib/tasks/run_without_leak.dart
index 3ff2a87..d46913f 100644
--- a/dev/devicelab/lib/tasks/run_without_leak.dart
+++ b/dev/devicelab/lib/tasks/run_without_leak.dart
@@ -32,7 +32,7 @@
           .transform<String>(utf8.decoder)
           .transform<String>(const LineSplitter())
           .listen((String line) {
-        if (line.contains('\] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q"')) {
+        if (line.contains('] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q"')) {
           process.stdin.writeln('q');
         }
         print('stdout: $line');
diff --git a/dev/tools/lib/roll_dev.dart b/dev/tools/lib/roll_dev.dart
index 1eae90e..3ecf5a4 100644
--- a/dev/tools/lib/roll_dev.dart
+++ b/dev/tools/lib/roll_dev.dart
@@ -168,7 +168,7 @@
 }
 
 Match parseFullTag(String version) {
-  final RegExp versionPattern = RegExp('^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)\$');
+  final RegExp versionPattern = RegExp(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)$');
   return versionPattern.matchAsPrefix(version);
 }
 
diff --git a/dev/tools/localization/bin/gen_missing_localizations.dart b/dev/tools/localization/bin/gen_missing_localizations.dart
index 900f885..ddd8a5e 100644
--- a/dev/tools/localization/bin/gen_missing_localizations.dart
+++ b/dev/tools/localization/bin/gen_missing_localizations.dart
@@ -75,7 +75,7 @@
 
 void updateMissingResources(String localizationPath, String groupPrefix) {
   final Directory localizationDir = Directory(localizationPath);
-  final RegExp filenamePattern = RegExp('${groupPrefix}_(\\w+)\.arb');
+  final RegExp filenamePattern = RegExp('${groupPrefix}_(\\w+)\\.arb');
 
   final Set<String> requiredKeys = resourceKeys(loadBundle(File(path.join(localizationPath, '${groupPrefix}_en.arb'))));
 
diff --git a/dev/tools/localization/gen_l10n_templates.dart b/dev/tools/localization/gen_l10n_templates.dart
index 536aa36..4caa5ca 100644
--- a/dev/tools/localization/gen_l10n_templates.dart
+++ b/dev/tools/localization/gen_l10n_templates.dart
@@ -66,8 +66,8 @@
 /// Callers can lookup localized strings with an instance of @(className) returned
 /// by `@(className).of(context)`.
 ///
-/// Applications need to include `@(className).delegate()` in their app\'s
-/// localizationDelegates list, and the locales they support in the app\'s
+/// Applications need to include `@(className).delegate()` in their app's
+/// localizationDelegates list, and the locales they support in the app's
 /// supportedLocales list. For example:
 ///
 /// ```
diff --git a/dev/tools/test/localization/gen_l10n_test.dart b/dev/tools/test/localization/gen_l10n_test.dart
index a1ecd6d..d68e933 100644
--- a/dev/tools/test/localization/gen_l10n_test.dart
+++ b/dev/tools/test/localization/gen_l10n_test.dart
@@ -952,12 +952,12 @@
       return Intl.plural(
         count,
       locale: _localeName,
-      name: \'helloWorlds\',
+      name: 'helloWorlds',
       args: <Object>[count, currentDate],
-      one: \'Hello World, today is \${currentDateString}\',
-      two: \'Hello two worlds, today is \${currentDateString}\',
-      many: \'Hello all \${count} worlds, today is \${currentDateString}\',
-      other: \'Hello other \${count} worlds, today is \${currentDateString}\'
+      one: 'Hello World, today is \${currentDateString}',
+      two: 'Hello two worlds, today is \${currentDateString}',
+      many: 'Hello all \${count} worlds, today is \${currentDateString}',
+      other: 'Hello other \${count} worlds, today is \${currentDateString}'
       );
     }
     return helloWorlds(count, currentDateString);
@@ -1334,12 +1334,12 @@
       return Intl.plural(
         count,
       locale: _localeName,
-      name: \'helloWorlds\',
+      name: 'helloWorlds',
       args: <Object>[count, currentDate],
-      one: \'Hello World, today is \${currentDateString}\',
-      two: \'Hello two worlds, today is \${currentDateString}\',
-      many: \'Hello all \${count} worlds, today is \${currentDateString}\',
-      other: \'Hello other \${count} worlds, today is \${currentDateString}\'
+      one: 'Hello World, today is \${currentDateString}',
+      two: 'Hello two worlds, today is \${currentDateString}',
+      many: 'Hello all \${count} worlds, today is \${currentDateString}',
+      other: 'Hello other \${count} worlds, today is \${currentDateString}'
       );
     }
     return helloWorlds(count, currentDateString);
@@ -1393,12 +1393,12 @@
       return Intl.plural(
         count,
       locale: _localeName,
-      name: \'helloWorlds\',
+      name: 'helloWorlds',
       args: <Object>[count, population],
-      one: \'Hello World of \${populationString} citizens\',
-      two: \'Hello two worlds with \${populationString} total citizens\',
-      many: \'Hello all \${count} worlds, with a total of \${populationString} citizens\',
-      other: \'Hello other \${count} worlds, with a total of \${populationString} citizens\'
+      one: 'Hello World of \${populationString} citizens',
+      two: 'Hello two worlds with \${populationString} total citizens',
+      many: 'Hello all \${count} worlds, with a total of \${populationString} citizens',
+      other: 'Hello other \${count} worlds, with a total of \${populationString} citizens'
       );
     }
     return helloWorlds(count, populationString);
diff --git a/dev/tools/vitool/lib/vitool.dart b/dev/tools/vitool/lib/vitool.dart
index a8fdc4b..495aa88 100644
--- a/dev/tools/vitool/lib/vitool.dart
+++ b/dev/tools/vitool/lib/vitool.dart
@@ -292,7 +292,7 @@
   final List<SvgPathCommand> commands;
   final double opacity;
 
-  static const String _pathCommandAtom = ' *([a-zA-Z]) *([\-\.0-9 ,]*)';
+  static const String _pathCommandAtom = r' *([a-zA-Z]) *([\-\.0-9 ,]*)';
   static final RegExp _pathCommandValidator = RegExp('^($_pathCommandAtom)*\$');
   static final RegExp _pathCommandMatcher = RegExp(_pathCommandAtom);
 
diff --git a/examples/flutter_gallery/lib/demo/fortnightly/fortnightly.dart b/examples/flutter_gallery/lib/demo/fortnightly/fortnightly.dart
index bfa82c8..1afb92b 100644
--- a/examples/flutter_gallery/lib/demo/fortnightly/fortnightly.dart
+++ b/examples/flutter_gallery/lib/demo/fortnightly/fortnightly.dart
@@ -66,11 +66,11 @@
 }
 
 class FruitPage extends StatelessWidget {
-  static final String paragraph1 = '''Have you ever held a quince? It\'s strange;
- covered in a fuzz somewhere between peach skin and a spider web. And it\'s
- hard as soft lumber. You\'d be forgiven for thinking it\'s veneered Larch-wood.
- But inhale the aroma and you\'ll instantly know you have something wonderful.
- Its scent can fill a room for days. And all this before you\'ve even cooked it.
+  static final String paragraph1 = '''Have you ever held a quince? It's strange;
+ covered in a fuzz somewhere between peach skin and a spider web. And it's
+ hard as soft lumber. You'd be forgiven for thinking it's veneered Larch-wood.
+ But inhale the aroma and you'll instantly know you have something wonderful.
+ Its scent can fill a room for days. And all this before you've even cooked it.
 '''.replaceAll('\n', '');
 
   static final String paragraph2 = '''Pomegranates on the other hand have become
diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart
index 9d386d5..b48306e 100644
--- a/packages/flutter_tools/lib/src/android/gradle.dart
+++ b/packages/flutter_tools/lib/src/android/gradle.dart
@@ -642,7 +642,7 @@
 
   for (final String buildMode in buildModes) {
     globals.printStatus('''
-      ${buildMode}Implementation \'$androidPackage:flutter_$buildMode:$buildNumber\'''');
+      ${buildMode}Implementation '$androidPackage:flutter_$buildMode:$buildNumber\'''');
   }
 
   globals.printStatus('''
diff --git a/packages/flutter_tools/lib/src/android/gradle_utils.dart b/packages/flutter_tools/lib/src/android/gradle_utils.dart
index 3a192fc..491fd12 100644
--- a/packages/flutter_tools/lib/src/android/gradle_utils.dart
+++ b/packages/flutter_tools/lib/src/android/gradle_utils.dart
@@ -128,7 +128,7 @@
 }
 const String _defaultGradleVersion = '5.6.2';
 
-final RegExp _androidPluginRegExp = RegExp('com\.android\.tools\.build\:gradle\:(\\d+\.\\d+\.\\d+\)');
+final RegExp _androidPluginRegExp = RegExp(r'com\.android\.tools\.build:gradle:\(\d+\.\d+\.\d+\)');
 
 /// Returns the Gradle version that the current Android plugin depends on when found,
 /// otherwise it returns a default version.
diff --git a/packages/flutter_tools/lib/src/base/utils.dart b/packages/flutter_tools/lib/src/base/utils.dart
index 8e60b51..a05e211 100644
--- a/packages/flutter_tools/lib/src/base/utils.dart
+++ b/packages/flutter_tools/lib/src/base/utils.dart
@@ -350,7 +350,7 @@
   // reconstitute the original string. This is useful for manipulating "visible"
   // characters in the presence of ANSI control codes.
   List<_AnsiRun> splitWithCodes(String input) {
-    final RegExp characterOrCode = RegExp('(\u001b\[[0-9;]*m|.)', multiLine: true);
+    final RegExp characterOrCode = RegExp('(\u001b\\[[0-9;]*m|.)', multiLine: true);
     List<_AnsiRun> result = <_AnsiRun>[];
     final StringBuffer current = StringBuffer();
     for (final Match match in characterOrCode.allMatches(input)) {
diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
index 937027f..1b37082 100644
--- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
@@ -82,7 +82,7 @@
     // the correct fuchsia module.
     final RegExp matchRegExp = _app == null
         ? _flutterLogOutput
-        : RegExp('INFO: ${_app.name}(\.cmx)?\\(flutter\\): ');
+        : RegExp('INFO: ${_app.name}(\\.cmx)?\\(flutter\\): ');
     return Stream<String>.eventTransformed(
       lines,
       (EventSink<String> output) => _FuchsiaLogSink(output, matchRegExp, startTime),
diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart
index 30cec47..2d01fcc 100644
--- a/packages/flutter_tools/lib/src/project.dart
+++ b/packages/flutter_tools/lib/src/project.dart
@@ -603,7 +603,7 @@
   String get pluginConfigKey => AndroidPlugin.kConfigKey;
 
   static final RegExp _applicationIdPattern = RegExp('^\\s*applicationId\\s+[\'"](.*)[\'"]\\s*\$');
-  static final RegExp _kotlinPluginPattern = RegExp('^\\s*apply plugin\:\\s+[\'"]kotlin-android[\'"]\\s*\$');
+  static final RegExp _kotlinPluginPattern = RegExp('^\\s*apply plugin\\:\\s+[\'"]kotlin-android[\'"]\\s*\$');
   static final RegExp _groupPattern = RegExp('^\\s*group\\s+[\'"](.*)[\'"]\\s*\$');
 
   /// The Gradle root directory of the Android host app. This is the directory
diff --git a/packages/flutter_tools/lib/src/protocol_discovery.dart b/packages/flutter_tools/lib/src/protocol_discovery.dart
index a13878e..acdb4d5 100644
--- a/packages/flutter_tools/lib/src/protocol_discovery.dart
+++ b/packages/flutter_tools/lib/src/protocol_discovery.dart
@@ -94,7 +94,7 @@
   }
 
   Match _getPatternMatch(String line) {
-    final RegExp r = RegExp('${RegExp.escape(serviceName)} listening on ((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)');
+    final RegExp r = RegExp(RegExp.escape(serviceName) + r' listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
     return r.firstMatch(line);
   }
 
diff --git a/packages/flutter_tools/lib/src/web/web_device.dart b/packages/flutter_tools/lib/src/web/web_device.dart
index 628a640..dffc866 100644
--- a/packages/flutter_tools/lib/src/web/web_device.dart
+++ b/packages/flutter_tools/lib/src/web/web_device.dart
@@ -193,7 +193,7 @@
 
 @visibleForTesting
 String parseVersionForWindows(String input) {
-  return input.split(RegExp('\w')).last;
+  return input.split(RegExp(r'\w')).last;
 }
 
 
diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart
index 18d9f74..301d425 100644
--- a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart
+++ b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart
@@ -408,7 +408,7 @@
     // loopback device, so connecting to the IPv4 loopback would fail when the
     // target address is IPv6 link-local.
     final String addr = _useIpV6Loopback
-        ? 'http://\[$_ipv6Loopback\]:$port'
+        ? 'http://[$_ipv6Loopback]:$port'
         : 'http://$_ipv4Loopback:$port';
     final Uri uri = Uri.parse(addr);
     return uri;