Created
January 30, 2026 14:35
-
-
Save PlugFox/5593eafa163371223c7c2068266cc1b7 to your computer and use it in GitHub Desktop.
Dart extension type
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
| /* | |
| * 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