Skip to content
tezvyn:
Menu

Present full-screen native SDK UI from Flutter and return a result

Source: docs.flutter.devHardHow cards are made

This tests platform channel architecture for full-screen native UI delegation. Use MethodChannel to launch the native controller, retain the async result callback, serialize the dismissal payload back to Dart, and avoid PlatformView for modal flows.

What's really being asked

This question evaluates whether you can distinguish between inline native embedding and full-screen native presentation in Flutter, and whether you know how to bridge asynchronous UI flows across the platform channel boundary. The interviewer cares about your understanding of MethodChannel bidirectional communication, native view controller and activity lifecycle management, and correct API selection.

The full answer

First, state that MethodChannel is the correct integration point because PlatformView is designed for rendering native views inside the Flutter widget tree and cannot present a modal UIViewController or start a full-screen Activity outside of that tree. Second, describe the async handshake pattern where Dart invokes a platform method to request presentation, the native side stores the FlutterResult or MethodChannel.Result reference, presents the SDK UI, and later invokes that stored reference with the payload after dismissal. Third, mention lifecycle safety such as presenting on the rootViewController on iOS or using the current Activity on Android, and guarding against engine detachment or activity destruction during the native flow. Fourth, explain result serialization by converting the native SDK object into a Map or JSON structure that crosses the channel, plus error handling for cancellations or SDK failures.

The mistakes people make

The biggest red flag is suggesting PlatformView for a full-screen native controller, which reveals a fundamental misunderstanding of the embedding API. Another red flag is attempting to return the selected item synchronously from the platform method instead of using the async result callback. Proposing to reimplement the third-party SDK UI in Flutter widgets is also wrong because the question explicitly provides a native SDK that must be used as-is.

What usually comes next

The interviewer may ask how you would handle Android configuration changes that destroy the Activity while the native SDK is showing, or how you would surface SDK errors through the channel as a PlatformException. They might also ask whether you would use Pigeon for type-safe channel contracts in production, or how you would mock the native layer for widget tests on the Dart side.

A concrete example

Imagine integrating a native document scanner SDK. On the Dart side, you call scanDocument through a MethodChannel and await a Map result. On iOS, the platform handler in a plugin or app delegate instantiates the SDK ScannerViewController, configures it, and presents it on the topmost UIViewController. When the scanner delegate fires didFinishWithResult, the handler calls the stored FlutterResult with a dictionary containing documentPath and confidenceScore. On Android, the handler launches the SDK ScannerActivity via startActivityForResult from the current Activity. In the plugins onActivityResult override, you extract the URI and metadata from the intent, then return them through result.success.

Interview question

You need to present a full-screen native SDK scanner from Flutter and return the scanned document to Dart. Which approach is architecturally correct?

  • a.Embed the native scanner using PlatformView inside a full-screen Flutter widget and manage dismissal through Flutter navigation
  • b.Return the scan result synchronously from the MethodChannel handler immediately after launching the native scanner
  • c.Start the scanner natively and push the result back to Dart by calling invokeMethod on the channel from the native side
  • d.Launch the scanner via MethodChannel, retain the native Result callback, and invoke it with serialized data after dismissalCorrect
Why?

Storing the native Result reference and invoking it after the SDK dismisses correctly bridges the async boundary without blocking the platform thread. PlatformView is the most tempting distractor, but it is designed for inline embedding within the widget tree and cannot present a modal UIViewController or start a standalone full-screen Activity.

Just read this? Test yourself on what you have been reading.

Read the original → docs.flutter.dev

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on flutter — each one lists the topics its interview covers.

See open roles