Fundametals

void main() {
    print("Hello world!");
}

String name = "Flutter";
print("Hello $name");

// most of the variables can be used with var
var year = 1977
var name = 'Voyager I'
var image = {
    'tags': ['saturn'],
    'url': '//path/to/saturn.jpg'
}
// dynamic is a special type that can hold anything, but disables safety checks. Mostly used for json parsing ahead of time.

// Null safety

String? name; // Nullable type

// final vs const
// final -> the value is set once during the runtime
// const -> the value is set during the compile-time, should know the value before the app runs.

flyByObjects.where((name) => name.contains('turn')).forEach(print);

class Spacecraft {
    String name;
    DateTime? launchDate;

    int? get launchYear = launchDate?.year; // getter

    Spacecraft(this.name, this.launchDate) {
    }

    Spacecraft.unlaunched(String name) : this(name, null);

    void describe() {
        print('Spacecraft');

        var launchDate = this.launchDate;

        if(launchDate != null) {
            int years = DateTime.now().difference(launchDate).inDays ~/ 365;
        }
    }

}

class Orbiter extends Spacecraft {
    double altitude;
    Orbiter(super.name, DateTime super.launchDate, this.altitude);
}