Sample questions
Question 1Easy
What does invokeMethod on a MethodChannel return in Dart?
- A Future, since the call is asynchronous
- A Stream of partial results from the native side
- The native result synchronously, as an Object
- void, because native code cannot return values
Answer: A. A Future, since the call is asynchronous
Explanation
Channel calls cross to the platform thread and back, so the result arrives later as a Future.
Step-by-step solution
- MethodChannel calls cross to the platform thread.
- The native side processes the request asynchronously.
- The result is sent back to the Dart isolate later.
- Therefore,
invokeMethod returns a Future. - The final answer is A Future, since the call is asynchronous.
Why the other options are wrong
- B. invokeMethod returns one result, not a Stream of partial results; that is an EventChannel.
- C. The result cannot be read synchronously; the call returns a Future that completes later.
- D. Native code can return values to Dart, so the result is not void.
Tip: Always use await or .then() when handling invokeMethod results.
Question 2Easy
What is a Flutter plugin package?
- A package with a Dart API plus native code per platform
- An IDE extension that adds Flutter support to the editor
- A pure Dart package that has no platform-specific code at all
- A command-line tool for publishing apps to the stores
Answer: A. A package with a Dart API plus native code per platform
Explanation
Plugins such as camera or shared storage wrap platform channels: you call the Dart API and the plugin's native code does the platform work.
Step-by-step solution
- Flutter plugins have a Dart API for cross-platform code.
- They include native code for each platform like Android or iOS.
- The native code handles platform-specific tasks.
- Dart code communicates with native code via platform channels.
- So, a Flutter plugin is a package with a Dart API plus native code per platform.
Why the other options are wrong
- B. A plugin is a package for app code; IDE extensions are a separate kind of tool.
- C. A pure Dart package has no native part; a plugin needs platform code for each target.
- D. Publishing tools are not plugins; a plugin provides platform functionality to an app.
Tip: Remember: Flutter plugins are not pure Dart; they include native code for each platform.
Question 3Easy
Which channel type is used to call a named native method and get one result back?
- IsolateChannel
- StreamChannel
- EventChannel
- MethodChannel
Answer: D. MethodChannel
Explanation
MethodChannel.invokeMethod('name', args) sends a method call and returns a Future with the native result.
Step-by-step solution
- MethodChannel is designed for request-response interactions.
- It calls a named native method with specific arguments.
- The native side processes the request and returns a single result.
- This matches the definition of calling a method and getting one result back.
- The correct answer is MethodChannel.
Why the other options are wrong
- A. IsolateChannel is for passing messages between Dart isolates, not native method calls.
- B. StreamChannel wraps a Dart stream pair and has no native method-call role.
- C. EventChannel streams a series of events from native to Dart; it does not return one result.
Tip: Use MethodChannel for one-time requests that need a single return value.
Question 4Easy
Which channel type suits a continuous series of native events, such as sensor readings?
- RouteChannel
- EventChannel
- MethodChannel
- PlatformView
Answer: B. EventChannel
Explanation
An EventChannel exposes native events as a Dart Stream that the app can listen to.
Step-by-step solution
- EventChannel is designed for continuous streams of native events.
- Sensor readings are continuous and require real-time updates.
- Dart Streams efficiently handle continuous data flows from native sources.
- EventChannel connects native event emitters to Dart Stream listeners.
- This makes EventChannel ideal for sensor reading scenarios.
- Final answer: B (EventChannel).
Why the other options are wrong
- A. RouteChannel is not a Flutter channel type; route changes use the Navigator.
- C. MethodChannel is for one request with one reply, not a continuous stream of readings.
- D. PlatformView embeds a native UI view in the widget tree; it does not carry sensor events.
Tip: Use EventChannel for continuous native event streams.
Question 5Medium
How does BasicMessageChannel differ from MethodChannel?
- It can send only binary data and never text or structured data
- It is synchronous, while MethodChannel is always asynchronous
- It is only for native-to-Dart events and is read as a Stream
- It sends plain messages with a codec, with no method names
Answer: D. It sends plain messages with a codec, with no method names
Explanation
BasicMessageChannel exchanges messages of a codec's type in both directions; MethodChannel adds the method-name-plus-arguments convention on top.
Step-by-step solution
- BasicMessageChannel sends plain messages with a codec.
- It has no method names.
Why the other options are wrong
- A. It can send text and structured data.
- B. Both are asynchronous.
- C. Streams are EventChannel.
Tip: Basic = messages only.
Question 6Medium
Dart calls a method that the native handler does not implement (it calls notImplemented). What does Dart receive?
- A null result without any error
- A MissingPluginException
- A TimeoutException after a delay
- A PlatformException with code 404
Answer: B. A MissingPluginException
Explanation
If no handler is registered, or the handler reports notImplemented, the Future completes with MissingPluginException.
Step-by-step solution
- Dart calls a method with no native handler implemented.
- The native handler returns notImplemented.
- Dart receives a MissingPluginException from the platform.
- No other exceptions are thrown in this scenario.
- Final answer: A MissingPluginException.
Why the other options are wrong
- A. Dart gets an exception, not a null; a missing handler is reported, not silently ignored.
- C. No timeout is involved; the handler reports notImplemented right away, so there is no delay.
- D. There is no code 404 here; a missing handler gives MissingPluginException, not PlatformException.
Tip: Remember: missing plugins throw MissingPluginException in Dart.
Question 7Medium
What problem does the Pigeon tool solve for platform channels?
- It compresses channel messages so large images can be sent more quickly
- It generates type-safe Dart and native code for both sides
- It replaces all platform channels with HTTP calls to a local server
- It runs native Android code directly on iOS devices without any changes
Answer: B. It generates type-safe Dart and native code for both sides
Explanation
Hand-written channels rely on matching strings and untyped maps. Pigeon generates both sides from one Dart interface definition, so mismatches are caught at compile time.
Step-by-step solution
- Pigeon defines a Dart interface once.
- It generates type-safe Dart and native code.
- Mismatches are caught at compile time.
Why the other options are wrong
- A. It does not compress messages.
- C. It does not use HTTP.
- D. It does not run Android code on iOS.
Tip: Pigeon = typed channels.
Question 8Medium
Which values can the standard message codec send over a channel without extra work?
- null, bools, numbers, Strings, Lists, Maps and typed data
- Only Strings; everything else must be encoded as JSON text
- Only numbers and booleans, encoded in a single binary blob
- Any Dart object, including your own classes and their methods
Answer: A. null, bools, numbers, Strings, Lists, Maps and typed data
Explanation
StandardMessageCodec handles basic types and collections of them. Custom classes must be converted, for example to a Map, or handled by a generated codec.
Step-by-step solution
- StandardMessageCodec sends null, bools, numbers, Strings, Lists, Maps and typed data directly.
- These are basic types and collections of them that it handles without extra work.
- Custom classes need to be converted or handled by a generated codec.
- So the correct values are null, bools, numbers, Strings, Lists, Maps and typed data.
- Final answer: null, bools, numbers, Strings, Lists, Maps and typed data.
Why the other options are wrong
- B. Strings are not the only type; the standard codec handles numbers, bools and collections too.
- C. Numbers and bools are not the only types, and the codec does not use one binary blob for all.
- D. Arbitrary Dart objects and methods are not sent; custom classes need their own encoding.
Tip: Remember: only basic types and collections are sent without extra work.
Question 9Hard
An app must show a native map SDK view inside the Flutter widget tree, overlapping Flutter widgets. What feature is used?
- A CustomPainter that draws the native map's canvas
- An EventChannel streaming the map frames as images
- A MethodChannel that returns the native view object
- Platform views, such as AndroidView and UiKitView
Answer: D. Platform views, such as AndroidView and UiKitView
Explanation
Platform views embed real native views into Flutter's rendering. They have a composition cost, so they are used only when a native view is necessary.
Step-by-step solution
- A native map is a real native view.
- Platform views embed native views in the Flutter tree.
- AndroidView and UiKitView are the widgets.
Why the other options are wrong
- A. You cannot draw a native canvas with CustomPainter.
- B. EventChannel streams events, not live views.
- C. A MethodChannel cannot return a native view object.
Tip: Native view in Flutter = platform view.
Question 10Hard
How does calling C code through dart:ffi differ from using a platform channel?
- FFI sends messages through a MethodChannel with a different codec underneath
- FFI only works on the web platform and is not available on mobile
- FFI calls native functions directly and synchronously
- FFI runs the C code on a server and returns the result over HTTP
Answer: C. FFI calls native functions directly and synchronously
Explanation
FFI binds to C symbols in the same process, so calls are synchronous and avoid serialisation. Platform channels are asynchronous message passing to the host platform.
Step-by-step solution
- Dart:ffi loads a dynamic library containing C symbols.
- It looks up the required C function by name.
- The Dart code invokes the C function directly in the same process.
- FFI calls native functions directly and synchronously.
Why the other options are wrong
- A. FFI does not go through a MethodChannel; it calls C functions directly in the same process.
- B. FFI works on mobile and desktop; it is not limited to the web platform.
- D. FFI calls run in the same process on the device, not on a server over HTTP.
Tip: Use FFI for low‑latency native calls, not for UI communication.
Practise all 14 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →