Giá trị và Kiểu dữ liệu trong Dart
1. Kiểu số
// Integers
int age = 25;
int hexValue = 0xFF;
// Doubles
double pi = 3.14159;
double exponent = 1.5e3; // 1500.0
// num (cả int và double)
num value = 42;
value = 3.14; // OK2. Strings
String name = "Dart";
String multiLine = '''
Line 1
Line 2
''';
// String interpolation
var greeting = "Hello, $name!";
var calculation = "Sum: ${10 + 20}";3. Booleans
bool isValid = true;
bool isEmpty = false;4. Lists, Sets, Maps
var list = [1, 2, 3];
var set = {1, 2, 3};
var map = {'key': 'value'};5. Type Inference
var age = 25; // int
var height = 1.75; // double
var name = "Alice"; // String
var isStudent = true; // bool6. Dynamic
dynamic value = 42;
value = "String"; // OK
value = true; // OK📝 Tóm tắt
int,double,num- NumbersString- Textbool- BooleanList,Set,Map- Collectionsdynamic- Any type- Type inference với
var
Last updated on