Introduction To Basic Of Flutter With Dart
Introduction About Basic Of Dart From The Perspective Of Flutter
What are some of the benefits of using Dart?
Dart is ahead-of-time (AOT) compiled to native code, making your Flutter app fast. In other words, there’s no intermediary to interpret one language to another, and there are no bridges. AOT compilation is used when compiling your app for release mode (such as to the
Apple App Store and Google Play). Dart also is just-in-time (JIT) compiled, making it fast to display your code changes such as via Flutter’s stateful hot reload feature. JIT compilation is used when debugging your app by running it in the simulator/emulator. Since Flutter uses Dart, all the sample user interface (UI) code in this book is written in Dart, removing the need to use separate languages (markup, visual designer) to create the UI. Flutter rendering runs at 60 frames per second (fps) and 120fps (for capable devices of 120Hz). The more fps, the smoother the app.
COMMENTING CODE:- There are three types of comments: single-line, multi line, and documentation comments. Single-line comments are commonly used to add a short description. Multi-line comments are best suited for long descriptions that span multiple lines. Documentation comments are used to fully document a piece of code logic, usually giving detailed explanations and sample code in the comments. Single-line comments begin with // , and the Dart compiler ignores everything to the end of the line. Multiline comments begin with /* and end with */ . The Dart compiler ignores everything between. Documentation comments begin with /// , and the Dart compiler ignores everything to the end of the line unless enclosed in brackets. Using brackets, you can refer to classes, methods, fields, top-level variables, functions, and parameters. In the following example, the generated documentation, becomes a link to the API documentation for the class. You can use the SDK’s documentation generation tool to parse Dart code and generate HTML documentation.
REFERENCING VARIABLES:- In the previous section , you learned that main() is the top-level entry to an app , and before you start writing code , it’s important to learn about Dart variables. Variables store references to a value. Some of the built-in variable types are numbers, strings, Booleans, lists, maps, and runes. You can use var to declare (you will learn declaring variables in the next section) a variable without specifying the type. Dart infers the type of variable automatically. Although there is nothing wrong with using var , as a personal preference, I usually stay away from using it unless I need to do so. Declaring the An uninitialized variable has a value of null . When declaring a variable without giving it an initial value, it’s called uninitialized. For example , a variable of type String is declared like String book- Title; and is uninitialized because the bookTitle value equals null (no value). However, if you declare it with an initial value of String bookTitle = ‘Beginning Flutter’ , the bookTitle value equals ‘Beginning Flutter’ . Use final or const when the variable is not intended to change the initial value. Use const for variables that need to be compile-time constants, meaning the value is known at compile time.