enable lint prefer_single_quotes (#12665)
This commit is contained in:
committed by
GitHub
parent
b07ea41954
commit
1fce14a31c
@@ -9,6 +9,6 @@ void main() {
|
||||
expect(2 + 2, 4);
|
||||
});
|
||||
test('excluded', () {
|
||||
throw "this test should have been filtered out";
|
||||
throw 'this test should have been filtered out';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void main() {
|
||||
expect(await driver.setSemantics(true), isTrue);
|
||||
});
|
||||
|
||||
final Iterable<TimelineEvent> semanticsEvents = timeline.events.where((TimelineEvent event) => event.name == "Semantics");
|
||||
final Iterable<TimelineEvent> semanticsEvents = timeline.events.where((TimelineEvent event) => event.name == 'Semantics');
|
||||
if (semanticsEvents.length != 1)
|
||||
fail('Expected exactly one semantics event, got ${semanticsEvents.length}');
|
||||
final Duration semanticsTreeCreation = semanticsEvents.first.duration;
|
||||
|
||||
@@ -29,7 +29,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
|
||||
|
||||
// TODO(hansmuller): need a local image asset
|
||||
static const String _sunshineURL = "http://www.walltor.com/images/wallpaper/good-morning-sunshine-58540.jpg";
|
||||
static const String _sunshineURL = 'http://www.walltor.com/images/wallpaper/good-morning-sunshine-58540.jpg';
|
||||
|
||||
static const double kCardMargins = 8.0;
|
||||
static const double kFixedCardHeight = 100.0;
|
||||
@@ -103,23 +103,23 @@ class CardCollectionState extends State<CardCollection> {
|
||||
child: new ListView(
|
||||
children: <Widget>[
|
||||
const DrawerHeader(child: const Center(child: const Text('Options'))),
|
||||
buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable),
|
||||
buildDrawerCheckbox("Fixed size cards", _fixedSizeCards, _toggleFixedSizeCards),
|
||||
buildDrawerCheckbox("Let the sun shine", _sunshine, _toggleSunshine),
|
||||
buildDrawerCheckbox("Vary font sizes", _varyFontSizes, _toggleVaryFontSizes, enabled: !_editable),
|
||||
buildDrawerCheckbox('Make card labels editable', _editable, _toggleEditable),
|
||||
buildDrawerCheckbox('Fixed size cards', _fixedSizeCards, _toggleFixedSizeCards),
|
||||
buildDrawerCheckbox('Let the sun shine', _sunshine, _toggleSunshine),
|
||||
buildDrawerCheckbox('Vary font sizes', _varyFontSizes, _toggleVaryFontSizes, enabled: !_editable),
|
||||
const Divider(),
|
||||
buildDrawerColorRadioItem("Deep Purple", Colors.deepPurple, _primaryColor, _selectColor),
|
||||
buildDrawerColorRadioItem("Green", Colors.green, _primaryColor, _selectColor),
|
||||
buildDrawerColorRadioItem("Amber", Colors.amber, _primaryColor, _selectColor),
|
||||
buildDrawerColorRadioItem("Teal", Colors.teal, _primaryColor, _selectColor),
|
||||
buildDrawerColorRadioItem('Deep Purple', Colors.deepPurple, _primaryColor, _selectColor),
|
||||
buildDrawerColorRadioItem('Green', Colors.green, _primaryColor, _selectColor),
|
||||
buildDrawerColorRadioItem('Amber', Colors.amber, _primaryColor, _selectColor),
|
||||
buildDrawerColorRadioItem('Teal', Colors.teal, _primaryColor, _selectColor),
|
||||
const Divider(),
|
||||
buildDrawerDirectionRadioItem("Dismiss horizontally", DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: Icons.code),
|
||||
buildDrawerDirectionRadioItem("Dismiss left", DismissDirection.endToStart, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_back),
|
||||
buildDrawerDirectionRadioItem("Dismiss right", DismissDirection.startToEnd, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_forward),
|
||||
buildDrawerDirectionRadioItem('Dismiss horizontally', DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: Icons.code),
|
||||
buildDrawerDirectionRadioItem('Dismiss left', DismissDirection.endToStart, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_back),
|
||||
buildDrawerDirectionRadioItem('Dismiss right', DismissDirection.startToEnd, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_forward),
|
||||
const Divider(),
|
||||
buildFontRadioItem("Left-align text", TextAlign.left, _textAlign, _changeTextAlign, icon: Icons.format_align_left, enabled: !_editable),
|
||||
buildFontRadioItem("Center-align text", TextAlign.center, _textAlign, _changeTextAlign, icon: Icons.format_align_center, enabled: !_editable),
|
||||
buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable),
|
||||
buildFontRadioItem('Left-align text', TextAlign.left, _textAlign, _changeTextAlign, icon: Icons.format_align_left, enabled: !_editable),
|
||||
buildFontRadioItem('Center-align text', TextAlign.center, _textAlign, _changeTextAlign, icon: Icons.format_align_center, enabled: !_editable),
|
||||
buildFontRadioItem('Right-align text', TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable),
|
||||
const Divider(),
|
||||
new ListTile(
|
||||
leading: const Icon(Icons.dvr),
|
||||
@@ -282,16 +282,16 @@ class CardCollectionState extends State<CardCollection> {
|
||||
String backgroundMessage;
|
||||
switch (_dismissDirection) {
|
||||
case DismissDirection.horizontal:
|
||||
backgroundMessage = "Swipe in either direction";
|
||||
backgroundMessage = 'Swipe in either direction';
|
||||
break;
|
||||
case DismissDirection.endToStart:
|
||||
backgroundMessage = "Swipe left to dismiss";
|
||||
backgroundMessage = 'Swipe left to dismiss';
|
||||
break;
|
||||
case DismissDirection.startToEnd:
|
||||
backgroundMessage = "Swipe right to dismiss";
|
||||
backgroundMessage = 'Swipe right to dismiss';
|
||||
break;
|
||||
default:
|
||||
backgroundMessage = "Unsupported dismissDirection";
|
||||
backgroundMessage = 'Unsupported dismissDirection';
|
||||
}
|
||||
|
||||
// TODO(abarth): This icon is wrong in RTL.
|
||||
|
||||
@@ -211,7 +211,7 @@ class _PointDemoState extends State<_PointDemo> {
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new Text(
|
||||
"Tap the refresh button to run the animation. Drag the green "
|
||||
'Tap the refresh button to run the animation. Drag the green '
|
||||
"and red points to change the animation's path.",
|
||||
style: Theme.of(context).textTheme.caption.copyWith(fontSize: 16.0)
|
||||
)
|
||||
@@ -384,7 +384,7 @@ class _RectangleDemoState extends State<_RectangleDemo> {
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new Text(
|
||||
"Tap the refresh button to run the animation. Drag the rectangles "
|
||||
'Tap the refresh button to run the animation. Drag the rectangles '
|
||||
"to change the animation's path.",
|
||||
style: Theme.of(context).textTheme.caption.copyWith(fontSize: 16.0)
|
||||
)
|
||||
|
||||
@@ -112,7 +112,7 @@ class PageViewAppState extends State<PageViewApp> {
|
||||
return new AppBar(
|
||||
title: const Text('PageView'),
|
||||
actions: <Widget>[
|
||||
new Text(scrollDirection == Axis.horizontal ? "horizontal" : "vertical"),
|
||||
new Text(scrollDirection == Axis.horizontal ? 'horizontal' : 'vertical'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import '../lib/card_collection.dart' as card_collection;
|
||||
|
||||
void main() {
|
||||
testWidgets("Card Collection smoke test", (WidgetTester tester) async {
|
||||
testWidgets('Card Collection smoke test', (WidgetTester tester) async {
|
||||
card_collection.main(); // builds the app and schedules a frame but doesn't trigger one
|
||||
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
await tester.pump(); // triggers a frame
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import '../lib/color_testing_demo.dart' as color_testing_demo;
|
||||
|
||||
void main() {
|
||||
testWidgets("Color testing demo smoke test", (WidgetTester tester) async {
|
||||
testWidgets('Color testing demo smoke test', (WidgetTester tester) async {
|
||||
color_testing_demo.main(); // builds the app and schedules a frame but doesn't trigger one
|
||||
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
await tester.pump(); // triggers a frame
|
||||
|
||||
@@ -42,34 +42,35 @@ const String outputHeader = '''
|
||||
final Map<String, Map<String, String>> localeToResources = <String, Map<String, String>>{};
|
||||
|
||||
/// Maps locales to resource attributes.
|
||||
///
|
||||
///
|
||||
/// See also https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#resource-attributes
|
||||
final Map<String, Map<String, dynamic>> localeToResourceAttributes = <String, Map<String, dynamic>>{};
|
||||
|
||||
// Return s as a Dart-parseable raw string in double quotes. Expand double quotes:
|
||||
// foo => r"foo"
|
||||
// foo "bar" => r"foo " '"' r"bar" '"'
|
||||
// Return s as a Dart-parseable raw string in single or double quotes. Expand double quotes:
|
||||
// foo => r'foo'
|
||||
// foo "bar" => r'foo "bar"'
|
||||
// foo 'bar' => r'foo ' "'" r'bar' "'"
|
||||
String generateString(String s) {
|
||||
if (!s.contains('"'))
|
||||
return 'r"$s"';
|
||||
if (!s.contains("'"))
|
||||
return "r'$s'";
|
||||
|
||||
final StringBuffer output = new StringBuffer();
|
||||
bool started = false; // Have we started writing a raw string.
|
||||
for (int i = 0; i < s.length; i++) {
|
||||
if (s[i] == '"') {
|
||||
if (s[i] == "'") {
|
||||
if (started)
|
||||
output.write('"');
|
||||
output.write(' \'"\' ');
|
||||
output.write("'");
|
||||
output.write(' "\'" ');
|
||||
started = false;
|
||||
} else if (!started) {
|
||||
output.write('r"${s[i]}');
|
||||
output.write("r'${s[i]}");
|
||||
started = true;
|
||||
} else {
|
||||
output.write(s[i]);
|
||||
}
|
||||
}
|
||||
if (started)
|
||||
output.write('"');
|
||||
output.write("'");
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
@@ -84,12 +85,12 @@ String generateLocalizationsMap() {
|
||||
const Map<String, Map<String, String>> localizations = const <String, Map<String, String>> {''');
|
||||
|
||||
for (String locale in localeToResources.keys.toList()..sort()) {
|
||||
output.writeln(' "$locale": const <String, String>{');
|
||||
output.writeln(" '$locale': const <String, String>{");
|
||||
|
||||
final Map<String, String> resources = localeToResources[locale];
|
||||
for (String name in resources.keys) {
|
||||
final String value = generateString(resources[name]);
|
||||
output.writeln(' "$name": $value,');
|
||||
output.writeln(" '$name': $value,");
|
||||
}
|
||||
output.writeln(' },');
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ void _createEntry(File mainFile, int copies) {
|
||||
|
||||
for (int i = 1; i < copies; i++) {
|
||||
imports.writeln("import 'gallery_$i/main.dart' as main_$i;");
|
||||
importRefs.writeln(" main_$i.main;");
|
||||
importRefs.writeln(' main_$i.main;');
|
||||
}
|
||||
|
||||
final String contents = '''
|
||||
|
||||
Reference in New Issue
Block a user