First, create the environment IDEA
1, Dart plug-in installation
2. Select Dart SDK
3, create a new console project
The main in the bin directory, really live for a long time to see.
Second, the basic data type
1, the string type
a, adding
String str1="123_456"; String str2="_789"; String str3=str1+str2; print(str1+str2);
//123_456_789
b, taken
String str1="123_456"; String str2=str1.substring(0,3); print(str2);
//123
c, divided
List<String> v=str1.split('_');
d, dart no character type, such as
import 'dart:mirrors'; import 'package:dartstudy/dartstudy.dart' as dartstudy; getTypeName(dynamic obj) { return reflect(obj).type.reflectedType.toString(); } void main(List<String> arguments) { String str1="123_456"; var a=str1[0]; print(getTypeName(a)); var b='1'; print(getTypeName(b)); } //输出 都是String
2, numerical type
var v=23.0; print(getTypeName(v)); //double
var v=2; print(getTypeName(v)); //int
int range below
64-bit double precision
3, Mathematical Functions
import 'dart:mirrors'; import 'dart:math'; import 'package:dartstudy/dartstudy.dart' as dartstudy; getTypeName(dynamic obj) { return reflect(obj).type.reflectedType.toString(); } void main(List<String> arguments) { var v=23.5.round(); print(v); }
//24