Flutter (dart) theoretical knowledge. Accumulation

I built a high wall just to be locked with you and never give up. ——Prince

1. The difference between const and final

  • Final can be used to modify variables. Modified variables are assigned at runtime and can only be assigned once. Therefore, the contents of modified variables are also called constants. The vernacular is: assignment at runtime and can only be assigned once
  • const : It can be used to modify variables and modify constant constructors. Modified variables can only be assigned once . Modified variables will be immutable constants in the entire life cycle of the application, and will only be created once in memory , And each subsequent call will reuse the object created for the first time.

the difference:

  • The const modified variable is the value that has been determined at compile time. The keyword can be used to modify the variable or the constant constructor
  • final : The modified variable is determined at runtime and can only be used to modify the variable

2 The difference between extends, with and implements

Inheritance (extends):

  • It is the same as inheritance in java, but there is a difference.There is no private public method in flutter, so the subclass in flutter can access all the methods and variables of the parent class.

Minxins with:

  • Features of mixins: To implement mixin, create a subclass that inherits the Object class (cannot inherit from other classes), do not declare any construction method, do not call super, use multiple commas (separated) after extends and before implements

Interface (implements):

  • Without the implementation of interface, every class can be regarded as implements

If you have a difference that you don’t understand, or I haven’t written it yet, please leave a message in the comment area. After you see it, I’ll update it and I will @你哦

Guess you like

Origin blog.csdn.net/weixin_44819566/article/details/110956506