Posts

20. Flutter - Routing (Loading Different Page Widgets)

A route is a map that holds a key (which defines a dart file) and a value (which is a function that loads a widget in the dart file). Defining a route: routes: { "/" : (context) => {WIDGET()}, "/SECONDFILE: (context) = > {WIDGET()}, } // the first route must be empty because it means it is the first widget to display at the start. // requires a context parameter in a route function. Don't need to change. Can override the first route with a property: initialRoute: "/ROUTETOBESTART", Navigating between pages/widgets: Navigator.pushNamed(context, "/ROUTETOGOTO"); // Usage: place this function inside a onPressed function. // pushes a new page onto the current page. // if new page has a appBar, the appBar will automatically have a back button to go back to current page. // Like push and pop.

11. Dart - Maps

 Maps are like structs. Creating a map: Map amap = { "STRING":"HELLO", "string2":"WORLD", "age":25, }; Calling a property of a map: print(amap["STRING"]); // will print "HELLO"

19. Flutter - SafeArea Widget

SafeArea widget prevents widgets from being blocked by the top into bar of a phone (where it shows time and battery, etc) by moving widgets down. Wrap a widget in a SafeArea widget: SafeArea( child: Text('HELLO'), ),

18. Flutter - Widget Classes with Variables and Constructor

 Making a widget a stateless widget that has variables that can be initialized in app. 1. Create a stateless widget. // By stless // OR // Clicking on a widget function and extract it using 2. Create a variable that is "final" final Classname Variablename; // Classname should be the parameter that goes in the widget parenthesis. 3. Create a constructor for the widget class. Class({this.variablename}); 4. Make sure when initializing a widget, put parameter inside the widget parenthesis.

17. Flutter - Card Widgets

Cards are boxes that holds stuff in a fancy design of cards. Card Widget: Card(); Properties: Can use columns/rows/etc. Can use child. Can use margin.

10. Dart - Custom Classes and Importing Dart Files

 Create a custom class inside a separate Dart file: example.dart class Human {     String name = "bob";     int age = 30; }; Importing Dart files into another file: import 'example.dart'; Using Custom Class properties inside flutter: Human personone = Human(); Text('${personone.name}'),

9. Dart - Function Named Parameters

 Named parameters allows us to put parameters in any order as long as the function specified that it uses named parameters. Making a function use named parameters: function( {String name, String job} ){ } // put brackets around the parameters. Using named parameters: function(String: "food cooker", String: "bob")