The magic of Flutter/Dart extension

The role of extension is as stated on the official website : "Methods can be extended for existing libraries". Here is a simple example to illustrate its role. Click here to enter the example source code: weather project source code
For example, weather conditions are divided into several states: "Sunny", "Rainy", "Cloudy", "Snowfall", and "Unknown". For this we define an enumeration class WeatherCondition:

enum WeatherCondition {
   
    
    
  clear,//晴天
  rainy,//阴雨天
  cloudy,//多云
  snowy,//降雪
  unknown,

Guess you like

Origin blog.csdn.net/chunqiuwei/article/details/131844197