diff --git a/lib/web_ui/lib/src/engine/platform_views/message_handler.dart b/lib/web_ui/lib/src/engine/platform_views/message_handler.dart index a46fff244a0ce..b7f084f6571ff 100644 --- a/lib/web_ui/lib/src/engine/platform_views/message_handler.dart +++ b/lib/web_ui/lib/src/engine/platform_views/message_handler.dart @@ -73,8 +73,10 @@ class PlatformViewMessageHandler { if (!_contentManager.knowsViewType(viewType)) { callback(_codec.encodeErrorEnvelope( code: 'unregistered_view_type', - message: 'trying to create a view with an unregistered type', - details: 'unregistered view type: $viewType', + message: 'A HtmlElementView widget is trying to create a platform view ' + 'with an unregistered type: <$viewType>.', + details: 'If you are the author of the PlatformView, make sure ' + '`registerViewFactory` is invoked.', )); return; } diff --git a/lib/web_ui/test/engine/platform_views/message_handler_test.dart b/lib/web_ui/test/engine/platform_views/message_handler_test.dart index 54d14bc300833..119e37aa4a912 100644 --- a/lib/web_ui/test/engine/platform_views/message_handler_test.dart +++ b/lib/web_ui/test/engine/platform_views/message_handler_test.dart @@ -46,7 +46,8 @@ void testMain() { codec.decodeEnvelope(response!); } on PlatformException catch (e) { expect(e.code, 'unregistered_view_type'); - expect(e.details, contains(viewType)); + expect(e.message, contains(viewType)); + expect(e.details, contains('registerViewFactory')); } }); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 9a5387cf86b18..a919ed8b75eee 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -129,7 +129,8 @@ NSDictionary* args = [call arguments]; long viewId = [args[@"id"] longValue]; - std::string viewType([args[@"viewType"] UTF8String]); + NSString* viewTypeString = args[@"viewType"]; + std::string viewType(viewTypeString.UTF8String); if (views_.count(viewId) != 0) { result([FlutterError errorWithCode:@"recreating_view" @@ -139,10 +140,18 @@ NSObject* factory = factories_[viewType].get(); if (factory == nil) { - result([FlutterError errorWithCode:@"unregistered_view_type" - message:@"trying to create a view with an unregistered type" - details:[NSString stringWithFormat:@"unregistered view type: '%@'", - args[@"viewType"]]]); + result([FlutterError + errorWithCode:@"unregistered_view_type" + message:[NSString stringWithFormat:@"A UIKitView widget is trying to create a " + @"PlatformView with an unregistered type: < %@ >", + viewTypeString] + details:@"If you are the author of the PlatformView, make sure `registerViewFactory` " + @"is invoked.\n" + @"See: " + @"https://docs.flutter.dev/development/platform-integration/" + @"platform-views#on-the-platform-side-1 for more details.\n" + @"If you are not the author of the PlatformView, make sure to call " + @"`GeneratedPluginRegistrant.register`."]); return; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.mm b/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.mm index ae751d1ab830a..b15b1ca5ebd42 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.mm @@ -39,8 +39,16 @@ - (void)onCreateWithViewID:(int64_t)viewId if (!factory) { result([FlutterError errorWithCode:@"unregistered_view_type" - message:@"trying to create a view with an unregistered type" - details:[NSString stringWithFormat:@"unregistered view type: '%@'", viewType]]); + message:[NSString stringWithFormat:@"A UIKitView widget is trying to create a " + @"PlatformView with an unregistered type: < %@ >", + viewType] + details:@"If you are the author of the PlatformView, make sure `registerViewFactory` " + @"is invoked.\n" + @"See: " + @"https://docs.flutter.dev/development/platform-integration/" + @"platform-views#on-the-platform-side-1 for more details.\n" + @"If you are not the author of the PlatformView, make sure to call " + @"`GeneratedPluginRegistrant.register`."]); return; }