当前位置:网站首页>Dart basic notes
Dart basic notes
2022-06-30 09:02:00 【Silent Pinocchio】
Dart Basics
- dynamic The assignment type can be changed
- var If initialization determines the type , Cannot be changed halfway
- Static type is better than dynamic type High execution efficiency
- final The value cannot be modified , The runtime determines
- const Compile time determines
- final Variables can use const Variable assignment
- dart Can be taken as java Medium int and long Use , If dart More than the 4 Bytes will Translate it into int perhaps long , otherwise Translate it into shot perhaps int
- ??= Sentenced to empty
- … Cascade The operator , It can achieve something similar builder Design patterns
- ? Security operator
- Optional position parameters : There is no need to write a bunch of overloaded functions , You can also provide default values
Method
- Underline names represent externally invisible
- The class name is not visible outside the beginning of the underscore
- Name the construction method
- Parameter initialization list
class Test {
// Not visible from the outside
late int _x;
Test(int a, int b);
// Name the construction method
Test.a(int c) : this(c, 0);
// Parameter initialization list
Test.fromMap(Map map) :_x = map["x"],_y = map["y"];
}
- Use new There is no difference between creating an object and a normal object
Use const Create multiple objects , Parameters are the same , This object is a compiler constant object ( Constant constructor must be defined ) - Factory construction method
First, set the default constructor
Then call the named constructor to return the constructor instance
Factory methods must return instance objects
static Method needs to display the declaration return object , Or no return
class Manager {
// Factory construction method
factory Manager.get() {
return new Manager();
}
Manager();
}
- get and set Method
var x1 = new Xl();
x1.x = 1;
print(x1._x);
- operators overloading
class Xl {
late int _x;
int get x => _x;
set x(int x) => _x = x;
// operators overloading
Xl operator +(Xl other) {
var xl = new Xl();
xl._x = _x + other._x;
return xl;
}
}
- Each class can be viewed as an interface , It can be realized
- with Keywords can be mixed with other classes ( Although there is no official document stating that it is multi inheritance , I think it can be understood as multiple inheritance )
class A {
void a() {
}
}
class B {
void b() {
}
}
//C class Mixed up A Classes and B class
class C with A, B {
void c() {
}
}
class D = Object with A, B;
void main(){
//C You can directly call the mixed class to break the law
var c = new C();
c.a();
c.b();
c.c();
}
- Method if conflict The priority of the call : First call C ,C No, Call again B ,A,with Post mixed classes Look backwards
- super You can call the functions of the parent class
If there is a problem , Welcome to point out
边栏推荐
- Axure make menu bar effect
- 挖财开户安全吗?怎么有人说不靠谱。
- Codeworks 5 questions per day (1700 for each) - the third day
- Rew acoustic test (I): microphone calibration
- 关于Lombok的@Data注解
- Pytorch BERT
- Flink Exception -- No ExecutorFactory found to execute the application
- Does the oscilloscope probe affect the measurement of capacitive load?
- [data analysis and display]
- Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush
猜你喜欢

Redis design and Implementation (V) | sentinel sentry

基于Svelte3.x桌面端UI组件库Svelte UI

Redis design and Implementation (IV) | master-slave replication

Redis design and Implementation (VII) | publish & subscribe

Pytorch BERT

Explanation on the use of password profiteering cracking tool Hydra

Tidb 6.0: making Tso more efficient tidb Book rush

Rew acoustic test (VI): signal and measurement

Do you want the dialog box that pops up from the click?

Self made GIF dynamic graph -gifcam
随机推荐
Advanced technology management -- how managers design and build echelons
Icon resources
File upload component on success event, add custom parameters
Mmdet line by line code interpretation of positive and negative sample sampler
Flink Exception -- No ExecutorFactory found to execute the application
Rew acoustic test (III): generate test signal
基于Svelte3.x桌面端UI组件库Svelte UI
Detailed explanation of pytoch's scatter function
CUDA realizes L2 European distance
【付费推广】常见问题合集,推荐榜单FAQ
Esp32 things (x): other functions
C#访问MongoDB并执行CRUD操作
[untitled]
Esp32 (4): overview of the overall code architecture
mysql基础入门 day3 动力节点[老杜]课堂笔记
Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)
[untitled]
vite项目require语法兼容问题解决require is not defined
Flink SQL custom connector
Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which