The Flutter interview actually has two parts similar to the Android interview:

1.Dart

2.Flutter

After all, if the Flutter is written using Dart, you must know something about Dart.


Dart related interview questions

1. Dart’s “..” What does it mean?

Dart’s “..” Means “cascading operator” and is used for configuration purposes.

“..” And “.” The difference is calling “..” Return this, and “.” The value returned is the value returned by the method.

2. The scope of Dart

Dart does not have “public” or “private” keywords, which are public by default. Private variables start with underscore _.

3. Is Dart a single-threaded model? How does it work?

Dart is a single-threaded model, and here’s how it works:

Quote from The Website Flutter:

Dart runs as a message loop in a single thread with two task queues, a microTask queue and an Event queue.

After the entry function main() completes, the message loop mechanism is started. First, the tasks in the microtask queue will be executed one by one in the first-in, first-out order. When all the microtask queues are executed, the tasks in the event queue will be executed. After the execution of the event tasks, the microtasks will be executed.


More interview information

4. How parallel is Dart multitasking?

As I said, if Dart doesn’t have multiple threads, how do you multitask?

Dart provides a worker-ISOLATE that operates independently, similar to a new thread, but does not share memory.

So how do they interact?

Part of the detailed explanation of Concurrent Programming, Asynchrony, and Event-driven in the Flutter Introduction dart

In DART, an Isolate object is actually a reference to the execution environment of an Isolate. Generally, we use the current Isolate to control the interaction between other ISOLATES. When we want to create a new Isolate we can use the isolate. spawn method to get a new Isolate object and send SendPort messages to each other. The ISOLATE also has a corresponding ReceivePort for receiving messages for processing. However, it should be noted that each ISOLATE has a pair of ReceivePort and SendPort. Only ReceivePort in the same ISOLATE can receive and process messages sent by SendPort of the current class.

5. What about Future?

A Future, literally “Future,” is a tool for handling asynchrony.

As I just said:

Dart runs as a message loop in a single thread with two task queues, a microTask queue and an Event queue.

By default, a Future inserts an event into the event queue, executes it when there is time, and calls back to the future.then (v) method when it is finished.

It is also possible to insert a task into the “microtask queue” by using the Future.microtask method to improve the efficiency of its execution.

The priority of each Dart ISOLATE is Main > MicroTask > EventQueue

6. What about Stream?

Streams, like features, are used to handle asynchrony.

However, the difference between Stream and Feature is that Stream can receive multiple asynchronous results, while Feature has only one.

Stream can be created using stream. fromFuture or created and controlled using StreamController.

Another note: regular streams can only have one subscriber. If you want more subscriptions, use asBroadcastStream().

7. What about mixins?

On what is a mixin, quote from Zhang Feng Jietelie’s article:

First of all, mixin is a keyword that defines a class. Dart introduces the mixin keyword in order to support multiple inheritance. Dart introduces the mixin keyword in order to support multiple inheritance. Dart introduces the mixin keyword in order to support multiple inheritance. Dart introduces the mixin keyword in order to support multiple inheritance. Dart introduces the mixin keyword in order to support multiple inheritance

Interview questions about the Flutter

1. Life cycle of StatefulWidget

•initState() : The Widget initializes the current State. The Context cannot be obtained in the current method. To do so, try Future.delayed()•didChangeDependencies() : Called after initState() and when the State object dependencies change. • Deactivate () : This method is called when a State is temporarily removed from the view tree and when a page is switched, similar to onPause on Android. • Dispose () : called when the Widget is destroyed. •didUpdateWidget: Called when the state of the Widget changes.

To borrow an image from CoorChice’s article:

2. How does Flutter communicate with Android iOS?

Flutter interacts with the native via platformchannels, which are divided into three types:

BasicMessageChannel: Used to pass strings and semi-structured information. 2.MethodChannel: Used to pass method calls. Flutter actively calls Native methods and gets the corresponding return value. 3.EventChannel: Used for event Streams communication.

For details, see The Xianyu Technology: Understanding the Flutter Platform Channel[4].

3. What are Widgets, RenderObjects and Elements?

• Widgets are only used to store information needed for rendering. •RenderObject manages layout, drawing, and other operations. •Element is the entity in the giant tree of controls.

What are Widgets, RenderObjects, and Elements? [5]

4. What is state management and why do you need it?

First of all, state is actually a conceptual thing, distinguishing between global state and local state.

The local state, such as the input information in a control, and the global state, such as the userId requested from the background after logging in.

As the global state becomes more numerous and multiple pages share a state, we need to manage it.

Common state management methods are as follows:

, ScopedModel, BLoC, Redux/FishRedux Provider

5. What about BLoC pattern?

Here is a quote:

BLoC is a way to build applications using reactive programming, a completely asynchronous world of flows.

6. How can I centrally manage error pages?

We all know that if something goes wrong with the Flutter, it’s red.

You can use errorWidget. builder to define a Widget.

conclusion

This is all for now. Having written so much, I have gained a better understanding of the foundation of Flutter & Dart. I also welcome all the big guys to communicate with me.