Flutter Questions
Warm up for your Flutter Interview with most asked questions and answers for junior, mid, and senior roles.
What is Flutter?
Show AnswerHide 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.
What are the advantages of using Flutter?
Show AnswerHide 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
What is Dart?
Show AnswerHide 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.
What is the difference between hot reload, hot restart, and full restart?
Show AnswerHide Answer
- Hot reload loads code changes into the VM and re-builds the widget tree, preserving the app state; it doesn’t rerun
main()
orinitState().
- 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.
Explain BuildContext.
Show AnswerHide Answer
BuildContext is a locator that is used to track each widget in a tree and locate them and their position in the tree.
What is Flutter Inspector?
Show AnswerHide Answer
Flutter Inspector is a tool for debugging Flutter apps.
What is the difference between runApp() and main() in Flutter?
Show AnswerHide 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.
What do you mean by keys in flutter?
Show AnswerHide 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.
When to use mainAxisAlignment and crossAxisAlignment
Show AnswerHide 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.
List some State Management approaches in Flutter.
Show AnswerHide Answer
Some of the State Management approaches in Flutter are:
- Bloc
- Provider
- Riverpod
- MobX
- setState
List some ways to handle persistence in Flutter
Show AnswerHide Answer
Some of the ways to handle persistence in Flutter are:
- Shared Preferences
- SQLite
- File System
Write the difference between SizedBox Vs Container.
Show AnswerHide 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.
What is the usage of MediaQuery in Flutter?
Show AnswerHide Answer
MediaQuery is a widget that provides information about the size and shape of the screen.
List some ways to improve performance in Flutter
Show AnswerHide 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.
What is profile mode, and when do you use it?
Show AnswerHide Answer
Profile mode is a mode that is used to profile the performance of your app. It is used to help you identify bottlenecks.
What is the difference between WidgetsApp and MaterialApp?
Show AnswerHide 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.
What types of tests can you perform in Flutter?
Show AnswerHide Answer
You can perform unit tests, integration tests, and end-to-end tests.
What are the async patterns in Flutter?
Show AnswerHide 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.
What are different build modes in flutter?
Show AnswerHide 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.
What are the types of widgets present in flutter?
Show AnswerHide 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.
What do you mean by Flutter SDK?
Show AnswerHide Answer
The Flutter SDK has the packages and command-line tools that you need to develop Flutter apps across platforms.
What is Mixins?
Show AnswerHide Answer
Mixins are a way to create a class that inherits from another class and adds some functionality to it.
What do you mean by Null-aware operators?
Show AnswerHide 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.
What do you mean by Streams?
Show AnswerHide 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.
What are different types of Streams?
Show AnswerHide 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.
What is the use of Ticker in Flutter?
Show AnswerHide 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.