Skip to content

Commit 6d434f3

Browse files
author
coderZoe
committed
'buit_in_types'
1 parent b81dd59 commit 6d434f3

File tree

7 files changed

+68
-1
lines changed

7 files changed

+68
-1
lines changed
File renamed without changes.

1_basic/libraries.dart

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'dart:html';
2+
3+
void main() {
4+
var request = HttpRequest();
5+
request.setRequestHeader("content-type", "application/json");
6+
}
File renamed without changes.
File renamed without changes.

basic/variables.dart renamed to 1_basic/variables.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '../start/main.dart';
1+
import '../0_start/main.dart';
22

33
void main() {
44
var person1 = Person("Tom", 12);

2_types/builtInType.dart

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
void main() {
2+
int a = -10;
3+
a = a.abs();
4+
print(a);
5+
6+
double b = 123.5;
7+
var c = b.floor();
8+
print(c);
9+
//num类型是int和double的合集类型
10+
num d = 123.4;
11+
d = d.floor();
12+
print(d);
13+
14+
//字符串转数字
15+
int number1 = int.parse('1');
16+
assert(number1 == 1);
17+
double number2 = double.parse("1.1");
18+
assert(number2 == 1.1);
19+
20+
var number3 = num.parse('1.234');
21+
assert(number3 == 1.234);
22+
23+
//数字转字符串
24+
int number4 = 10;
25+
var str1 = number4.toString();
26+
assert(str1 == '10');
27+
28+
double pi = 3.1415926;
29+
var str2 = pi.toStringAsFixed(2);
30+
assert(str2 == '3.14');
31+
32+
var name = "小明";
33+
Map xiaoming = {
34+
'name': '小明',
35+
'age': 12,
36+
'hobbies': ['play', 'eat', 'sleep']
37+
};
38+
String str3 = 'Hello$name your age is ${xiaoming['age']}';
39+
print(str3);
40+
41+
//字符串拼接
42+
var str4 = str3 + str2;
43+
44+
//多行字符串
45+
var str5 = '''
46+
name: my_project
47+
description: A new Dart project.
48+
version: 1.0.0
49+
50+
environment:
51+
sdk: '>=2.10.0 <3.0.0'
52+
53+
dependencies:
54+
http: ^0.13.3
55+
''';
56+
print(str5);
57+
58+
//原始字符串 不转义 使用r开头 加一段字符串
59+
var str6 = r'In a raw string, not even \n gets special treatment.';
60+
print(str6);
61+
}

basic/libraries.dart

Whitespace-only changes.

0 commit comments

Comments
 (0)