Bird
Raised Fist0
Fluttermobile~10 mins

Why Flutter enables cross-platform development - Test Your Understanding

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Flutter app that runs on both Android and iOS.

Flutter
void main() {
  runApp([1]());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(child: Text('Hello, Flutter!')),
      ),
    );
  }
}
Drag options to blanks, or click blank then click option'
ACenter
BMyApp
CMaterialApp
DScaffold
Attempts:
3 left
💡 Hint
Common Mistakes
Using MaterialApp directly in runApp instead of the app class.
Trying to run Scaffold or Center directly.
2fill in blank
medium

Complete the code to import the Flutter package needed for cross-platform UI widgets.

Flutter
import '[1]';

void main() => runApp(MyApp());
Drag options to blanks, or click blank then click option'
Apackage:flutter/material.dart
Bpackage:flutter/cupertino.dart
Cpackage:flutter/widgets.dart
Dpackage:flutter/foundation.dart
Attempts:
3 left
💡 Hint
Common Mistakes
Importing cupertino.dart only, which is iOS style.
Importing foundation.dart which is not for UI.
3fill in blank
hard

Fix the error in the code to ensure Flutter renders the UI on both platforms.

Flutter
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return [1](
      home: Scaffold(
        body: Center(child: Text('Cross-platform app')),
      ),
    );
  }
}
Drag options to blanks, or click blank then click option'
AScaffold
BCupertinoApp
CWidgetsApp
DMaterialApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using Scaffold as the root widget instead of MaterialApp.
Using CupertinoApp which is iOS style only.
4fill in blank
hard

Fill both blanks to complete the Flutter widget that adapts UI for Android and iOS.

Flutter
Widget build(BuildContext context) {
  return [1](
    body: [2](
      child: Text('Platform adaptive UI'),
    ),
  );
}
Drag options to blanks, or click blank then click option'
AMaterialApp
BCupertinoPageScaffold
CScaffold
DSafeArea
Attempts:
3 left
💡 Hint
Common Mistakes
Using MaterialApp, which expects 'home' not 'body'.
Using CupertinoPageScaffold which is iOS style only.
5fill in blank
hard

Fill all three blanks to create a Flutter app that uses a single codebase for Android and iOS.

Flutter
void main() {
  runApp([1]());
}

class [2] extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return [3](
      home: Scaffold(
        appBar: AppBar(title: Text('Cross-platform')),
        body: Center(child: Text('One codebase, many platforms')),
      ),
    );
  }
}
Drag options to blanks, or click blank then click option'
AMyApp
BMaterialApp
CStatelessWidget
DMyHomePage
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the app class name (MyApp) with a home page class name like MyHomePage.
Using Scaffold directly in runApp instead of MaterialApp.

Practice

(1/5)
1. Why does Flutter allow developers to create apps that work on both Android and iOS with the same code?
easy
A. Because Flutter only supports Android apps
B. Because Flutter uses a single codebase and its own rendering engine
C. Because Flutter requires separate code for each platform
D. Because Flutter converts code into native Java and Swift automatically

Solution

  1. Step 1: Understand Flutter's codebase approach

    Flutter uses one codebase for all platforms, avoiding separate codes for Android and iOS.
  2. Step 2: Recognize Flutter's rendering engine role

    Flutter has its own engine that draws UI consistently across platforms, so apps look the same everywhere.
  3. Final Answer:

    Because Flutter uses a single codebase and its own rendering engine -> Option B
  4. Quick Check:

    Single codebase + engine = cross-platform [OK]
Hint: Remember: one codebase plus own engine means cross-platform [OK]
Common Mistakes:
  • Thinking Flutter converts code to native Java or Swift
  • Believing Flutter needs separate code for each platform
  • Assuming Flutter only supports Android
2. Which of the following is the correct way to import Flutter's material design package in a Dart file?
easy
A. import 'package:flutter/material.dart';
B. include 'flutter/material.dart';
C. using flutter.material;
D. require('flutter/material.dart');

Solution

  1. Step 1: Recall Dart import syntax

    Dart uses the keyword 'import' followed by the package path in quotes and a semicolon.
  2. Step 2: Match the correct package path

    The Flutter material package path is 'package:flutter/material.dart'.
  3. Final Answer:

    import 'package:flutter/material.dart'; -> Option A
  4. Quick Check:

    Correct Dart import syntax = import 'package:flutter/material.dart'; [OK]
Hint: Dart imports use 'import' and package path in quotes [OK]
Common Mistakes:
  • Using 'include' instead of 'import'
  • Using 'using' or 'require' which are not Dart keywords
  • Missing semicolon at the end
3. What will be the output when running a Flutter app that uses the same widget tree on both Android and iOS?
medium
A. The app crashes on iOS but works on Android
B. The app shows different UI layouts on each platform automatically
C. The app UI looks and behaves identically on both platforms
D. The app only runs on Android devices

Solution

  1. Step 1: Understand Flutter's widget rendering

    Flutter uses its own engine to draw widgets the same way on all platforms.
  2. Step 2: Predict app behavior on Android and iOS

    Since the widget tree is the same, the UI looks and works identically on both platforms.
  3. Final Answer:

    The app UI looks and behaves identically on both platforms -> Option C
  4. Quick Check:

    Same widget tree = same UI on all platforms [OK]
Hint: Same widgets mean same UI everywhere [OK]
Common Mistakes:
  • Thinking Flutter apps crash on iOS by default
  • Assuming Flutter changes UI layout automatically per platform
  • Believing Flutter apps only run on Android
4. You wrote a Flutter app but it crashes on iOS with a missing plugin error. What is the likely cause?
medium
A. You forgot to run 'flutter pub get' to install dependencies
B. Flutter does not support iOS apps
C. You wrote the app in Java instead of Dart
D. You used Android-only plugins without iOS support

Solution

  1. Step 1: Identify the error cause

    A missing plugin error on iOS usually means the plugin used lacks iOS support.
  2. Step 2: Understand Flutter plugin platform support

    Some plugins work only on Android; using them causes crashes on iOS.
  3. Final Answer:

    You used Android-only plugins without iOS support -> Option D
  4. Quick Check:

    Plugin missing on iOS = Android-only plugin used [OK]
Hint: Check plugin supports all target platforms [OK]
Common Mistakes:
  • Assuming Flutter doesn't support iOS
  • Forgetting to run 'flutter pub get' (usually different error)
  • Confusing Dart with Java language
5. You want to create a Flutter app that runs on Android, iOS, and web with consistent UI. Which approach best achieves this?
hard
A. Use Flutter widgets and its rendering engine for all platforms
B. Write separate UI code for Android, iOS, and web
C. Use native Android and iOS SDKs and a separate web framework
D. Build the app only for Android and ignore other platforms

Solution

  1. Step 1: Understand Flutter's cross-platform capabilities

    Flutter uses widgets and its own engine to create consistent UI across Android, iOS, and web.
  2. Step 2: Compare approaches for multi-platform UI

    Writing separate UI code or using native SDKs defeats Flutter's cross-platform advantage.
  3. Step 3: Choose the best approach

    Using Flutter widgets and engine for all platforms ensures consistent UI and easier maintenance.
  4. Final Answer:

    Use Flutter widgets and its rendering engine for all platforms -> Option A
  5. Quick Check:

    Widgets + engine = consistent UI everywhere [OK]
Hint: One Flutter codebase for all platforms saves time [OK]
Common Mistakes:
  • Trying to write separate UI code for each platform
  • Using native SDKs separately instead of Flutter
  • Ignoring web or other platforms
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard