当前位置:网站首页>[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.14
III . 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
- 数仓中的维度表与事实表
- Locate: cannot execute stat() `/var/lib/mlocate/mlocate Db ': there is no such file or directory
- Flink real-time data warehouse (IX): incremental synchronization of data in MySQL
- SQLServer查询哪些索引利用率低
- Remove the underline in router link
- Lseek error
- Boot 连接 Impala数据库
- Group by的用法
- GraphX 图计算实践之模式匹配抽取特定子图
猜你喜欢
Idea jar package conflict troubleshooting
手机app通达信添加自定义公式(分时T+0)为例子讲解
请问怎么在oracle视图中使用stustr函数
如何實現十億級離線 CSV 導入 Nebula Graph
智联招聘的基于 Nebula Graph 的推荐实践分享
Storage, reading and writing of blood relationship data of Nepal Graph & Data Warehouse
Nebula Graph & 数仓血缘关系数据的存储与读写
Crawl the information of national colleges and universities in 1 minute and make it into a large screen for visualization!
IDEA中设置背景图片(超详细)
Armv8-a programming guide MMU (4)
随机推荐
Usage of group by
Pyinstaller's method of packaging pictures attached to exe
Moveit obstacle avoidance path planning demo
Song of cactus - throwing stones to ask the way (2)
2020.4.12 byte written test questions B DP D monotone stack
In memory of becoming the first dayu200 tripartite demo contributor
JS learning notes - process control
Boot 连接 Impala数据库
如何实现十亿级离线 CSV 导入 Nebula Graph
Locate: cannot execute stat() `/var/lib/mlocate/mlocate Db ': there is no such file or directory
Add user-defined formula (time sharing t+0) to mobile app access as an example
[5g NR] RRC connection release
After the win10 system is upgraded for a period of time, the memory occupation is too high
Leetcode -- number of palindromes
2022 the latest and most detailed will successfully set the background image in vscade and solve unsupported problems at the same time
Lseek error
Astra: could not open "2bc5/ [email protected] /6“: Failed to set USB interface
Pyobject to char* (string)
结构体的内存对齐
手机app通达信添加自定义公式(分时T+0)为例子讲解