当前位置:网站首页>[fluent] dart data type number type (DART file creation | num type | int type | double type | num related API)
[fluent] dart data type number type (DART file creation | num type | int type | double type | num related API)
2022-07-02 16:10:00 【Programmer community】
List of articles
- I . establish Dart file
- II . num / int / double Numeric type
- III . Number type correlation API
I . establish Dart file
establish Flutter application : This is created before Flutter application ;

establish Dart file : Right click on the lib -> New -> Dart File , Enter... In the pop-up dialog box Dart File name is enough ;


Use templates : Enter in file stful , choice New Stateful widge Templates , You can use this template ;


The completion code : The main codes are in Widget build(BuildContext context) { } Method implementation ;
import 'package:flutter/material.dart';class DartType_Number extends StatefulWidget {
@override _DartType_NumberState createState() => _DartType_NumberState();}class _DartType_NumberState extends State<DartType_Number> {
@override Widget build(BuildContext context) {
return Container(); }}II . num / int / double Numeric type
1 . num And int and double The relationship between :num It's the number type , It has two subclasses , int and double type ;
2 . num Type variable : It can be accepted that Integer variables , You can also accept floating-point variables ;
3 . num Examples of type usage :
/* num Numeric type Is the parent of numeric type num Two subclasses of : ① int , ② double num Type variables can be assigned Integer types , You can also assign values Floating point type */num num_1 = 1.0; // Accept floating point types num num_2 = 1; // Accept integer int int_1 = -1; //int Type can only accept integer types double double_1 = 3.14; //double Type can only accept floating-point types // Print the four values above print("num_1 : $num_1 num_2 : $num_2 int_1 : $int_1 double_1 : $double_1");4 . Execution results :
num_1 : 1.0 num_2 : 1 int_1 : -1 double_1 : 3.14III . Number type correlation API
1 . Find the absolute value : call num Of abs() Method , O the num The absolute value of the type ;
2 . Digital type conversion : call num Of toInt() , toDouble() , toString() And other methods can realize digital type conversion ;
3 . complete Dart Component code example :
import 'package:flutter/material.dart';class DartType_Number extends StatefulWidget {
@override _DartType_NumberState createState() => _DartType_NumberState();}class _DartType_NumberState extends State<DartType_Number> {
@override Widget build(BuildContext context) {
/* num Numeric type Is the parent of numeric type num Two subclasses of : ① int , ② double num Type variables can be assigned Integer types , You can also assign values Floating point type */ num num_1 = 1.0; // Accept floating point types num num_2 = 1; // Accept integer int int_1 = -1; //int Type can only accept integer types double double_1 = 3.14; //double Type can only accept floating-point types // Print the four values above print("num_1 : $num_1 num_2 : $num_2 int_1 : $int_1 double_1 : $double_1"); /* Number type common API 1 . Find the absolute value : call num Of abs() Method , O the num The absolute value of the type 2 . Digital type conversion : call num Of toInt() , toDouble() , toString() And other methods can realize digital type conversion */ print("$int_1 The absolute value : ${int_1.abs()}"); print("$int_1 To double : ${int_1.toDouble()}"); print("$double_1 To int : ${double_1.toInt()}"); return Container(child: Text(' Numeric type ')); }}4 . Execution results :
num_1 : 1.0 num_2 : 1 int_1 : -1 double_1 : 3.14-1 The absolute value : 1-1 To double : -1.03.14 To int : 3
边栏推荐
- Make p12 certificate [easy to understand]
- Introduction to Dynamic Planning II (5.647.62)
- 纪念成为首个 DAYU200 三方 demo 贡献者
- 奥比中光 astra: Could not open “2bc5/[email protected]/6“: Failed to set USB interface
- The outline dimension function application of small motherboard
- [fluent] dart language (DART language features | JIT instant compilation | AOT static compilation)
- JS learning notes - data types
- 数据湖(十一):Iceberg表数据组织与查询
- Vscode设置标签页多行显示
- QVariant与Json的各种纠葛——Qt
猜你喜欢

Maui学习之路(三)--Winui3深入探讨

Postgressql stream replication active / standby switchover primary database no read / write downtime scenario

愛可可AI前沿推介(7.2)

MySQL calculates the data within the longitude and latitude range

Aike AI frontier promotion (7.2)

智联招聘的基于 Nebula Graph 的推荐实践分享

《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量

可视化技术在 Nebula Graph 中的应用

End time processing method of wechat v3native payment settings

Comment réaliser un graphique Nebula d'importation CSV hors ligne de niveau milliard
随机推荐
Leetcode --- longest public prefix
Invalid bound statement (not found) solution summary
Xpt2046 four wire resistive touch screen
2020.4.12 byte written test questions B DP D monotone stack
Flink real-time data warehouse (7): Flink realizes the full pull module to extract data in MySQL
The outline dimension function application of small motherboard
Route service grid traffic through two-level gateway design
Vscode设置标签页多行显示
Best practices for building multi architecture images
Analysis of the difference between array and linked list
中科大脑知识图谱平台建设及业务实践
Usage of group by
/Bin/ld: cannot find -llz4
After the win10 system is upgraded for a period of time, the memory occupation is too high
Set the background picture in the idea (ultra detailed)
《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量
Another graduation season
又是一年毕业季
Practice of constructing ten billion relationship knowledge map based on Nebula graph
Write your own CPU Chapter 11 - learning notes