This repository is a part of HacktoberFest-an event organised by DigitalOcean. You are requested to create your profile using the above link to be a part of it.
-
What is
Flutter
?Flutter is Google's UI toolkit for crafting beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
-
What are the
different types of widgets in Flutter
?Two types of widgets present in the Flutter are stateless and stateful.
The stateless widgets don’t store any values which will change in the future. The stateless widgets don’t store any state. Icon, text widgets are some examples of stateless widgets.
The stateful widgets have a state object to keep track of all the changes and updates happening in the UI. These widgets are immutable but the state object is used to keep track of the changes. Checkbox and image are some of the examples of stateful widgets.
-
Difference b/w
Stateful
widget andStateless
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 its properties during run-time. They are dynamic i.e., they are mutable and can be drawn multiple times within its lifetime.
-
What is the use of
pubspec.yaml
file inFlutter
?The pubspec. yaml file is the most important file in any Flutter project. It is the place where you provide all the required dependencies of your Flutter project.
-
What is Dart? Why Flutter uses Dart as Programming Language? Dart is an object-oriented, garbage-collected programming language that you use to develop Flutter apps. It is created by Google. Dart was chosen as the language of Flutter for the following reason:
i. Dart is AOT (Ahead Of Time) compiled to fast, predictable, native code, which allows almost all of Flutter to be written in Dart. This makes Flutter fast
ii. Dart can also be JIT (Just In Time) compiled for exceptionally fast development cycles and game-changing workflow (hotreload).
iii. Dart allows Flutter to avoid the need for a separate declarative layout language like XML, because Dart’s declarative, programmatic layout is easy to read and visualize. i.e we can do both UI and Buisness Logic using one language only which is "DART"
iv. Dart Team + Flutter Team As both Dart and Flutter is developed and maintained by Google, hence both Flutter Team and Dart Team work together to solve the problem.
-
What is the difference between
NetworkImage
andImage.network
in flutter?NetworkImage
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. -
What are mixins in dart?
Mixins are used for a unique kind of inheritance, they allow other classes to inherit it's baked in methods for use, without actually being a child of the parent Mixin class. In simple words, Mixins are our usual normal classes from which we can borrow methods, without extending the class.
-
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. -
What are the two types of
Streams
available inFlutter
?There are two types of Streams available in Flutter which are: ..* Single subscription streams ..* Broadcast streams
Single subscription streams
: It is a popular and commom type of stream. It consist of series of events that are parts of a large whole. The events here have to be delivered in a defined order without even missing a single event.Broadcast streams
: This stream is meant for the individual messages that can be handeled one at a time. Multiplelistener
can listen at a time and it also gives the user the chance to listen after the cancellation of the previous subscription. -
What is a
Flutter Inspector
?
Flutter Inspector
is a tool that helps in visualizing and exploring the widget trees. It also helps in understanding the present layout and rectify the layout issues.
-
Is CI/CD possible in
Flutter
?Yes, CI/CD is possible in
Flutter
. There is CI/CD tool dedicated toFlutter
the name isCODE MAGIC
. With the help ofCODE MAGIC
we can easily automate the process of CI/CD for flutter apps from single automation. -
What’s the difference between
hot reload
andhot 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.
-
What are Null-aware operators in
Flutter
?Dart offers some handy operators for dealing with values that might be null.
a.One is the ??= assignment operator, which assigns a value to a variable only if that variable is currently null
b.Another null-aware operator is ??, which returns the expression on its left unless that expression’s value is null, in which case it evaluates and returns the expression on its right -
What is use of
Navigation.push
andNavigation.pop
function?The
push
method is used to add a route to the stack of routes managed by the navigator. Thepop
method is used to remove the current route from the stack of routes managed by the navigator. -
What is an
App state
?State means that is not ephemeral, that you want to share across many parts of your app, and that you want to keep between user sessions, is what we call application state (sometimes also called shared state).
Examples of application state:
- User preferences
- Login info
- Notifications in a social networking app
- The shopping cart in an e-commerce app
- Read/unread state of articles in a news app
- What are the
different build modes
in Flutter?
-
The Flutter tooling supports three modes when compiling your app, and a headless mode for testing.
-
You choose a compilation mode depending on where you are in the development cycle.
-
The modes are:
- Debug
- Profile
- Release
- What is the difference between
main()
andrunApp()
functions in Flutter?
main ()
function came from Java-like languages so it'swhere all program started,
without it, you can't write any program on Flutter even without UI.runApp()
function should return Widget that would be attached to the screen as a root of the Widget Tree that will be rendered.
-
What is ScopedModel/BLoC Pattern?
ScopedModel
andBLoC (Business Logic Components)
are common Flutter app architecture patterns to help separate business logic from UI code and using fewer Stateful Widgets.-
Scoped Model
is a third-party package that is not included into Flutter framework. It's a set of utilities that allow you to easily pass a data Model from a parent Widget down to its descendants. In addition, it also rebuilds all of the children that use the model when the model is updated. This library was originally extracted from the Fuchsia codebase. -
BLoC
stands for Business Logic Components. It helps in managing state and make access to data from a central place in your project. The gist of BLoC is that everything in the app should be represented as stream of events: widgets submit events; other widgets will respond. BLoC sits in the middle, managing the conversation.
-
-
How to avoid widget remount while working with Bottom navigation tabs?
The effective way to avoid the no of widget rebuilds while working with multiple Widgets as interfaces of a app that uses Bottom Navigation Tabs as it's stratergy it to utilize IndexedStack that will increase the app performace by 2x and reduces the unnecessary widget rebuilds on tab changes.
-
How do you reduce widget rebuild?
You rebuild widgets when the state changes. This is normal and desirable, because it allows the user to see the state changes reflected in the UI. However, rebuilding parts of the UI that don't need to change is wasteful.
There are several things you can do to reduce unnecessary widget rebuilding.
- The first is to refactor a large widget tree into smaller individual widgets, each with its own
build
method. - Whenever possible, use the
const
constructor, because this will tell Flutter that it doesn't need to rebuild the widget. - Keep the subtree of a stateful widget as small as possible. If a stateful widget needs to have a widget subtree under it, create a custom widget for the stateful widget and give it a
child
parameter.
- Have a look at open issues. Pick an unassigned issue.
- You can also create new issues (If you add a question or want answer to a particular question ).
- Make sure you are assigned for the issue.
- Fork the repo!
- Clone the forked repository to local system.
- Create your feature branch:
git checkout -b my-question-answer
- Be sure to not include any compiled binaries in the patch.
- Commit your changes:
git commit -am 'Add some question/answer'
. Go through Commit Messages guidelines - Push to the branch:
git push origin my-question-answer
While sending a PR make sure you follow one issue per PR rule. - Submit a pull request 😄
Only project maintainers should merge a PR. Other members can add their reviews to a PR but the merging should be done by only a project maintainer.