mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
enable use_enums (#117376)
This commit is contained in:
parent
e0742ebb24
commit
0220afdd3e
@ -223,7 +223,7 @@ linter:
|
||||
- use_build_context_synchronously
|
||||
# - use_colored_box # not yet tested
|
||||
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
|
||||
# - use_enums # not yet tested
|
||||
- use_enums
|
||||
- use_full_hex_values_for_flutter_colors
|
||||
- use_function_type_syntax_for_parameters
|
||||
- use_if_null_to_convert_nulls_to_bools
|
||||
|
@ -26,34 +26,33 @@ export 'raw_keyboard.dart' show RawKeyEvent, RawKeyboard;
|
||||
/// Only a limited number of modes are supported, which are enumerated as
|
||||
/// static members of this class. Manual constructing of this class is
|
||||
/// prohibited.
|
||||
@immutable
|
||||
class KeyboardLockMode {
|
||||
// KeyboardLockMode has a fixed pool of supported keys, enumerated as static
|
||||
// members of this class, therefore constructing is prohibited.
|
||||
const KeyboardLockMode._(this.logicalKey);
|
||||
|
||||
/// The logical key that triggers this lock mode.
|
||||
final LogicalKeyboardKey logicalKey;
|
||||
|
||||
enum KeyboardLockMode {
|
||||
/// Represents the number lock mode on the keyboard.
|
||||
///
|
||||
/// On supporting systems, enabling number lock mode usually allows key
|
||||
/// presses of the number pad to input numbers, instead of acting as up, down,
|
||||
/// left, right, page up, end, etc.
|
||||
static const KeyboardLockMode numLock = KeyboardLockMode._(LogicalKeyboardKey.numLock);
|
||||
numLock._(LogicalKeyboardKey.numLock),
|
||||
|
||||
/// Represents the scrolling lock mode on the keyboard.
|
||||
///
|
||||
/// On supporting systems and applications (such as a spreadsheet), enabling
|
||||
/// scrolling lock mode usually allows key presses of the cursor keys to
|
||||
/// scroll the document instead of the cursor.
|
||||
static const KeyboardLockMode scrollLock = KeyboardLockMode._(LogicalKeyboardKey.scrollLock);
|
||||
scrollLock._(LogicalKeyboardKey.scrollLock),
|
||||
|
||||
/// Represents the capital letters lock mode on the keyboard.
|
||||
///
|
||||
/// On supporting systems, enabling capital lock mode allows key presses of
|
||||
/// the letter keys to input uppercase letters instead of lowercase.
|
||||
static const KeyboardLockMode capsLock = KeyboardLockMode._(LogicalKeyboardKey.capsLock);
|
||||
capsLock._(LogicalKeyboardKey.capsLock);
|
||||
|
||||
// KeyboardLockMode has a fixed pool of supported keys, enumerated as static
|
||||
// members of this class, therefore constructing is prohibited.
|
||||
const KeyboardLockMode._(this.logicalKey);
|
||||
|
||||
/// The logical key that triggers this lock mode.
|
||||
final LogicalKeyboardKey logicalKey;
|
||||
|
||||
static final Map<int, KeyboardLockMode> _knownLockModes = <int, KeyboardLockMode>{
|
||||
numLock.logicalKey.keyId: numLock,
|
||||
|
@ -1565,15 +1565,12 @@ class LogMessage {
|
||||
}
|
||||
|
||||
/// The method by which the Flutter app was launched.
|
||||
class LaunchMode {
|
||||
enum LaunchMode {
|
||||
run._('run'),
|
||||
attach._('attach');
|
||||
|
||||
const LaunchMode._(this._value);
|
||||
|
||||
/// The app was launched via `flutter run`.
|
||||
static const LaunchMode run = LaunchMode._('run');
|
||||
|
||||
/// The app was launched via `flutter attach`.
|
||||
static const LaunchMode attach = LaunchMode._('attach');
|
||||
|
||||
final String _value;
|
||||
|
||||
@override
|
||||
|
@ -23,12 +23,12 @@ import 'vmservice.dart';
|
||||
DeviceManager? get deviceManager => context.get<DeviceManager>();
|
||||
|
||||
/// A description of the kind of workflow the device supports.
|
||||
class Category {
|
||||
const Category._(this.value);
|
||||
enum Category {
|
||||
web._('web'),
|
||||
desktop._('desktop'),
|
||||
mobile._('mobile');
|
||||
|
||||
static const Category web = Category._('web');
|
||||
static const Category desktop = Category._('desktop');
|
||||
static const Category mobile = Category._('mobile');
|
||||
const Category._(this.value);
|
||||
|
||||
final String value;
|
||||
|
||||
@ -36,7 +36,7 @@ class Category {
|
||||
String toString() => value;
|
||||
|
||||
static Category? fromString(String category) {
|
||||
return <String, Category>{
|
||||
return const <String, Category>{
|
||||
'web': web,
|
||||
'desktop': desktop,
|
||||
'mobile': mobile,
|
||||
@ -45,17 +45,17 @@ class Category {
|
||||
}
|
||||
|
||||
/// The platform sub-folder that a device type supports.
|
||||
class PlatformType {
|
||||
const PlatformType._(this.value);
|
||||
enum PlatformType {
|
||||
web._('web'),
|
||||
android._('android'),
|
||||
ios._('ios'),
|
||||
linux._('linux'),
|
||||
macos._('macos'),
|
||||
windows._('windows'),
|
||||
fuchsia._('fuchsia'),
|
||||
custom._('custom');
|
||||
|
||||
static const PlatformType web = PlatformType._('web');
|
||||
static const PlatformType android = PlatformType._('android');
|
||||
static const PlatformType ios = PlatformType._('ios');
|
||||
static const PlatformType linux = PlatformType._('linux');
|
||||
static const PlatformType macos = PlatformType._('macos');
|
||||
static const PlatformType windows = PlatformType._('windows');
|
||||
static const PlatformType fuchsia = PlatformType._('fuchsia');
|
||||
static const PlatformType custom = PlatformType._('custom');
|
||||
const PlatformType._(this.value);
|
||||
|
||||
final String value;
|
||||
|
||||
@ -63,7 +63,7 @@ class PlatformType {
|
||||
String toString() => value;
|
||||
|
||||
static PlatformType? fromString(String platformType) {
|
||||
return <String, PlatformType>{
|
||||
return const <String, PlatformType>{
|
||||
'web': web,
|
||||
'android': android,
|
||||
'ios': ios,
|
||||
|
Loading…
Reference in New Issue
Block a user