Dart/Flutter Flashcards

1
Q

What does stringList.trim() do?

A

It trims extra spaces from strings in the list.

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

How to parse strings to integers in Dart?

A

int.parse()

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

How to get input from the user in Dart?

A

stdin.readLineSync()

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

How to open multiple folders in VS Code?

A

Use File > Add Folder to Workspace.

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

How to create a new Flutter project?

A

flutter create <project_name></project_name>

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

What’s the purpose of flutter run?

A

It starts the development server for a Flutter app.

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

How to update Flutter and Dart together?

A

flutter upgrade

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

How to check the Dart version?

A

dart –version

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

What is a Flutter workspace?

A

A collection of folders and files for a Flutter project.

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

How to add a folder to the current workspace in VS Code?

A

Go to File > Add Folder to Workspace

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

How to save a workspace in Visual Studio Code?

A

Go to File > Save Workspace As.

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

What is the purpose of a workspace in VS Code?

A

to group and manage multiple folders.

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

How to update Flutter and Dart separately?

A

Use flutter upgrade for Flutter and manually update Dart SDK.

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

How to check if Flutter is installed correctly?

A

flutter doctor

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

What command starts a Flutter application?

A

flutter run

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

How to create a new Dart-only project?

A

dart create <project_name></project_name>

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

How can I access an existing database in my Flutter project’s assets?

A

Use rootBundle.load() to load the database from assets.

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

How do I open a database directly from my assets in Flutter?

A

await openDatabase(databasePath)

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

What does getApplicationDocumentsDirectory() return?

A

The directory where user-generated files are stored.

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

How can I join paths in Dart?

A

Use the join() function from path package.

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

How can I check if a file or database exists in Dart?

A

File.exists(path_to_file)

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

What is the purpose of getDatabasesPath()

A

It returns the path for storing databases on the device.

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

How can I define a global variable in Dart?

A

Declare it outside of any function.

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

How do I close a database in Flutter?

A

.close()

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

How do I get the documents directory in Flutter?

A

getApplicationDocumentsDirectory()

26
Q

What does await do in Dart?

A

It waits for a Future to complete.

27
Q

How to check if a directory exists in Dart?

A

Directory.exists()

28
Q

What is written in lower camelCase?

A

variable, function, and parameter names

29
Q

What is written in upper CamelCase?

A

Names of Classes

30
Q

How to signify that an entity is private to its library?

A

underscore: ‘_name’

31
Q

How to concatenate the elements of a list and put a space between them?

A

listName.join(‘ ‘)

32
Q

How to add a string ‘a’ to a list?

A

listName.add(‘a’)

33
Q

What does the Scaffold widget do?

A

It provides a basic app structure with an app bar.

34
Q

What is a callback?

A

It’s a function passed as an argument to another function and intended to be called by that function at a later time, when a certain event occurs.

35
Q

How is a toggle button represented in flutter code?

A

As a Switch widget

36
Q

What is a container?

A

A box that can contain other widgets.
Allows you to apply visual properties like padding and color.

37
Q

What is ‘Center()’?

A

A widget that centers its child within itself both horizontally and vertically.

38
Q

Structure of ternary operator?

A

condition ? expressionIfTrue : expressionIfFalse

39
Q

What is ValueNotifier used for in Flutter?

A

To notify listeners when a value changes.

40
Q

What is the purpose of ValueListenableBuilder?

A

A widget that rebuilds when a ValueNotifier changes.

41
Q

How do you add comments in Flutter code?

A

Use // for single-line comments, or /* … */ for multi-line comments.

42
Q

How to cherry-pick non-null values?

A

nonNullValue = firstValue ?? secondValue

42
Q

What are sets in dart?

A

Like lists, but can contain different types of variables.

43
Q

What is this:

zeugs {‘foo’, 3, ‘bar’}

A

A set.

44
Q

What does ‘LIMIT 1’ in SQL do?

A

It restricts the result set to just one row. Among all the rows that satisfy the conditions, only one row will be selected.

45
Q
A
46
Q

How to divide a sentence into words in dart?

A

Use the string.split method

47
Q

Syntax of .split method:

A

String.split(delimiter)

48
Q

What does the string.split method return?

A

A list of substrings.

49
Q

Which delimiter to use to divide a sentence into words?

A

” “

string.split(“ “)

50
Q

How to replace all occurrences of a specific substring of a string?

A

newString = string.replaceAll(substring, replacement)

51
Q

What is a getter in dart?

A

A getter is a special method that provides a way to access the values of an object’s properties.

52
Q

Syntax of defining a getter:

A

Type get propertyName {
// return the property value
}

53
Q

Meaning of syntax highlighting:

orange - yellow - bright green - white - light blue - dark blue - purple ?

A

Orange = string
yellow = function/method
bright green = class, module
white = Functions from modules (e.g., the “.sort” in “np.sort”)
light blue = variable
dark blue = “class”, “def”, “False”, “not”, “None”, (= “other reserved words”)
purple = command (while, for, if, try, ,return, …)

54
Q

What does this mean:
get preinstalledDatabase,

A

It means “this is a getter named preinstalledDatabase”.
(NOT “ get the preinstalledDatabase!)

55
Q

What is a DatabaseProvider?

A

DatabaseProvider is a class designed to manage interactions with a SQLite database using the sqflite package.

56
Q

what does “join” do in Dart?

A

In Dart, join is commonly used in the context of file or directory paths. It’s a function provided by the path package, a string-based path manipulation library.

The join function takes a number of arguments, which can be parts of a file or directory path, and combines them into a single path.
It also handles the insertion of the correct path separator.

57
Q

What is the rootBundle?

A

rootBundle basically refers to the assetsBundle: all data contained in assets folder.
Files placed in the assets directory of a Flutter project and specified in the pubspec.yaml file are included in the rootBundle when the app is built.

58
Q

what is the purpose of class models in the context of databases?

A

It provides methods to convert between objects and maps, which makes it easier to work with the sqflite package.

59
Q
A