Flutter Flashcards

1
Q
When we use "void" in functions like:
void main() {
     print('something');
}
A

Because we don’t expect the function to return any value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When we use ‘dynamic’ variables in flutter and how?

A

When the type can be changed in the future:
example:
dynamic name = ‘Amir’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How we define a function in dart? say a String function or int function?

A
String greeting() {
   return 'Hello';
}
int getAge() {
   return 30;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the comment sign in dart?

A

//some test//

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does => mean in functions? with example

A

instead of return in functions:

String greeting() => ‘Hello’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Add/remove to a list in dart

A

List names = [‘Amir’, ‘Hasan’];

names. add(‘somename’);
names. remove(‘Amir’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can we use a mixed data type in a list? Is it good to do so?

A

Yes, and No!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to define a list datatype?

A

List names = [‘Amir’, ‘Hasan’];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How we define classes in dart? and can it be inside the main function or not?

A

Class User {
String username = ‘Amir’;
int age = 30;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
How are we instantiating a class? example for:
class User {
...
}
A

User user_one = User();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How we define the constructor of a class named User to receive username and age?

A
void main() {
    User userone = User('Amir', 30);
    print(userone.username);

}

class User {

String username;
int age;

User(String username, int age){
this.username = username;
this.age = age;
}

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to define a class such as User_2 to inherit from User_1? and how we define a constructor in that class?

A
class User_2 extends User_1 {
  User_2(String username, int age): super(username, age);

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which widget is responsible for the base layout of the app?

A

Scaffold

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Is the ‘home’ property of the material app or a widget (class)?

A

property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

is appBar a property or a widget? what is its parents class?

A

both, Scaffold widget

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Why do we sometimes use child property?

A

Because we always have to have at least one property inside any widget