You are on page 1of 6

Flutter 

Que sont les widgets Flutter ?


Une application Flutter : considérée comme un arbre de widgets.

Le code sera dans une widget

Statefeul Widget :
 has state information
 referred to as dynamic: it can change the inner data during the widget cycle de vie.
 A widget that allows us to refresh the screen is called a Stateful widget
 does not have a build() 
 has createState() method
 expl : Checkbox, Radio, Slider, InkWell, Form, and TextField.

Stateless Widget :
 does not have any state information.
 remains static throughout its cycle de vie
 expl : Text, Row, Column, Container, etc.
 If the screen or widget contains static content, it should be a Stateless widget

pubspec.yaml
o Project's configuration file
o It allows you how your application works
o contains:

o Project general settings such as name, description, and version of the project.
o Project dependencies.
o Project assets (e.g., images, audio, etc.)

advantages of Flutter

o Cross-platform Development: write the code once, , and can run on different


platforms. It saves the time, effort, and money of the developers.
o Faster Development: The performance of the Flutter application is fast. Flutter
compiles the application by using the arm C/C++ library that makes it closer
to codage machine and gives the app a better native performance.
o LHot Reloading: It makes the app development process extremely fast. This
feature allows us to change or update the code are reflected as soon as the
alterations are made.
o Minimal code: Flutter app is developed by Dart programming language,
which uses JIT and AOT compilation to improve the overall start-up time,
functioning and accelerates the performance. JIT enhances the development
system and refreshes the UI without putting extra effort into building a new
one.
o UI Focused: It has an excellent user interface because it uses a design-centric
widget, high-development tools, advanced APIs, and many more features.
o Documentation: Flutter has very good documentation support. It is organized
and more informative. We can get everything that we want to be written in
one place.

9. App state.

t is possible to share app states across sections of your app and maintain user sessions in
the same way: expl: login info, Ecommerce shopping cart, social networking noftifications

keys in flutter.

identifiers for widgets, elements, and semantic nodes: GlobalKeys LocalKeys are the
subclasses of Key.

Within the widget tree, keys are responsible for preserving the state of modified
widgets.

For Row:  
mainAxisAlignment = Horizontal Axis  
crossAxisAlignment = Vertical Axis  

For Column:  
mainAxisAlignment = Vertical Axis  
crossAxisAlignment = Horizontal Axis  

19. Why does a flutter app usually take a long developing time?

The first time you build a Flutter application, it takes much longer than usual since
Flutter creates a device-specific IPA or APK file. Xcode and Gradle are used in this
process to build a file, which usually takes a lot of time.
28. Explain BuildContext.

BuildContexts are used to identify or locate widgets in widget trees. Each widget has
its own BuildContext, i.e., one BuildContext per widget. Basically, we're using it to find
references to other widgets and themes. In addition, you can utilize it to interact with
widget parents and access widget data.

What are the different build modes in Flutter?

These compilation modes can be chosen by depending on where we are in the


development cycle. The name of the modes are:

 Debug : is used while the app is still in development and when you need to identify
and remove existing and potential errors. Flutter’s hot reload feature allows you to do
this in real-time and without needing to restart the software every time you make a
change.
 Profile : is used post-development. Every developer worth their salt knows that
development does not end with app deployment. Therefore, in the profile mode, you
still require some debugging functionality. Use this mode to analyze the real-time
performance of your released app.
 Release : used when the development process is complete and you are ready to
deploy the app. To use the release mode, you need to disable debugging since it is
assumed that an app ready for deployment must already be bug-free. The release
mode optimizes compilation for fast execution.

expr1??expr2
This operator first checks the expression 1 and, if it is non-null, returns its value; otherwise, it
will evaluate and returns the value of expression 2.

condition?expr1:expr2
This operator first checks the condition, and if it is true, it will evaluate expr1 and returns its
value (if the condition is matched). Otherwise, it evaluates and returns the value of expr2.

32. What do you understand about tween animation?

The shortened version of in-between animation is tween animation. The start and
endpoints of an animation must be specified in tween animation. Using this method,
the animation can begin at the beginning and can progress through a series of values
until it reaches the endpoint.
Transition speed and duration are also determined by using the tween animation.
Calculating the transition from the beginning to the end will be easier with the widget
framework. 

34) How would you execute code only in debug mode?

To execute the code only in debug mode, we need to first import the dart foundation
as below:

1. import 'package:flutter/foundation.dart' as Foundation;   
2. Next, we need to use the kReleaseMode as below:
if (Foundation.kReleaseMode){ // is Release Mode ??  
    print('release mode');  
} else {  
    print('debug mode');  
}   

What is BuildContext?

BuildContext in Flutter is the part of the widgets in the Element tree so that each
widget has its own BuildContext. We mainly use it to get a reference to another
widget or theme.

39) What types of tests can you perform in Flutter?

Testing is an activity used to verify and validate the application, which is bug-free and
meets the user requirements. Generally, we can use these three types of tests in
Flutter:

 Unit Tests: It tests a single function, method, or class. Its goal is to ensure the
correctness of code under a variety of conditions. This testing is used for
checking the validity of our business logic.

 Widget Tests: It tests a single widget. Its goal is to ensure that the widget's UI
looks and interacts with other widgets as expected.

 Integration Tests: It validates a complete app or a large part of the app. Its
goal is to ensure that all the widgets and services work together as expected.
Flutter also provides one additional testing known as a golden test. Its goal is to
ensure that you have an image of a widget or screen and check to see whether the
actual widget matches it or not.

40) What are Null-aware operators?

Dart provides some useful information to handle the null values.

1. The "??=" assignment operator that assigns a value to a variable only when that
variable is null.

int a; // Initial value of a is null.  
a ??= 5;  
print(a); // It will print 5.  

2. The "??" null-aware operator 

print(3 ?? 5); // It will print 3.  
print(null ?? 5); // It will print 5.  

24. What do you mean by Streams?

In asynchronous programming, streams are used to provide a sequence of data in an


asynchronous manner. Similar to a pipe, we put a value on one end and a listener
receives it on the other. Several listeners can be put into one stream, and they'll all
get the same value when they're put in the pipeline. It's possible to create and
manage streams through the SteamController. 

The Stream API provides the await for and listen() methods for processing streams.
Streams can be created in many ways, but they can only be used in the same manner.
Here is an example: 

Future<int> sumStream(Stream<int> stream) async {


var sum = 0;
await for (var value in stream) {
sum += value;
}
return sum;
}

 Single Subscription Streams: These streams deliver events sequentially. They are
considered as sequences contained within a larger whole. These streams are used when the
order in which events are received matters, such as reading a file. There can be only one
listener throughout the sequence, and without a listener, the event won't be triggered. 
 Broadcast Streams: These streams deliver events to their subscribers. Upon
subscribing to events, subscribers are immediately able to start listening to them.  These are
versatile streams that allow several listeners to listen simultaneously. Furthermore, one can
listen again even after canceling a previous subscription.

Write difference between Hot reload and Hot restart.

For any dart application, the initial execution requires a fair amount of time.
Therefore, to solve this problem, flutter has two features: Hot Reload and Hot Restart,
which reduce the execution time of our app after we run it. 

 Hot Reload: It is considered an excellent feature of flutter that takes approximately


one second to perform its functionality.  With this function, you can make changes, fix bugs,
create UIs, and add features easily and quickly. By utilizing the hot reload feature, we can
quickly compile the new code in a file and send it to Dart Virtual Machine (DVM). As soon as
DVM completes the update, it updates the app's UI. The preserved state is not destroyed in
hot reload.
 Hot Restart: It has a slightly different functionality as compared to a hot reload. In
this, the preserved states of our app are destroyed, and the code gets compiled again from
the beginning. Although it takes longer than a hot reload, it's faster than a full restart
function.

19) Name the popular database package used in the Flutter?


The most used and popular database packages used in the Flutter are as follows:

o sqflite database: It allows to access and manipulate SQLite database.


o Firebase database: It will enable you to access and manipulate the cloud database.

You might also like