Skip to content

Instantly share code, notes, and snippets.

@NiKoTron
Created June 15, 2021 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiKoTron/42175e0b90dee1e83e043810c23f5a4b to your computer and use it in GitHub Desktop.
Save NiKoTron/42175e0b90dee1e83e043810c23f5a4b to your computer and use it in GitHub Desktop.
apiresolv
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