Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/cli/commands/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class RunCommand extends fltool.RunCommand with FlutterpiCommandMixin {
usesDeviceManager();
usesEngineFlavorOption();
usesDebugSymbolsOption();
usesRotationOption();
}

@protected
Expand Down Expand Up @@ -39,7 +40,6 @@ class RunCommand extends fltool.RunCommand with FlutterpiCommandMixin {
@override
Future<FlutterCommandResult> runCommand() async {
await populateCache();

return super.runCommand();
}
}
26 changes: 26 additions & 0 deletions lib/src/cli/flutterpi_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ mixin FlutterpiCommandMixin on FlutterCommand {
return remote.contains('@') ? remote.split('@').first : null;
}

int get rotation {
final rotationString = stringArg('rotation');
if (rotationString == null) {
return 0;
}
final rotationInt = int.tryParse(rotationString);
if (rotationInt == null) {
usageException('Invalid --rotation: Expected an integer in degrees. ');
}
return rotationInt;
}

final _contextOverrides = <Type, dynamic Function()>{};

void addContextOverride<T>(dynamic Function() fn) {
Expand Down Expand Up @@ -249,6 +261,7 @@ mixin FlutterpiCommandMixin on FlutterCommand {
fs: globals.fs,
logger: globals.logger,
platform: globals.platform,
rotation: rotation,
),
deviceId: stringArg(FlutterGlobalOptions.kDeviceIdOption, global: true),
),
Expand Down Expand Up @@ -290,6 +303,18 @@ mixin FlutterpiCommandMixin on FlutterCommand {
);
}

void usesRotationOption() {
argParser.addOption(
'rotation',
abbr: 'r',
help: 'Start the app with this rotation. This is just an '
'alternative, more intuitive way to specify the '
'startup orientation. The angle is in degrees and clock-wise',
allowed: ['0', '90', '180', '270'],
defaultsTo: '0',
);
}

bool getIncludeDebugSymbols() {
return boolArg('debug-symbols');
}
Expand Down Expand Up @@ -431,6 +456,7 @@ mixin FlutterpiCommandMixin on FlutterCommand {
fs: globals.fs,
logger: globals.logger,
platform: globals.platform,
rotation: rotation,
),
BuildTargets: () => const BuildTargetsImpl(),
ApplicationPackageFactory: () => FlutterpiApplicationPackageFactory(),
Expand Down
2 changes: 2 additions & 0 deletions lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class FlutterPiToolConfig {
required this.fs,
required this.logger,
required this.platform,
required this.rotation,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this isn't really clear in the code, but the FlutterPiToolConfig class basically represents the persistent configuration file of the flutterpi_tool, where the devices and their options are stored. I think the rotation might be better fit somewhere else

}) : _config = Config(
'flutterpi_tool_config',
fileSystem: fs,
Expand All @@ -88,6 +89,7 @@ class FlutterPiToolConfig {
final Logger logger;
final Platform platform;
final Config _config;
final int rotation;

List<DeviceConfigEntry> getDevices() {
final entries = _config.getValue('devices');
Expand Down
6 changes: 6 additions & 0 deletions lib/src/devices/flutterpi_ssh/device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:io';
import 'package:flutterpi_tool/src/build_system/build_app.dart';
import 'package:flutterpi_tool/src/cache.dart';
import 'package:flutterpi_tool/src/common.dart';
import 'package:flutterpi_tool/src/config.dart';
import 'package:flutterpi_tool/src/fltool/common.dart';
import 'package:flutterpi_tool/src/fltool/globals.dart';
import 'package:flutterpi_tool/src/more_os_utils.dart';
Expand Down Expand Up @@ -109,6 +110,7 @@ class FlutterpiSshDevice extends Device {
required String id,
required this.name,
required this.sshUtils,
required this.config,
required String? remoteInstallPath,
required this.logger,
required this.os,
Expand All @@ -129,6 +131,7 @@ class FlutterpiSshDevice extends Device {
final Logger logger;
final FlutterpiCache cache;
final MoreOperatingSystemUtils os;
final FlutterPiToolConfig config;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, maybe instead introduce a final int? rotation member instead, just like the explicitDevicePixelRatio and explicitDisplaySizeMillimeters.


final runningApps = <String, _RunningApp>{};
final logReaders = <String, CustomDeviceLogReader>{};
Expand Down Expand Up @@ -330,6 +333,7 @@ class FlutterpiSshDevice extends Device {
required String flutterpiExe,
required String bundlePath,
required BuildMode runtimeMode,
required int rotation,
Iterable<String> engineArgs = const [],
Iterable<String> dartCmdlineArgs = const [],
}) {
Expand All @@ -346,6 +350,7 @@ class FlutterpiSshDevice extends Device {
'--dimensions',
'$width,$height',
],
'--rotation', rotation.toString(),
if (runtimeModeArg != null) runtimeModeArg,
bundlePath,
...engineArgs,
Expand Down Expand Up @@ -495,6 +500,7 @@ class FlutterpiSshDevice extends Device {
flutterpiExe: flutterpiExePath,
bundlePath: remoteInstallPath,
runtimeMode: debuggingOptions.buildInfo.mode,
rotation: config.rotation,
engineArgs: [
...engineArgs,
if (debuggingOptions.deviceVmServicePort == null)
Expand Down
1 change: 1 addition & 0 deletions lib/src/devices/flutterpi_ssh/device_discovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class FlutterpiSshDeviceDiscovery extends PollingDeviceDiscovery {
os: os,
explicitDisplaySizeMillimeters: configEntry.displaySizeMillimeters,
explicitDevicePixelRatio: null,
config: config,
);
}

Expand Down