mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
112 lines
2.3 KiB
Dart
112 lines
2.3 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:io' hide Platform;
|
|
|
|
import 'package:path/path.dart' as path;
|
|
import 'package:platform/platform.dart' show LocalPlatform;
|
|
|
|
/// The location of the Flutter root directory, based on the known location of
|
|
/// this script.
|
|
final Directory flutterRoot = Directory(path.dirname(const LocalPlatform().script.toFilePath())).parent.parent.parent.parent;
|
|
|
|
/// Converts `FOO_BAR` to `fooBar`.
|
|
String shoutingToLowerCamel(String shouting) {
|
|
final RegExp initialLetter = RegExp(r'_([^_])([^_]*)');
|
|
final String snake = shouting.toLowerCase();
|
|
final String result = snake.replaceAllMapped(initialLetter, (Match match) {
|
|
return match.group(1).toUpperCase() + match.group(2).toLowerCase();
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/// Converts 'FooBar' to 'fooBar'.
|
|
String upperCamelToLowerCamel(String upperCamel) {
|
|
return upperCamel.substring(0, 1).toLowerCase() + upperCamel.substring(1);
|
|
}
|
|
|
|
/// Converts 'fooBar' to 'FooBar'.
|
|
String lowerCamelToUpperCamel(String lowerCamel) {
|
|
return lowerCamel.substring(0, 1).toUpperCase() + lowerCamel.substring(1);
|
|
}
|
|
|
|
/// A list of Dart reserved words.
|
|
///
|
|
/// Since these are Dart reserved words, we can't use them as-is for enum names.
|
|
const List<String> kDartReservedWords = <String>[
|
|
'abstract',
|
|
'as',
|
|
'assert',
|
|
'async',
|
|
'await',
|
|
'break',
|
|
'case',
|
|
'catch',
|
|
'class',
|
|
'const',
|
|
'continue',
|
|
'covariant',
|
|
'default',
|
|
'deferred',
|
|
'do',
|
|
'dynamic',
|
|
'else',
|
|
'enum',
|
|
'export',
|
|
'extends',
|
|
'external',
|
|
'factory',
|
|
'false',
|
|
'final',
|
|
'finally',
|
|
'for',
|
|
'Function',
|
|
'get',
|
|
'hide',
|
|
'if',
|
|
'implements',
|
|
'import',
|
|
'in',
|
|
'interface',
|
|
'is',
|
|
'library',
|
|
'mixin',
|
|
'new',
|
|
'null',
|
|
'on',
|
|
'operator',
|
|
'part',
|
|
'rethrow',
|
|
'return',
|
|
'set',
|
|
'show',
|
|
'static',
|
|
'super',
|
|
'switch',
|
|
'sync',
|
|
'this',
|
|
'throw',
|
|
'true',
|
|
'try',
|
|
'typedef',
|
|
'var',
|
|
'void',
|
|
'while',
|
|
'with',
|
|
'yield',
|
|
];
|
|
|
|
/// Converts an integer into a hex string with the given number of digits.
|
|
String toHex(int value, {int digits = 8}) {
|
|
if (value == null) {
|
|
return 'null';
|
|
}
|
|
return '0x${value.toRadixString(16).padLeft(digits, '0')}';
|
|
}
|
|
|
|
/// Parses an integer from a hex string.
|
|
int getHex(String input) {
|
|
return int.parse(input, radix: 16);
|
|
}
|