当前位置: 首页 > news >正文

谷歌 网站做推广张家界网站seo

谷歌 网站做推广,张家界网站seo,商务网站建设体会,一重大连工程建设有限公司官方网站1 数据类型 数字(number) int double 字符串转换成 num int.parse(“1”) double.parse(“1”);double 四舍五入保留两位小数 toStringAsFixed(2) 返回值为stringdouble 直接舍弃小数点后几位的数据 可使用字符串截取的方式 字符串(string) 单引号 双引号 三引号三引号 可以输…

1 数据类型

  • 数字(number) int double

    • 字符串转换成 num int.parse(“1”) double.parse(“1”);
    • double 四舍五入保留两位小数 toStringAsFixed(2) 返回值为string
    • double 直接舍弃小数点后几位的数据 可使用字符串截取的方式
  • 字符串(string)

    • 单引号 双引号 三引号
    • 三引号 可以输出文本格式 比如换行
  • 布尔值(boolean)

  • 列表(list)

    • 一旦定义了 内容的类型 就不可变
    • list内容是常量 添加const
      在这里插入图片描述
  • 集合(set)

在这里插入图片描述

  • 映射(map)
  • 符文(rune)
  • 符号(Symbol)
- 数字(number)  int double-  字符串转换成 num   int.parse("1") double.parse("1");-  double 四舍五入保留两位小数 toStringAsFixed(2) 返回值为string-  double 直接舍弃小数点后几位的数据  可使用字符串截取的方式
//字符串转换成 num  var a = int.parse("1");var b = double.parse("1");print(a);print(b);
//结果
//1
//1.0- 字符串(string)- 单引号 双引号   三引号- 三引号 可以输出文本格式 比如换行 
var a = "aaa""bbb";print(a);a = 'aaa''bbb';print(a);a = '''aaa bbb''';print(a);  
结果
aaabbb
aaabbb
aaa bbb- 列表(list)- 一旦定义了 内容的类型 就不可变-  - list内容是常量  添加const
void main(){var list = [1,2,3];// list = ["1","2","3"]; // Error: A value of type 'String' can't be assigned to a variable of type 'int'.var cars = [ Car("TSLT"),Car("XRB")];print(cars);print(cars[0].name);print(cars[0].drive());var names = const ["TSLT","XRBS"];  //内容不可改变print(names);names[1] = "TSLC"; // Cannot modify an unmodifiable listprint(names);
}
class Car{var name;Car(this.name);bool drive(){print("${name}我着了...");return true;}
}结果[Instance of 'Car', Instance of 'Car']
TSLT
TSLT我着了...
true
[TSLT, XRBS]void main(){var a = {1,"2",3.4,Car(5),true};print(a);a.add("aaa");print(a);var b = Set();b.add(1);b.add("2");b.add(3.4);b.add(Car(5));b.add(true);print(b);// var c = const {1,"2",3.4,Car(5),true}; //  Error:  The element '3.4' does not have a primitive equality.var c = const {1,"你好",true}; //  Error:  The element '3.4' does not have a primitive equality.print(c);
}
结果
{1, 2, 3.4, Instance of 'Car', true}
{1, 2, 3.4, Instance of 'Car', true, aaa}
{1, 2, 3.4, Instance of 'Car', true}
{1, 你好, true}

2 var 关键字

  • var 关键字一旦赋值类型即确定
void main(){var a = 1;var b = "hello";var c = Car();c.drive();print(a.runtimeType);print(b.runtimeType);print(c.runtimeType);
} class Car{void drive(){print("我跑了");}
}

结果

我跑了
int
String
Car

3 dynamic 和 Object

  • Object是Dart所有对象的父类
  • Object和dynamic声明变量 可改变类型
  • dynamic 可使用对象类型的属性和方法 Object声明的对象只能用Object的属性和方法
void main(){Object a;a = "hello";print("a 的类型是 ${a.runtimeType}");a = 1;print("a 的变化后类型是 ${a.runtimeType}");dynamic b;b = 1;print("b 的类型是 ${b.runtimeType}");b = 1.1;print("b 的变化后类型是 ${b.runtimeType}");a = "hello";b = "world";print(b.length);// print(a.length); //报错 The getter 'length' isn't defined for the class 'Object'.
}

结果

a 的类型是 String
a 的变化后类型是 int
b 的类型是 int
b 的变化后类型是 double
5

4 final 和 const

  • const 编译时赋值
  • final 运行时 第一次使用时 赋值
void main(){final a;a = 1;print(a);// const b; // 报错 Error: The const variable 'b' must be initializedconst b = 2;print(b);
}

结果

1
2

5 空安全

void main(){Car? car;print(car?.drive());car = Car();print(car?.drive());
}
class Car{bool drive(){print("我着了...");return true;}
}

运行结果

lib/demo.dart:8:9: Warning: Operand of null-aware operation '?.' has type 'Car' which excludes null.- 'Car' is from 'package:demo/demo.dart' ('lib/demo.dart').print(car?.drive());^
null
我着了...
true

函数 (方法)

  • 不声明返回值的 默认是dynamic
run(){print("我跑了");
}eat(){return "吃撑了";
}void main(){print(run());print(eat());
}

结果

我跑了
null
吃撑了
  • 函数可以作为变量
var run = (){print("我跑了");
};var eat = (){return "吃撑了";
};void main(){print(run());print(eat());
}

结果

我跑了
null
吃撑了
  • 函数可以作为参数
run(String name){print("${name}跑了");
}eat(String name){return "${name}吃撑了";
}see(var seeWho){seeWho("老六");
}void main(){var car  = Car("安妮");car.who(run);see((var name)=>print(name));
}
class Car{var name;Car(this.name);who(var run){run(name);}
}运行结果:
安妮跑了
老六
  • 可变函数
eat(String name,{String? food,int? num}){return "${name}吃${food}撑了${num}份";
}speak(String name,[String? and,String? chat]){return "${name}吃${and}${chat}";
}void main(){print(eat("张三"));print(eat("张三",food: "麻辣烫",num: 10));print(speak("张三"));print(speak("张三","李四"));print(speak("张三","李四","聊天"));
}运行结果:
张三吃null撑了null份
张三吃麻辣烫撑了10份
张三吃nullnull
张三吃李四null
张三吃李四聊天
  • 扩展函数
    • 常用类型转换 / 时间处理 / 或者Widget的扩展(例如padding)
    • 多个扩展函数若已定义 不可重复定义 即函数名不可重复
    • dynamic 不可使用扩展函数
/*** 扩展函数* 格式:* extension 函数名 on 类**/
extension toNum on String{int toInt(){return int.parse(this);}double toDouble(){return double.parse(this);}
}void main(){var a = "12".toInt();print(a);print(a.runtimeType);dynamic b = "12";
}结果:
12
int

在这里插入图片描述

    • 默认构造函数
    • 命名构造函数 Student2.fromJson()

import 'dart:convert';void main(){var student = Student("张三", "三年二班", 18, "2005-12-12 12:12:12");print("student>>${student}");var student1 = Student1("张三", "三年二班", 18, "2005-12-12 12:12:12");print("student1>>${student1}");var student11 = Student1.name("李四");  //命名构造函数print("student11>>${student11}");String jsonString = '{"name": "John","classGrade": "三年二班","birthday": "2005-12-12 12:12:12", "age": 30}';var student2 = Student2.fromJson(jsonString);print(student2.toString());
}class Student{//不添加构造函数  这些属性 会报错  或者可以加上?String name,classGrade;int age;String birthday;Student(this.name, this.classGrade, this.age, this.birthday);Map<String,dynamic> toJson(){return {'name':name,'classGrade':classGrade,'age':age,'birthday':birthday};}@overrideString toString() {return 'Student{name: $name, classGrade: $classGrade, age: $age, birthday: $birthday}';}
}class Student1{//不添加构造函数  这些属性 会报错  或者可以加上?String? name,classGrade;int? age;String? birthday;Student1(this.name, this.classGrade, this.age, this.birthday);Student1.name(this.name);@overrideString toString() {return 'Student1{name: $name, classGrade: $classGrade, age: $age, birthday: $birthday}';}
}class Student2{String name = "",classGrade = "";int age = 0;String birthday = "";//命名构造函数Student2.fromJson(String jsonStr){var json = jsonDecode(jsonStr);print(jsonStr);this.name = json['name'];this.classGrade = json['classGrade'];this.age = json['age'];this.birthday = json['birthday'];}@overrideString toString() {return 'Student2{name: $name, classGrade: $classGrade, age: $age, birthday: $birthday}';}
}运行结果:
student>>Student{name: 张三, classGrade: 三年二班, age: 18, birthday: 2005-12-12 12:12:12}
student1>>Student1{name: 张三, classGrade: 三年二班, age: 18, birthday: 2005-12-12 12:12:12}
student11>>Student1{name: 李四, classGrade: null, age: null, birthday: null}
{"name": "John","classGrade": "三年二班","birthday": "2005-12-12 12:12:12", "age": 30}
Student2{name: John, classGrade: 三年二班, age: 30, birthday: 2005-12-12 12:12:12}

在这里插入图片描述
在这里插入图片描述

  • 常量构造函数
    • 常量构造函数 const修饰构造函数
    • 常量构造函数用const 修饰时 属性值一样 则对象相等
import 'dart:convert';class Student{String name;int age;Student(this.name, this.age);
}class Student1{final String name;final int age;const Student1(this.name, this.age);
}void main(){var student = Student("张三",18);var student0 = Student("张三",18);print(student.hashCode);print(student0.hashCode);print(student == student0);print("\n");var student1 = const Student1("张三",18);var student11 = const Student1("张三",18);var student12 = const Student1("张三",19);print(student1.hashCode);print(student11.hashCode);print(student12.hashCode);print(student1 == student11);  //trueprint(student12 == student11); //false}结果:
333142976
1033297191
false87118132
87118132
590927718
true
false
  • 工厂构造函数

import 'dart:convert';class Student{String? name;int? age;Student.init({String name ="",int age = 0}){this.name = name;this.age = age;}static Student instance = Student.init();factory Student(){return instance;}}void main(){var student = Student.instance;var student1 = Student.instance;print(student.hashCode);print(student1.hashCode);
}结果:
11925193
11925193
    • 默认属性方法修饰符是public
    • _下划线表示私有
    • 单继承 多实现
      在这里插入图片描述
class A{void printA(){print("A");}
}class B{void printA(){print("B");}
}abstract class M{void printM(){print("M");}
}abstract class N{void printN(){print("N");}
}interface class X{void printX(){print("X");}
}interface class Y{void printY(){print("Y");}
}
//单继承 多实现
class C extends A implements M,N,X,Y{@overridevoid printM() {// TODO: implement printM}@overridevoid printN() {// TODO: implement printN}@overridevoid printX() {// TODO: implement printX}@overridevoid printY() {// TODO: implement printY}}
  • 类的混入
mixin class P{void printP(){print("P");}
}mixin class Q{void printQ(){print("Q");}
}class D with P,Q{void printD(){print("D");}
}void main(){var d = D();d.printD();d.printP();d.printQ();
}结果:
D
P
Q

文章转载自:
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://.
http://www.tj-hxxt.cn/news/36906.html

相关文章:

  • 网站建设 怎样找客户百度网站排名优化
  • 网站设置密码进入发稿软文公司
  • 设计网站中如何设置特效百度推广免费
  • 北京网站建设方案书sem是什么显微镜
  • 网站建设企业咨询市场营销策划书范文5篇精选
  • 怎么做网站banner网络优化报告
  • 电影网站建设之苹果cms桂平seo关键词优化
  • 15年做那个网站致富太原首页推广
  • 深圳网站设计与开发西安seo托管
  • 西安网站制作多少钱网络营销名词解释答案
  • wordpress相同的cmsseo课程总结怎么写
  • 去年做那个网站致富流量平台排名
  • 官方在家做兼职的网站百度商城官网
  • 什么是微网站seo资源网站排名
  • 自己可以做类似拓者的网站吗企业网络推广平台
  • 网站建设好后为什么要维护电商平台排名
  • 网站宽屏图片怎么做手机如何制作网页链接
  • wordpress foxpayseo的方式包括
  • 做商城网站如何寻找货源关键词seo公司真实推荐
  • 网站客服漂浮广告代码新闻小学生摘抄
  • 信得过的网站开发推广免费推广引流软件
  • 合肥在线官网我赢seo
  • 做一回最好的网站网站建站方式有哪些
  • 免费生成ppt的网站微信怎么推广找客源
  • 软件开发技术培训课程成都自然排名优化
  • 公司网站维护怎么做互联网营销软件
  • 响应式自助建站平台谷歌seo网站建设
  • 淄博做网站电话微信附近人推广引流
  • 建站源码下载徐州网页关键词优化
  • 程序员除了做软件是不是就做网站衡阳网站优化公司