Frequently asked: Flutter Interview Questions and Answers

Vigo Webs
5 min readApr 24, 2022

Q1. List some advantages of Flutter?

Some advantages of using Flutter are
1. With Flutter, you can use the same UI and Business logic on all platforms.
2. Flutter reduces the time of building applications as it applies the changes instantly with the “hot reload” feature.
3. Flutter gives you similar to native app performance.
4. With Flutter, you can build applications not only for mobile platforms but also for desktop applications.
5. Flutter gives you the ability to fully customize the UI on all platforms.

Q2. What are the Flutter widgets?

A Flutter app is always considered as a tree of widgets. Whenever you are going to code for building anything in Flutter, it will be inside a widget. Widgets describe how your app view should look with their current configuration and state. When you made any alteration in the code, the widget rebuilt its description by calculating the difference of previous and current widgets to determine the minimal changes for rendering in the app’s UI. Widgets are nested with each other to build the app. It means your app’s root is itself a widget, and all the way down is a widget also. For example, a widget can display something, can define design, can handle interaction, etc.

Q3. What is the difference between Stateful widget and Stateless widget?

Stateless widgets cannot change their state during the runtime of the app, which means the widgets cannot be redrawn while the app is in action.
Stateful Widgets are the ones that change their properties during run-time. They are dynamic i.e. they are mutable and can be drawn multiple times within their lifetime.

Q4. What is the use of pubspec.yaml file in Flutter?

The pubspec.yaml the file allows you to define the packages your app relies on, declare your assets like font, images, audio, video, etc. For Android developers, this is roughly similar to a build.gradle file.

Q5. What is hot reload in flutter?

Flutter’s hot reload feature helps you quickly and easily experiment, build UIs, add features, and fix bugs. Hot reload works by injecting updated source code files into the running Dart Virtual Machine (VM). After the VM updates classes with the new versions of fields and functions, the Flutter framework automatically rebuilds the widget tree, allowing you to quickly view the effects of your changes.

Q6. What’s the difference between hot reload and hot restart?

Hot reload maintains the app state while updating the UI almost instantaneously whereas Hot restart resets the app state to its initial conditions before updating the UI.

Q7. What is the difference between NetworkImage and Image.network in flutter?

NetworkImage the class creates an object the provides an image from the src URL passed to it. It is not a widget and does not output an image to the screen. Image.network creates a widget that displays an image on the screen. It is just a named constructor on the Image class (a stateful widget). It sets the image property using the NetworkImage. This image property is used finally to display the image.

Q8. What is the difference between Expanded and Flexible widgets?

Expanded is just a shorthand for Flexible Using expanded this way:

You may want to use Flexible over Expanded when you want a different fit, useful in some responsive layouts. The difference between FlexFit.tight and FlexFit.loose is that loose will allow its child to have a maximum size while tight forces that child to fill all the available space.

Q9. What is Fat Arrow Notation in Dart and when do you use it?

The fat arrow syntax is simply a short hand for returning an expression and is similar to (){ return expression; }. The fat arrow is for returning a single line, braces are for returning a code block. Only an expression—not a statement—can appear between the arrow (=>) and the semicolon (;). For example, you can’t put an if statement there, but you can use a conditional expression

Q10. What is the difference between WidgetsApp and MaterialApp?

WidgetsApp provides basic navigation. Together with the widgets library, it includes many of the foundational widgets that Flutter uses. MaterialApp and the corresponding material library is a layer built on top of WidgetsApp and the widgets library. It implements Material Design, which gives the app a unified look and feel on any platform or device. The material library has many additional widgets that come with it. You certainly aren’t required to use MaterialApp in your project. You can use CupertinoApp to make iOS users feel at home, or you can even build your own set of custom widgets to fit your brand.

Q11. What is the purpose of SafeArea in Flutter?

SafeArea is an important and useful widget in Flutter which makes UI dynamic and adaptive to a wide variety of devices. While designing the layout of widgets, we consider different types of devices and their pre-occupied constraints of the screen like status bar, notches, navigation bar, etc.

Q12. What is profile mode and when do you use it?

In profile mode, some debugging ability is maintained — enough to profile your app’s performance. Profile mode is used when you want to analyze performance. Profile mode is disabled on the emulator and simulator because their behavior is not representative of real performance. On mobile, profile mode is similar to release mode, with the following differences: — Some service extensions, such as the one that enables the performance overlay, are enabled. — Tracing is enabled, and tools supporting source-level debugging (such as DevTools) can connect to the process. Profile mode for a web app means that: — The build is not minified but tree shaking has been performed. — The app is compiled with the dart2js compiler. The command flutter run — profile compiles to profile mode.

Q13. What is tree shaking in Flutter?

Tree shaking is an optimization technique to remove the unused module in the bundle during the build process. It is a dead code elimination technique used to optimize the code.

Q14. What is the difference between debug mode, profile mode and release mode?

• Use debug mode during development, when you want to use hot reload.
• Use profile mode when you want to analyze performance.
• Use release mode when you are ready to release your app.

Q15. What are slivers? Give some examples.

A sliver is a portion of a scrollable area. You can use slivers to achieve custom scrolling effects. That means you can, for example, have a ListView and GridView scroll together. It’d be possible to do something similar with a basic scroll as well, but slivers are performing much better in such cases.

To read more Flutter Interview Questions and answer check out our Android App from play store:

https://play.google.com/store/apps/details?id=com.vigowebs.interviewquestions

Our app contains 1600+ Interview Questions and answers with clear code examples from trending technologies.

--

--