Created
June 15, 2021 06:47
-
-
Save NiKoTron/42175e0b90dee1e83e043810c23f5a4b to your computer and use it in GitHub Desktop.
apiresolv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print(ApiResolver.v1?.foo); | |
print(ApiResolver.v1?.bar); | |
print(ApiResolver.v1?.baz); | |
print(ApiResolver.v2?.foo); | |
print(ApiResolver.v2?.bar); | |
print(ApiResolver.v2?.baz); | |
} | |
abstract class ApiVer{ | |
final String ver; | |
const ApiVer(this.ver); | |
String get foo => '$ver/foo'; | |
String get bar => '$ver/bar'; | |
String get baz => '$ver/baz'; | |
} | |
class AV1 extends ApiVer{ | |
const AV1() : super('v1'); | |
} | |
class AV2 extends ApiVer{ | |
const AV2() : super('v2'); | |
} | |
class ApiResolver { | |
static const _apis = <String, ApiVer>{'v1' : AV1(),'v2' : AV2(),}; | |
static ApiVer? get v1 => _apis['v1']; | |
static ApiVer? get v2 => _apis['v2']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment