Skip to content

Commit

Permalink
Merge pull request google#1 from google/master
Browse files Browse the repository at this point in the history
fast-forward
  • Loading branch information
csells committed Jul 26, 2019
2 parents 25dc7d9 + d000d75 commit 912324d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
26 changes: 5 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ as breaking changes for desktop happen frequently.

### Tools

Run `flutter doctor` and be sure that no issues are reported for the sections
relevant to your platform.
First you will need to [enable Flutter desktop support for your
platform](https://github.com/flutter/flutter/wiki/Desktop-shells#tooling).

Then run `flutter doctor` and be sure that no issues are reported for the
sections relevant to your platform.

## Running a Project

Expand All @@ -40,25 +43,6 @@ asserts will fire, the observatory will be enabled, etc.
See [the example README](example/README.md) for information on using the
example as a starting point to run another project.

### IDEs

If you want to use an IDE to run a Flutter project on desktop, you will need to
have the `ENABLE_FLUTTER_DESKTOP` environment variable set to `true` in the IDE:
* VS Code: Add the flag to [dart.env](https://dartcode.org/docs/settings/#dartenv)
in the VS Code `settings.json`:
```
"dart.env": {
"ENABLE_FLUTTER_DESKTOP": true,
}
```
* You can also attach to a desktop Flutter application launched some other way
using the `Debug: Attach to Flutter Process` command and copying in the
Observatory URI that was logged on launch.
* IntelliJ/Android Studio: You will need to set the environment for the
application using the normal process for your OS (e.g., launching it from a
terminal with the environment variable set may work). You will know the
variable is correctly set if the devices menu lists your machine as a device.

## Repository Structure

`testbed` is a more complex example that is primarily intended for people
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class UrlLauncherPlugin : public flutter::Plugin {
private:
UrlLauncherPlugin();

// Called when a method is called on |channel_|;
// Called when a method is called on the plugin's channel;
void HandleMethodCall(
const flutter::MethodCall<EncodableValue> &method_call,
std::unique_ptr<flutter::MethodResult<EncodableValue>> result);
Expand Down Expand Up @@ -94,6 +94,7 @@ void UrlLauncherPlugin::HandleMethodCall(
std::ostringstream error_message;
error_message << "Failed to open " << url << ": error " << status;
result->Error("open_error", error_message.str());
return;
}
result->Success();
} else {
Expand Down
25 changes: 18 additions & 7 deletions plugins/window_size/macos/Classes/FLEWindowSizePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ NSRect GetFlippedRect(NSRect frame) {
}

@interface FLEWindowSizePlugin ()

/// The view displaying Flutter content.
@property(nonatomic, readonly) NSView *flutterView;

/**
* Extracts information from |screen| and returns the serializable form expected
* by the platform channel.
Expand All @@ -70,23 +74,30 @@ - (NSArray *)platformChannelRepresentationForFrame:(NSRect)frame;
@implementation FLEWindowSizePlugin {
// The channel used to communicate with Flutter.
FlutterMethodChannel *_channel;
// The view displaying Flutter content.
NSView *_flutterView;

// A reference to the registrar holding the NSView used by the plugin. Holding a reference
// since the view might be nil at the time the plugin is created.
id<FlutterPluginRegistrar> _registrar;
}

- (NSView *)flutterView {
return _registrar.view;
}

+ (void)registerWithRegistrar:(id<FlutterPluginRegistrar>)registrar {
FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:kChannelName
binaryMessenger:registrar.messenger];
FLEWindowSizePlugin *instance = [[FLEWindowSizePlugin alloc] initWithChannel:channel
view:registrar.view];
registrar:registrar];
[registrar addMethodCallDelegate:instance channel:channel];
}

- (instancetype)initWithChannel:(FlutterMethodChannel *)channel view:(NSView *)view {
- (instancetype)initWithChannel:(FlutterMethodChannel *)channel
registrar:(id<FlutterPluginRegistrar>)registrar {
self = [super init];
if (self) {
_channel = channel;
_flutterView = view;
_registrar = registrar;
}
return self;
}
Expand All @@ -105,10 +116,10 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
}
methodResult = screenList;
} else if ([call.method isEqualToString:kGetWindowInfoMethod]) {
methodResult = [self platformChannelRepresentationForWindow:_flutterView.window];
methodResult = [self platformChannelRepresentationForWindow:self.flutterView.window];
} else if ([call.method isEqualToString:kSetWindowFrameMethod]) {
NSArray<NSNumber *> *arguments = call.arguments;
[_flutterView.window
[self.flutterView.window
setFrame:GetFlippedRect(NSMakeRect(arguments[0].doubleValue, arguments[1].doubleValue,
arguments[2].doubleValue, arguments[3].doubleValue))
display:YES];
Expand Down

0 comments on commit 912324d

Please sign in to comment.