This file contains hidden or 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
class ServiceManager { | |
final _instances = <Type, Object>{}; | |
void register<T extends Object>(T instance) { | |
_instances[T] = instance; | |
} | |
bool isRegistered<T extends Object>() { | |
return isRegisteredByType(T); | |
} |
This file contains hidden or 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
enum ABC { a, b, c } | |
void main() { | |
switch (ABC.a) { | |
case ABC.a: | |
print('a'); | |
case != ABC.a: | |
print('b or c'); | |
} | |
} |
This file contains hidden or 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
import 'dart:async'; | |
void main() async { | |
// A function marked async will implicitly return a Future. | |
future(sync: true).then(print); | |
future(sync: false).then(print); | |
print('main (sync)'); | |
// clear pending futures | |
await Future<void>.delayed(Duration.zero); |
This file contains hidden or 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
sealed class AuthState {} | |
abstract class AuthUserSignedIn extends AuthState { | |
AuthUser get user; | |
} | |
abstract class AuthUserSignedOut extends AuthState { | |
AuthUser get user; | |
} |
This file contains hidden or 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
enum MfaType { sms, totp } | |
T _useCurrent<T>(T value) => value; | |
Future<void> setMfaPreferences({ | |
Set<MfaType> Function(Set<MfaType>) enabled = _useCurrent, | |
MfaType? Function(MfaType?) preferred = _useCurrent, | |
}) async { | |
// TODO | |
} |
This file contains hidden or 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() { | |
switch ('hello') { | |
case 'hello': | |
print("Hello!"); | |
continue s; | |
s: case String _: | |
print("It's a string!"); | |
} | |
} |
This file contains hidden or 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
class Serializable { | |
String toJson() => 'json'; | |
} | |
void main() { | |
switch (Serializable() as dynamic) { | |
case dynamic(:final Object? Function() toJson): | |
print(toJson()); | |
case _: | |
throw ArgumentError('Not serializable'); |
This file contains hidden or 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
class Serializable { | |
String toJson() => 'json'; | |
} | |
void main() { | |
switch (Serializable() as dynamic) { | |
case dynamic(:final Object? Function() toJson): | |
print(toJson()); | |
case _: | |
throw ArgumentError('Not serializable'); |
This file contains hidden or 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
abstract class PluginOptions {} | |
abstract class Plugin<Options extends PluginOptions> { | |
Options get options; | |
} | |
class MyPluginOptions extends PluginOptions {} | |
class MyPlugin extends Plugin<MyPluginOptions> { | |
static const pluginKey = PluginKey<MyPluginOptions, MyPlugin>(); |
This file contains hidden or 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
import { PreSignUpTriggerHandler } from "aws-lambda"; | |
import { CognitoIdentityProvider } from "@aws-sdk/client-cognito-identity-provider"; | |
const CLIENT = new CognitoIdentityProvider({}); | |
export const handler: PreSignUpTriggerHandler = async (event) => { | |
console.log(`Got event: ${JSON.stringify(event, null, 2)}`); | |
const { | |
triggerSource, |
NewerOlder