Add missing parameter to TableBorder.symmetric, and improve class constructors (#144279)

Originally, my aim was just to refactor (as per usual), but while messing around with the `TableBorder.symmetric` constructor, I realized that `borderRadius` was missing!

This pull request makes a few class constructors more efficient, and it fixes #144277 by adding the missing parameter.

<br>
This commit is contained in:
Nate
2024-03-04 13:20:19 -07:00
committed by GitHub
parent 1d7f4a9afa
commit 1a0dc8f1e1
36 changed files with 195 additions and 356 deletions

View File

@@ -387,9 +387,9 @@ class Stdio {
/// An overridable version of io.ProcessInfo.
abstract class ProcessInfo {
factory ProcessInfo(FileSystem fs) => _DefaultProcessInfo(fs);
factory ProcessInfo(FileSystem fs) = _DefaultProcessInfo;
factory ProcessInfo.test(FileSystem fs) => _TestProcessInfo(fs);
factory ProcessInfo.test(FileSystem fs) = _TestProcessInfo;
int get currentRss;

View File

@@ -25,12 +25,10 @@ typedef ShutdownHook = FutureOr<void> Function();
// for more details.
abstract class ShutdownHooks {
factory ShutdownHooks() => _DefaultShutdownHooks();
factory ShutdownHooks() = _DefaultShutdownHooks;
/// Registers a [ShutdownHook] to be executed before the VM exits.
void addShutdownHook(
ShutdownHook shutdownHook
);
void addShutdownHook(ShutdownHook shutdownHook);
@visibleForTesting
List<ShutdownHook> get registeredHooks;
@@ -139,10 +137,7 @@ abstract class ProcessUtils {
factory ProcessUtils({
required ProcessManager processManager,
required Logger logger,
}) => _DefaultProcessUtils(
processManager: processManager,
logger: logger,
);
}) = _DefaultProcessUtils;
/// Spawns a child process to run the command [cmd].
///

View File

@@ -152,9 +152,7 @@ class SettingsFile {
}
}
factory SettingsFile.parseFromFile(File file) {
return SettingsFile.parse(file.readAsStringSync());
}
SettingsFile.parseFromFile(File file) : this.parse(file.readAsStringSync());
final Map<String, String> values = <String, String>{};

View File

@@ -22,11 +22,7 @@ class DartPluginRegistrantTarget extends Target {
///
/// If `project` is unset, a [FlutterProject] based on environment is used.
@visibleForTesting
factory DartPluginRegistrantTarget.test(FlutterProject project) {
return DartPluginRegistrantTarget._(project);
}
DartPluginRegistrantTarget._(this._project);
const DartPluginRegistrantTarget.test(FlutterProject project) : _project = project;
final FlutterProject? _project;

View File

@@ -42,8 +42,7 @@ class FlutterAttachRequestArguments
program = obj['program'] as String?,
super.fromMap();
static FlutterAttachRequestArguments fromJson(Map<String, Object?> obj) =>
FlutterAttachRequestArguments.fromMap(obj);
factory FlutterAttachRequestArguments.fromJson(Map<String, Object?> obj) = FlutterAttachRequestArguments.fromMap;
/// Arguments to be passed to the tool that will run [program] (for example, the VM or Flutter tool).
final List<String>? toolArgs;
@@ -128,6 +127,8 @@ class FlutterLaunchRequestArguments
customToolReplacesArgs = obj['customToolReplacesArgs'] as int?,
super.fromMap();
factory FlutterLaunchRequestArguments.fromJson(Map<String, Object?> obj) = FlutterLaunchRequestArguments.fromMap;
/// If noDebug is true the launch request should launch the program without enabling debugging.
@override
final bool? noDebug;
@@ -170,7 +171,4 @@ class FlutterLaunchRequestArguments
if (customToolReplacesArgs != null)
'customToolReplacesArgs': customToolReplacesArgs,
};
static FlutterLaunchRequestArguments fromJson(Map<String, Object?> obj) =>
FlutterLaunchRequestArguments.fromMap(obj);
}

View File

@@ -167,12 +167,8 @@ class FuchsiaPM {
/// server.stop();
/// }
class FuchsiaPackageServer {
factory FuchsiaPackageServer(
String repo, String name, String host, int port) {
return FuchsiaPackageServer._(repo, name, host, port);
}
FuchsiaPackageServer._(this._repo, this.name, this._host, this._port);
FuchsiaPackageServer(String repo, this.name, String host, int port)
: _repo = repo, _host = host, _port = port;
static const String deviceHost = 'fuchsia.com';
static const String toolHost = 'flutter-tool';

View File

@@ -18,19 +18,12 @@ abstract class PersistentToolState {
required FileSystem fileSystem,
required Logger logger,
required Platform platform,
}) => _DefaultPersistentToolState(
fileSystem: fileSystem,
logger: logger,
platform: platform,
);
}) = _DefaultPersistentToolState;
factory PersistentToolState.test({
required Directory directory,
required Logger logger,
}) => _DefaultPersistentToolState.test(
directory: directory,
logger: logger,
);
}) = _DefaultPersistentToolState.test;
static PersistentToolState? get instance => context.get<PersistentToolState>();

View File

@@ -84,19 +84,14 @@ class AndroidPlugin extends PluginPlatform implements NativeOrDartPlugin {
}) : _fileSystem = fileSystem,
ffiPlugin = ffiPlugin ?? false;
factory AndroidPlugin.fromYaml(String name, YamlMap yaml, String pluginPath, FileSystem fileSystem) {
assert(validate(yaml));
return AndroidPlugin(
name: name,
package: yaml['package'] as String?,
pluginClass: yaml[kPluginClass] as String?,
dartPluginClass: yaml[kDartPluginClass] as String?,
ffiPlugin: yaml[kFfiPlugin] as bool?,
defaultPackage: yaml[kDefaultPackage] as String?,
pluginPath: pluginPath,
fileSystem: fileSystem,
);
}
AndroidPlugin.fromYaml(this.name, YamlMap yaml, this.pluginPath, FileSystem fileSystem)
: assert(validate(yaml)),
package = yaml['package'] as String?,
pluginClass = yaml[kPluginClass] as String?,
dartPluginClass = yaml[kDartPluginClass] as String?,
ffiPlugin = yaml[kFfiPlugin] as bool? ?? false,
defaultPackage = yaml[kDefaultPackage] as String?,
_fileSystem = fileSystem;
final FileSystem _fileSystem;
@@ -244,18 +239,14 @@ class IOSPlugin extends PluginPlatform implements NativeOrDartPlugin, DarwinPlug
}) : ffiPlugin = ffiPlugin ?? false,
sharedDarwinSource = sharedDarwinSource ?? false;
factory IOSPlugin.fromYaml(String name, YamlMap yaml) {
assert(validate(yaml)); // TODO(zanderso): https://github.com/flutter/flutter/issues/67241
return IOSPlugin(
name: name,
classPrefix: '',
pluginClass: yaml[kPluginClass] as String?,
dartPluginClass: yaml[kDartPluginClass] as String?,
ffiPlugin: yaml[kFfiPlugin] as bool?,
defaultPackage: yaml[kDefaultPackage] as String?,
sharedDarwinSource: yaml[kSharedDarwinSource] as bool?,
);
}
IOSPlugin.fromYaml(this.name, YamlMap yaml)
: assert(validate(yaml)), // TODO(zanderso): https://github.com/flutter/flutter/issues/67241
classPrefix = '',
pluginClass = yaml[kPluginClass] as String?,
dartPluginClass = yaml[kDartPluginClass] as String?,
ffiPlugin = yaml[kFfiPlugin] as bool? ?? false,
defaultPackage = yaml[kDefaultPackage] as String?,
sharedDarwinSource = yaml[kSharedDarwinSource] as bool? ?? false;
static bool validate(YamlMap yaml) {
return yaml[kPluginClass] is String ||
@@ -321,22 +312,14 @@ class MacOSPlugin extends PluginPlatform implements NativeOrDartPlugin, DarwinPl
}) : ffiPlugin = ffiPlugin ?? false,
sharedDarwinSource = sharedDarwinSource ?? false;
factory MacOSPlugin.fromYaml(String name, YamlMap yaml) {
assert(validate(yaml));
// Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497.
String? pluginClass = yaml[kPluginClass] as String?;
if (pluginClass == 'none') {
pluginClass = null;
}
return MacOSPlugin(
name: name,
pluginClass: pluginClass,
dartPluginClass: yaml[kDartPluginClass] as String?,
ffiPlugin: yaml[kFfiPlugin] as bool?,
defaultPackage: yaml[kDefaultPackage] as String?,
sharedDarwinSource: yaml[kSharedDarwinSource] as bool?,
);
}
MacOSPlugin.fromYaml(this.name, YamlMap yaml)
: assert(validate(yaml)),
// Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497.
pluginClass = yaml[kPluginClass] == 'none' ? null : yaml[kPluginClass] as String?,
dartPluginClass = yaml[kDartPluginClass] as String?,
ffiPlugin = yaml[kFfiPlugin] as bool? ?? false,
defaultPackage = yaml[kDefaultPackage] as String?,
sharedDarwinSource = yaml[kSharedDarwinSource] as bool? ?? false;
static bool validate(YamlMap yaml) {
return yaml[kPluginClass] is String ||
@@ -487,21 +470,13 @@ class LinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
}) : ffiPlugin = ffiPlugin ?? false,
assert(pluginClass != null || dartPluginClass != null || (ffiPlugin ?? false) || defaultPackage != null);
factory LinuxPlugin.fromYaml(String name, YamlMap yaml) {
assert(validate(yaml));
// Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497.
String? pluginClass = yaml[kPluginClass] as String?;
if (pluginClass == 'none') {
pluginClass = null;
}
return LinuxPlugin(
name: name,
pluginClass: pluginClass,
dartPluginClass: yaml[kDartPluginClass] as String?,
ffiPlugin: yaml[kFfiPlugin] as bool?,
defaultPackage: yaml[kDefaultPackage] as String?,
);
}
LinuxPlugin.fromYaml(this.name, YamlMap yaml)
: assert(validate(yaml)),
// Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497.
pluginClass = yaml[kPluginClass] == 'none' ? null : yaml[kPluginClass] as String?,
dartPluginClass = yaml[kDartPluginClass] as String?,
ffiPlugin = yaml[kFfiPlugin] as bool? ?? false,
defaultPackage = yaml[kDefaultPackage] as String?;
static bool validate(YamlMap yaml) {
return yaml[kPluginClass] is String ||

View File

@@ -8,9 +8,7 @@ import 'cache.dart';
/// A validator that runs before the tool runs any command.
abstract class PreRunValidator {
factory PreRunValidator({
required FileSystem fileSystem,
}) => _DefaultPreRunValidator(fileSystem: fileSystem);
factory PreRunValidator({required FileSystem fileSystem}) = _DefaultPreRunValidator;
void validate();
}

View File

@@ -15,7 +15,7 @@ import '../convert.dart';
/// Adler-32 and MD5 hashes of blocks in files.
class BlockHashes {
BlockHashes({
const BlockHashes({
required this.blockSize,
required this.totalSize,
required this.adler32,
@@ -23,6 +23,13 @@ class BlockHashes {
required this.fileMd5,
});
BlockHashes.fromJson(Map<String, Object?> obj)
: blockSize = obj['blockSize']! as int,
totalSize = obj['totalSize']! as int,
adler32 = Uint32List.view(base64.decode(obj['adler32']! as String).buffer),
md5 = (obj['md5']! as List<Object?>).cast<String>(),
fileMd5 = obj['fileMd5']! as String;
/// The block size used to generate the hashes.
final int blockSize;
@@ -45,16 +52,6 @@ class BlockHashes {
'md5': md5,
'fileMd5': fileMd5,
};
static BlockHashes fromJson(Map<String, Object?> obj) {
return BlockHashes(
blockSize: obj['blockSize']! as int,
totalSize: obj['totalSize']! as int,
adler32: Uint32List.view(base64.decode(obj['adler32']! as String).buffer),
md5: (obj['md5']! as List<Object?>).cast<String>(),
fileMd5: obj['fileMd5']! as String,
);
}
}
/// Converts a stream of bytes, into a stream of bytes of fixed chunk size.

View File

@@ -431,7 +431,7 @@ void main() {
testWithoutContext('transfers file to the daemon with delta turned on, file exists on remote', () async {
bufferLogger = BufferLogger.test();
final FakeFileTransfer fileTransfer = FakeFileTransfer();
final BlockHashes blockHashes = BlockHashes(
const BlockHashes blockHashes = BlockHashes(
blockSize: 10,
totalSize: 30,
adler32: <int>[1, 2, 3],