Flutter Questions

Warm up for your Flutter Interview with most asked questions and answers for junior, mid, and senior roles.

Junior

What is Flutter?

Show Answer

Flutter is a framework for building native apps for iOS and Android. It is a toolkit for building beautiful, high-performance, and usable mobile apps.

Junior

What are the advantages of using Flutter?

Show Answer

Some of the advantages of using Flutter are:

  • Dart
  • Growing popularity
  • High performance
  • Mild learning curve
  • One UI design
  • Money and time economy
  • Powerful community
Junior

What is Dart?

Show Answer

Dart is a client-optimized language for developing fast apps on any platform. Its goal is to offer the most productive programming language for multi-platform development, paired with a flexible execution runtime platform for app frameworks.

Junior

What is the difference between hot reload, hot restart, and full restart?

Show Answer
  • Hot reload loads code changes into the VM and re-builds the widget tree, preserving the app state; it doesn’t rerun main() or initState().
  • Hot restart loads code changes into the VM, and restarts the Flutter app, losing the app state. 
  • Full restart restarts the iOS, Android, or web app. This takes longer because it also recompiles the Java / Kotlin / ObjC / Swift code. On the web, it also restarts the Dart Development Compiler.
Mid

Explain BuildContext.

Show Answer

BuildContext is a locator that is used to track each widget in a tree and locate them and their position in the tree.

Mid

What is Flutter Inspector?

Show Answer

Flutter Inspector is a tool for debugging Flutter apps.

Mid

What is the difference between runApp() and main() in Flutter?

Show Answer

The runApp() function takes the given Widget and makes it the root of the widget tree.

 

The main() function is the entry point of the application. It is the first function that is called when the application is started.

Mid

What do you mean by keys in flutter?

Show Answer

A Key is an identifier for Widgets, Elements, and SemanticsNodes.

 

A new widget will only be used to update an existing element if its key is the same as the key of the current widget associated with the element.

Mid

When to use mainAxisAlignment and crossAxisAlignment

Show Answer

For Row

 

mainAxisAlignment is used to align the children horizontally.

crossAxisAlignment is used to align the children vertically.

 

For Column

 

mainAxisAlignment is used to align the children vertically.

crossAxisAlignment is used to align the children horizontally.

Mid

List some State Management approaches in Flutter.

Show Answer

Some of the State Management approaches in Flutter are:

  • Bloc
  • Provider
  • Riverpod
  • MobX
  • setState
Mid

List some ways to handle persistence in Flutter

Show Answer

Some of the ways to handle persistence in Flutter are:

  • Shared Preferences
  • SQLite
  • File System
Mid

Write the difference between SizedBox Vs Container.

Show Answer

SizedBox() is a widget for giving some constant height or width between two widgets. It does not contain any decorative properties just like color, borderRadius etc.

 

Container() is a convenience widget that combines common painting, positioning, and sizing widgets.

Mid

What is the usage of MediaQuery in Flutter?

Show Answer

MediaQuery is a widget that provides information about the size and shape of the screen.

Mid

List some ways to improve performance in Flutter

Show Answer
  • Use stateless widgets.
  • Split large widgets into smaller widgets.
  • Use the const keyword.
  • Render only widgets that are visible on the screen. 
  • Avoid using opacity as much as possible.
Mid

What is profile mode, and when do you use it?

Show Answer

Profile mode is a mode that is used to profile the performance of your app. It is used to help you identify bottlenecks.

Mid

What is the difference between WidgetsApp and MaterialApp?

Show Answer

MaterialApp

A convenience widget that wraps a number of widgets that are commonly required for material design applications.

It builds upon a WidgetsApp by adding material-design specific functionality, such as AnimatedTheme and GridPaper.

WidgetsApp

A convenience class that wraps a number of widgets that are commonly required for an application.

One of the primary roles that WidgetsApp provides is binding the system back button to popping the Navigator or quitting the application.

Mid

What types of tests can you perform in Flutter?

Show Answer

You can perform unit tests, integration tests, and end-to-end tests.

Mid

What are the async patterns in Flutter?

Show Answer

The async patterns in Flutter are:

    FutureBuilder: Widget that builds itself based on the latest snapshot of interaction with a Future.
    StreamBuilder: Widget that builds itself based on the latest snapshot of interaction with a Stream.
Mid

What are different build modes in flutter?

Show Answer

There are two types of build modes in Flutter:

  • Debug: This is the default mode. It is used to debug the application.
  • Release: This is used to build the application for release.
Mid

What are the types of widgets present in flutter?

Show Answer

There are two main types types of widgets in Flutter:

  • Stateful widgets: These widgets are used to create UI that is dependent on the state of the application.
  • Stateless widgets: These widgets are used to create UI that is independent of the state of the application.
Mid

What do you mean by Flutter SDK?

Show Answer

The Flutter SDK has the packages and command-line tools that you need to develop Flutter apps across platforms.

Senior

What is Mixins?

Show Answer

Mixins are a way to create a class that inherits from another class and adds some functionality to it.

Senior

What do you mean by Null-aware operators?

Show Answer

Null-aware operators are operators that allow you to use the null-safe operator syntax. For example, you can use ?.  to access the property of a nullable object.

Senior

What do you mean by Streams?

Show Answer

A source of asynchronous data events.

 

A Stream provides a way to receive a sequence of events. Each event is either a data event, also called an element of the stream, or an error event, which is a notification that something has failed.

 

When a stream has emitted all its events, a single "done" event notifies the listener that the end has been reached.

Senior

What are different types of Streams?

Show Answer

There are two kinds of streams: "Single-subscription" streams and "broadcast" streams.

 

A single-subscription stream allows only a single listener during the whole lifetime of the stream.

 

It doesn't start generating events until it has a listener, and it stops sending events when the listener is unsubscribed, even if the source of events could still provide more.

 

The stream created by an async* function is a single-subscription stream, but each call to the function creates a new such stream.

 

A broadcast stream allows any number of listeners, and it fires its events when they are ready, whether there are listeners or not.

 

Broadcast streams are used for independent events/observers.

Senior

What is the use of Ticker in Flutter?

Show Answer

Ticker is a "special" periodic timer that we can use to be notified when the Flutter engine is about to draw a new frame.