Flutter Questions

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

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.