Skip to content

Instantly share code, notes, and snippets.

@PlugFox
Created January 30, 2026 14:35
Show Gist options
  • Select an option

  • Save PlugFox/5593eafa163371223c7c2068266cc1b7 to your computer and use it in GitHub Desktop.

Select an option

Save PlugFox/5593eafa163371223c7c2068266cc1b7 to your computer and use it in GitHub Desktop.
Dart extension type
/*
* Extension type
* https://gist.github.com/PlugFox/5593eafa163371223c7c2068266cc1b7
* https://dartpad.dev?id=5593eafa163371223c7c2068266cc1b7
* Mike Matiunin <plugfox@gmail.com>, 30 January 2026
*/
import 'dart:convert';
void main() {
print(const SignInMeta.empty());
print(jsonEncode(SignInMeta(uiFlowSource: 'source')));
}
extension type const SignInMeta._(Map<String, Object?> _map)
implements Map<String, Object?> {
const SignInMeta.empty() : _map = const {};
factory SignInMeta({
String? uiFlowSource,
bool? isSignUp,
}) => SignInMeta._({
'is_sign_up': isSignUp ?? false,
'ui_flow_source': ?uiFlowSource,
});
String? get uiFlowSource => _map['ui_flow_source']?.toString();
bool get isSignUp => _map['isSignUp'] == true;
Map<String, Object?> toMap() => <String, Object?>{...this};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment