Flutter iOS Embedder
FlutterView Class Reference

#import <FlutterView.h>

Inheritance diagram for FlutterView:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(instancetype) - initWithFrame:
 
(instancetype) - initWithCoder:
 
(instancetype) - initWithDelegate:opaque:enableWideGamut:
 
(UIScreen *) - screen
 
(MTLPixelFormat) - pixelFormat
 
(void) - setIntrinsicContentSize:
 
(void) - resetIntrinsicContentSize
 

Class Methods

(instancetype) + NS_UNAVAILABLE
 

Properties

BOOL autoResizable
 

Detailed Description

Definition at line 49 of file FlutterView.h.

Method Documentation

◆ initWithCoder:

- (instancetype) initWithCoder: (NSCoder*)  NS_UNAVAILABLE

Definition at line 24 of file FlutterView.mm.

37  :(NSCoder*)aDecoder {
38  NSAssert(NO, @"FlutterView must initWithDelegate");
39  return nil;
40 }

◆ initWithDelegate:opaque:enableWideGamut:

- (instancetype) initWithDelegate: (id<FlutterViewEngineDelegate>)  delegate
opaque: (BOOL)  opaque
enableWideGamut: (BOOL)  NS_DESIGNATED_INITIALIZER 

Definition at line 24 of file FlutterView.mm.

137  :(id<FlutterViewEngineDelegate>)delegate
138  opaque:(BOOL)opaque
139  enableWideGamut:(BOOL)isWideGamutEnabled {
140  if (delegate == nil) {
141  NSLog(@"FlutterView delegate was nil.");
142  return nil;
143  }
144 
145  self = [super initWithFrame:CGRectNull];
146 
147  if (self) {
148  _delegate = delegate;
149  _isWideGamutEnabled = isWideGamutEnabled;
150  self.layer.opaque = opaque;
151  _autoResizable = NO;
152  _intrinsicSize = CGSizeMake(UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric);
153  }
154 
155  return self;
156 }
CGSize _intrinsicSize
Definition: FlutterView.mm:22

◆ initWithFrame:

- (instancetype) initWithFrame: (CGRect)  NS_UNAVAILABLE

Definition at line 24 of file FlutterView.mm.

32  :(CGRect)frame {
33  NSAssert(NO, @"FlutterView must initWithDelegate");
34  return nil;
35 }

◆ NS_UNAVAILABLE [1/2]

+ (instancetype) NS_UNAVAILABLE

◆ NS_UNAVAILABLE [2/2]

- (instancetype) NS_UNAVAILABLE

◆ pixelFormat

- (MTLPixelFormat) pixelFormat

Definition at line 24 of file FlutterView.mm.

111  {
112  if ([self.layer isKindOfClass:[CAMetalLayer class]]) {
113 // It is a known Apple bug that CAMetalLayer incorrectly reports its supported
114 // SDKs. It is, in fact, available since iOS 8.
115 #pragma clang diagnostic push
116 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
117  CAMetalLayer* layer = (CAMetalLayer*)self.layer;
118  return layer.pixelFormat;
119  }
120  return MTLPixelFormatBGRA8Unorm;
121 }

◆ resetIntrinsicContentSize

- (void) resetIntrinsicContentSize

A method that resets and recalculates the instrinsic content size Currently called when the device orientation changes.

Definition at line 24 of file FlutterView.mm.

98  {
99  _intrinsicSize = CGSizeMake(UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric);
100  [self removeAutoResizeLayoutConstraints];
101 }

◆ screen

- (UIScreen *) screen

Definition at line 24 of file FlutterView.mm.

42  {
43  return self.window.windowScene.screen;
44 }

◆ setIntrinsicContentSize:

- (void) setIntrinsicContentSize: (CGSize)  size

A method that sets the instrinsic content size This is used when autoResizable is enabled.

Definition at line 24 of file FlutterView.mm.

52  :(CGSize)size {
53  if (!self.autoResizable) {
54  return;
55  }
56 
57  UIWindow* window = self.window;
58  CGFloat scale = window ? self.window.windowScene.screen.scale : self.traitCollection.displayScale;
59  CGSize scaledSize = CGSizeMake(size.width / scale, size.height / scale);
60 
61  CGSize roundedScaleSize = CGSizeMake(roundf(scaledSize.width), roundf(scaledSize.height));
62  CGSize roundedIntrinsicSize =
63  CGSizeMake(roundf(_intrinsicSize.width), roundf(_intrinsicSize.height));
64 
65  // If the size has not changed, don't update constraints.
66  if (CGSizeEqualToSize(roundedIntrinsicSize, roundedScaleSize)) {
67  return;
68  }
69  _intrinsicSize = scaledSize;
70 
71  self.translatesAutoresizingMaskIntoConstraints = false;
72 
73  // Remove any existing FlutterAutoResizeLayoutConstraint
74  [self removeAutoResizeLayoutConstraints];
75 
76  FlutterAutoResizeLayoutConstraint* widthConstraint =
77  [FlutterAutoResizeLayoutConstraint constraintWithItem:self
78  attribute:NSLayoutAttributeWidth
79  relatedBy:NSLayoutRelationEqual
80  toItem:nil
81  attribute:NSLayoutAttributeNotAnAttribute
82  multiplier:1.0
83  constant:scaledSize.width];
84 
85  FlutterAutoResizeLayoutConstraint* heightConstraint =
86  [FlutterAutoResizeLayoutConstraint constraintWithItem:self
87  attribute:NSLayoutAttributeHeight
88  relatedBy:NSLayoutRelationEqual
89  toItem:nil
90  attribute:NSLayoutAttributeNotAnAttribute
91  multiplier:1.0
92  constant:scaledSize.height];
93 
94  [NSLayoutConstraint activateConstraints:@[ widthConstraint, heightConstraint ]];
95  [self setNeedsLayout];
96 }
BOOL autoResizable
Definition: FlutterView.h:74

Property Documentation

◆ autoResizable

- (BOOL) autoResizable
readwritenonatomicassign

Definition at line 74 of file FlutterView.h.


The documentation for this class was generated from the following files: