小编Mat*_*ard的帖子

有没有办法在 Dart 中实现内部类?

//access to a Constant if it was like another language 
ImageWeather.Desktop.cloud; 
 
//What i wanted ( not working because there is no inner class)
class ImageWeather {
      class Desktop {
         static const String cloud = 'assets/images/DesktopCloud.png';
         static const String noCloud = 'assets/images/DesktopNoCloud.png';
         static const String rain = 'assets/images/DesktopRain.png';
   }  
      class Phone{
         static const String cloud = 'assets/images/PhoneCloud.png';
         static const String noCloud = 'assets/images/PhoneNoCloud.png';
         static const String rain = 'assets/images/PhoneRain.png';
   }
}

//access to a String like an inner class with new …
Run Code Online (Sandbox Code Playgroud)

inner-classes dart flutter

7
推荐指数
1
解决办法
3615
查看次数

标签 统计

dart ×1

flutter ×1

inner-classes ×1