Dart 单例模式
class Service { // 工厂模式 factory Service() =>_getInstance(); static Service get instance => _getInstance(); static Service _instance; Service._internal() { // 初始化 } static Service _getInstance() { if (_instance == null) { _instance = new Service._internal(); } return _instance; } }