In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to understand the Dart language in Flutter". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand the Dart language in Flutter".
The initial experience of Dart language
Dart can be debugged and compiled in the compiler (AndroidStudio), command line (if DartSDK is installed) and web page repl.it. As this content is relatively simple, we can debug and compile directly in the web page.
We define a function that outputs the current time and outputs the current time
/ / output current time
VoidnowTime () {
Intyear=DateTime.now () year
Intmonth=DateTime.now () month
Intday=DateTime.now () day
Inthour=DateTime.now () hour
Intminute=DateTime.now () minute
Intsecond=DateTime.now () second
Stringstr='HelloWorld,Thisis$year-$month-$day$hour:$minute:$second'
Print (str)
}
Like most other languages, Dart requires the main function as the entry point for execution. We then define the main function and put the function that outputs the current time into the main function.
Voidmain () {
NowTime ()
}
Click the "run" button and the command will output
HelloWorld,Thisis2019-8-1110 4514
Now that we can simply run Dart code, let's take a look at the basic variable types of Dart
Variables and types of Dart language
In Dart, all variables can be declared with var, and of course, you can specify a specific type to declare a variable. When you use var to declare variables, the representation type is left to compiler inference. Although Dart supports the use of var to declare variables, I recommend using specific types to declare variables so that editors and compilers can use these specific types to provide you with tips for code completion or compilation alerts.
Note: by default, the values of all uninitialized variables are null, so we only need to compare with null when we determine whether the variable is initialized.
Dart is a type-safe language, and all types are object types and inherit from the top-level type Object, so the values of all variables are tired instances (that is, objects), including numbers, Boolean values, functions, and null are also inherited from Object objects.
Dart has some basic types built in, such as num, bool, String, List, and Map.
Thank you for reading, the above is the content of "how to understand the Dart language in Flutter". After the study of this article, I believe you have a deeper understanding of how to understand the Dart language in Flutter, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.