From 91400f2b11d473c8f48c5102fef684568c126bc9 Mon Sep 17 00:00:00 2001 From: Muhammad Bilal Date: Fri, 23 Jan 2026 14:05:57 +0500 Subject: [PATCH] fix(ios): avoid double-initializing FLTPDFView --- .../Sources/flutter_pdfview/FlutterPDFView.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ios/flutter_pdfview/Sources/flutter_pdfview/FlutterPDFView.m b/ios/flutter_pdfview/Sources/flutter_pdfview/FlutterPDFView.m index 3f393ae0..5f7b1e16 100644 --- a/ios/flutter_pdfview/Sources/flutter_pdfview/FlutterPDFView.m +++ b/ios/flutter_pdfview/Sources/flutter_pdfview/FlutterPDFView.m @@ -42,7 +42,11 @@ - (instancetype)initWithFrame:(CGRect)frame arguments:(id _Nullable)args binaryMessenger:(NSObject*)messenger { self = [super init]; - _pdfView = [[FLTPDFView new] initWithFrame:frame arguments:args controller:self]; + if (!self) return nil; + + // NOTE: `new` already calls `init`. Re-initializing a UIView can crash on newer UIKit + // during trait collection initialization. Use alloc/init instead. + _pdfView = [[FLTPDFView alloc] initWithFrame:frame arguments:args controller:self]; _viewId = viewId; @try {