当前位置:网站首页>[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
边栏推荐
- JS learning notes - first acquaintance
- What is Amazon keyword index? The consequences of not indexing are serious
- 数据湖(十一):Iceberg表数据组织与查询
- HMS core machine learning service helps zaful users to shop conveniently
- 解决** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the defau
- Set the background picture in the idea (ultra detailed)
- Boot transaction usage
- Summary of multithreading and thread synchronization knowledge
- Wise target detection 23 - pytoch builds SSD target detection platform
- Add user-defined formula (time sharing t+0) to mobile app access as an example
猜你喜欢

Ant group's large-scale map computing system tugraph passed the national evaluation

图数据库|Nebula Graph v3.1.0 性能报告

如何实现十亿级离线 CSV 导入 Nebula Graph

Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network

Effectively use keywords to increase Amazon sales

mysql 计算经纬度范围内的数据

Vscade set multi line display of tab

Remove the underline in router link

Compress words (kmp/ string hash, double hash)

潘多拉 IOT 开发板学习(RT-Thread)—— 实验2 RGB LED 实验(学习笔记)
随机推荐
Write your own CPU Chapter 11 - learning notes
Application of visualization technology in Nebula graph
[fluent] dart language (DART language features | JIT instant compilation | AOT static compilation)
AWS云主机扩容
Introduction to database system Chapter 1 short answer questions - how was the final exam?
Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
Boot 中bean配置覆盖
Aiko ai Frontier promotion (7.2)
Maui学习之路(三)--Winui3深入探讨
华为云服务器安装mysqlb for mysqld.service failed because the control process exited with error code.See “sys
Memory alignment of structure
Best practices for building multi architecture images
Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics
Postgressql stream replication active / standby switchover primary database no read / write downtime scenario
源码look me
Pattern matching extraction of specific subgraphs in graphx graph Computing Practice
Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
dried food! Understand the structural vulnerability of graph convolution networks
2020.4.12 byte written test questions B DP D monotone stack
奥比中光 astra: Could not open “2bc5/[email protected]/6“: Failed to set USB interface