Flutter with Dart

¡Supera tus tareas y exámenes ahora con Quizwiz!

Dartpad

A web-based playground that allows you to write some Dart code and run it in the browser.

Dart

Dart is a programming language developed by Google which can be used to build web and mobile applications. Dart is an object-oriented programming language developed by Google. Whilst technically not restricted, it's primarily used for creating frontend user interfaces for the web (with AngularDart or Flutter for Web) and mobile apps (Flutter). It's under active development, compiled to native machine code (when used for building mobile apps), inspired by modern features of other programming languages (mainly Java, JavaScript, C#) and strongly typed. As already mentioned, Dart is a compiled language. That means, that your code isn't executed like you write it, but instead, a compiler parses + transform it (to machine code).

//; double slashes

Double slashes at the beginning of a line means that it's a comment, not code.

object

Generally, everything in Dart is an object - even an integer. But objects can also be more complex, see below. Example: Person = Person() It's also important to keep in mind that EVERY value in Dart is an object. More on that can be found below (=> "What does "Object-oriented" mean?")

types

Not all programming languages are strongly typed - but Dart is. What does that mean though? Every value you use in your program (e.g. some user input you're saving) has a type - it could be "text" for example. In Dart (and in pretty much all other programming languages), that would not be called "text" though but "string". On the other hand, if you're working with the age of a user, you might be using a number without any decimal places - a so-called "integer" value. Numbers with decimal places are called "doubles" (or "float" - in other programming languages). These are some basic types - Dart has way more than these basic types though.

class

Objects are created with the help of "Classes" because every object needs a blueprint (=> the class) based on which you can then create ("instantiate") it. Classes act as blueprints that describe how an object should look like. You create ("instantiate") a class by executing it like a function.

parentheses ( )

This function is named main because the thing in front of the parentheses ( ) here is the function name. The parentheses themselves are always required for every function you define and they allow you to receive arguments that would be inputted to your function. This function doesn't take any arguments, nonetheless, it needs these parentheses to turn it into a function.

variables

Variables are data containers - they have names and store values of any type. In your programs, you typically need to store some values. Not necessarily in a database or in a file but in memory. You might need to store some intermediate result, the input of a user before you process it or some information about your Flutter widget (e.g. "Should it currently be displayed on the screen?"). You store such information (= values) in so-called variables. For example: var myAge = 30; is a variable that stores an integer (int) of value 30.

camel case naming convention

You can name functions anything you'd like, but you have to following a naming convention called camel case, where you have only one word, so no spaces or blanks in between words, that would be a syntax error. Camel case is also used in many other programming languages so you should memorize it and use it so that when other developers see your code, they have an easier time understanding it. The first word of the function is always lowercase. If you have multiple words, the second word should always start with a capital character.

String

a data type, stores text; a text value; String values are embedded in either single or double quotes. ALWAYS CAPITALIZED S. It's a "string of characters", hence the name.

integers

a data type; a number type; stores numbers without decimal places; Integer values represent non-fractional values, i.e., numeric values without a decimal point. For example, the value "10" is an integer. Integer literals are represented using the int keyword.

void

a data type; type of data which a function returns; this function returns nothing and therefore the return type is void, it's empty.

main

a special function name; it's the entry point of a Dart application. Dart automatically calls the main function for you when the app starts; in other words, this is the first function which Dart and Flutter will execute automatically when your app launches. So in this function, you need to put the code that kicks off the UI rendering work that brings something onto the screen.

Flutter

a tool and a programming framework for the Dart language

property

a variable inside of a class. You can have class-level variables (which you then can access from anywhere inside the class) - such variables are then called properties. Side note: Functions inside of a class are called "methods".

function

are a crucial concept in pretty much any programming language you're going to learn. Functions are code snippets in which you can execute multiple times and at anytime you want.

widget

are components, the building blocks of your user interface.

curly brackets, braces

code goes inside { } that should execute when its function gets called;

double or float

double; a data type, stores numbers with decimal places. Dart also supports fractional numeric values i.e. values with decimal points. The Double data type in Dart represents a 64-bit (double-precision) floating-point number. For example, the value "10.10". The keyword double is used to represent floating point literals. num refers to "number" - there are two types of numbers in Dart: Integers (numbers without a decimal place) and doubles (numbers with decimal places) example: int age = 30; double price = 9.99

semicolon ;

in Dart, for every expression you have in your code, for every code line, you have to add a semicolon at the end. Exceptions from the rule are the definition of functions where you don't add a semicolon after a curly bracket but you do add it for all of the code lines inside of your function.

Git

is a version control system that helps you control your source code. For example, you can easily go back to older states of your code or revert in case you mess up your code.

Flutter app

is an application where you, the developer, build a UI by adding widgets.

scoping

means that you can use the variables only inside of the block statement (= function body, the code between the { }) where you defined them. Functions can take arguments (the data between the ( )) which are basically variables, scoped to the function.

num

num refers to "number" - there are two types of numbers in Dart: Integers (numbers without a decimal place) and doubles (numbers with decimal places) example: int age = 30; double price = 9.99


Conjuntos de estudio relacionados

Post-Lecture Chapter 02 Desc Chem

View Set

Deck Safety - Principles of Stability Questions

View Set

Chapter 42: Nursing Care of the Child With an Alteration in Bowel Elimination/Gastrointestinal Disorder

View Set

Research Methods Refresher Notes

View Set