Flutter Flashcards
When we use "void" in functions like: void main() { print('something'); }
Because we don’t expect the function to return any value
When we use ‘dynamic’ variables in flutter and how?
When the type can be changed in the future:
example:
dynamic name = ‘Amir’
How we define a function in dart? say a String function or int function?
String greeting() { return 'Hello'; }
int getAge() { return 30; }
What is the comment sign in dart?
//some test//
What does => mean in functions? with example
instead of return in functions:
String greeting() => ‘Hello’;
Add/remove to a list in dart
List names = [‘Amir’, ‘Hasan’];
names. add(‘somename’);
names. remove(‘Amir’);
Can we use a mixed data type in a list? Is it good to do so?
Yes, and No!
How to define a list datatype?
List names = [‘Amir’, ‘Hasan’];
How we define classes in dart? and can it be inside the main function or not?
Class User {
String username = ‘Amir’;
int age = 30;
}
How are we instantiating a class? example for: class User { ... }
User user_one = User();
How we define the constructor of a class named User to receive username and age?
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 to define a class such as User_2 to inherit from User_1? and how we define a constructor in that class?
class User_2 extends User_1 { User_2(String username, int age): super(username, age);
}
Which widget is responsible for the base layout of the app?
Scaffold
Is the ‘home’ property of the material app or a widget (class)?
property
is appBar a property or a widget? what is its parents class?
both, Scaffold widget