Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4104eb5

Browse files
authored
Revert "[macOS] Make FlutterEngine support multiple views (#37976)" (#39536)
1 parent c9574d5 commit 4104eb5

15 files changed

+95
-329
lines changed

shell/platform/darwin/macos/framework/Headers/FlutterEngine.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ extern const uint64_t kFlutterDefaultViewId;
3232

3333
/**
3434
* Coordinates a single instance of execution of a Flutter engine.
35-
*
36-
* A FlutterEngine can only be attached with one controller from the native
37-
* code.
3835
*/
3936
FLUTTER_DARWIN_EXPORT
4037
@interface FlutterEngine : NSObject <FlutterTextureRegistry, FlutterPluginRegistry>
@@ -79,9 +76,10 @@ FLUTTER_DARWIN_EXPORT
7976
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint;
8077

8178
/**
82-
* The `FlutterViewController` of this engine, if any.
79+
* The default `FlutterViewController` associated with this engine, if any.
8380
*
84-
* This view is used by legacy APIs that assume a single view.
81+
* The default view always has ID kFlutterDefaultViewId, and is the view
82+
* operated by the APIs that do not have a view ID specified.
8583
*
8684
* Setting this field from nil to a non-nil view controller also updates
8785
* the view controller's engine and ID.

shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,12 @@ FLUTTER_DARWIN_EXPORT
3636
@property(nonnull, readonly) id<FlutterTextureRegistry> textures;
3737

3838
/**
39-
* The default view displaying Flutter content.
39+
* The view displaying Flutter content. May return |nil|, for instance in a headless environment.
4040
*
41-
* This method may return |nil|, for instance in a headless environment.
42-
*
43-
* The default view is a special view operated by single-view APIs.
44-
*/
45-
- (nullable NSView*)view;
46-
47-
/**
48-
* The `NSView` associated with the given view ID, if any.
41+
* WARNING: If/when multiple Flutter views within the same application are supported (#30701), this
42+
* API will change.
4943
*/
50-
- (nullable NSView*)viewForId:(uint64_t)viewId;
44+
@property(nullable, readonly) NSView* view;
5145

5246
/**
5347
* Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|.

shell/platform/darwin/macos/framework/Headers/FlutterViewController.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ FLUTTER_DARWIN_EXPORT
8989
NS_DESIGNATED_INITIALIZER;
9090
- (nonnull instancetype)initWithCoder:(nonnull NSCoder*)nibNameOrNil NS_DESIGNATED_INITIALIZER;
9191
/**
92-
* Initializes this FlutterViewController with an existing `FlutterEngine`.
93-
*
94-
* The initialized view controller will add itself to the engine as part of this process.
92+
* Initializes this FlutterViewController with the specified `FlutterEngine`.
9593
*
9694
* This initializer is suitable for both the first Flutter view controller and
9795
* the following ones of the app.

shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// TODO(dkwingsmt): This class only supports single-view for now. As more
2020
// classes are gradually converted to multi-view, it should get the view ID
2121
// from somewhere.
22-
FlutterView* view = [view_provider_ viewForId:kFlutterDefaultViewId];
22+
FlutterView* view = [view_provider_ getView:kFlutterDefaultViewId];
2323
if (!view) {
2424
return false;
2525
}
@@ -37,7 +37,7 @@
3737
bool FlutterCompositor::Present(uint64_t view_id,
3838
const FlutterLayer** layers,
3939
size_t layers_count) {
40-
FlutterView* view = [view_provider_ viewForId:view_id];
40+
FlutterView* view = [view_provider_ getView:view_id];
4141
if (!view) {
4242
return false;
4343
}

shell/platform/darwin/macos/framework/Source/FlutterCompositorTest.mm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h"
1212
#import "flutter/testing/testing.h"
1313

14-
extern const uint64_t kFlutterDefaultViewId;
15-
1614
@interface FlutterViewMockProvider : NSObject <FlutterViewProvider> {
1715
FlutterView* _defaultView;
1816
}
@@ -32,7 +30,7 @@ - (nonnull instancetype)initWithDefaultView:(nonnull FlutterView*)view {
3230
return self;
3331
}
3432

35-
- (nullable FlutterView*)viewForId:(uint64_t)viewId {
33+
- (nullable FlutterView*)getView:(uint64_t)viewId {
3634
if (viewId == kFlutterDefaultViewId) {
3735
return _defaultView;
3836
}

0 commit comments

Comments
 (0)