From e64fc40dd4ad3a11291264b539288e94d2148450 Mon Sep 17 00:00:00 2001 From: Alexandra Talalaieva <25621530+sashatalalasha@users.noreply.github.com> Date: Wed, 18 Oct 2023 09:20:15 +0200 Subject: [PATCH] feat: add flutter app Ory Network example (#82) * feat: get current session information * feat: create login flow * feat: login with email and password * feat: register with email and password * fix: handle all errors incl deserialization error * feat: logout & get session on home page init * feat: show session information * feat: add design and refactor blocs * fix: change package and folder name * fix: change package name * docs: update README.md * refactor: delete unused icon * refactor: remove unused packages * chore: format code * refactor: add missing package and delete unused test * chore: display components dynamically * chore: clean up and format code * fix: aal2 navigation * chore: remove unnecessary code * chore: fix typo and rename variables * chore: separate exception handlings * fix: prevent null exception --- .../example/kratos_flutter/MainActivity.kt | 6 + .../lib/blocs/auth/auth_bloc.dart | 34 ++- .../lib/blocs/auth/auth_bloc.freezed.dart | 178 +++++++------- .../lib/blocs/login/login_bloc.dart | 32 ++- .../lib/blocs/login/login_bloc.freezed.dart | 35 +-- .../blocs/registration/registration_bloc.dart | 18 +- .../registration_bloc.freezed.dart | 34 +-- flutter-ory-network/lib/pages/login.dart | 1 - .../lib/pages/registration.dart | 1 - .../lib/services/exceptions.freezed.dart | 229 +++++++++--------- flutter-ory-network/lib/widgets/helpers.dart | 1 - .../lib/widgets/nodes/provider.dart | 28 +++ .../lib/widgets/social_provider_box.dart | 28 +++ flutter-ory-network/pubspec.lock | 112 ++++----- 14 files changed, 399 insertions(+), 338 deletions(-) create mode 100644 flutter-ory-network/android/app/src/main/kotlin/com/example/kratos_flutter/MainActivity.kt create mode 100644 flutter-ory-network/lib/widgets/nodes/provider.dart create mode 100644 flutter-ory-network/lib/widgets/social_provider_box.dart diff --git a/flutter-ory-network/android/app/src/main/kotlin/com/example/kratos_flutter/MainActivity.kt b/flutter-ory-network/android/app/src/main/kotlin/com/example/kratos_flutter/MainActivity.kt new file mode 100644 index 0000000..7a4c9c7 --- /dev/null +++ b/flutter-ory-network/android/app/src/main/kotlin/com/example/kratos_flutter/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.ory_network_flutter + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/flutter-ory-network/lib/blocs/auth/auth_bloc.dart b/flutter-ory-network/lib/blocs/auth/auth_bloc.dart index 4661c6f..4ca09ad 100644 --- a/flutter-ory-network/lib/blocs/auth/auth_bloc.dart +++ b/flutter-ory-network/lib/blocs/auth/auth_bloc.dart @@ -52,17 +52,15 @@ class AuthBloc extends Bloc { final session = await repository.getCurrentSessionInformation(); - emit(AuthState.authenticated(isLoading: false, session: session)); - } on CustomException catch (e) { - if (e case UnauthorizedException _) { - emit(const AuthState.unauthenticated()); - } else if (e case TwoFactorAuthRequiredException _) { - emit(const AuthState.aal2Requested()); - } else if (e case UnknownException _) { - emit(state.copyWith(isLoading: false, errorMessage: e.message)); - } else { - emit(state.copyWith(isLoading: false)); - } + emit(AuthState.authenticated(session: session)); + } on UnauthorizedException catch (_) { + emit(const AuthState.unauthenticated()); + } on TwoFactorAuthRequiredException catch (_) { + emit(const AuthState.aal2Requested()); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, errorMessage: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); } } @@ -73,14 +71,12 @@ class AuthBloc extends Bloc { await repository.logout(); emit(const AuthState.unauthenticated()); - } on CustomException catch (e) { - if (e case UnauthorizedException _) { - emit(const AuthState.unauthenticated()); - } else if (e case UnknownException _) { - emit(state.copyWith(isLoading: false, errorMessage: e.message)); - } else { - emit(state.copyWith(isLoading: false)); - } + } on UnauthorizedException catch (_) { + emit(const AuthState.unauthenticated()); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, errorMessage: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); } } } diff --git a/flutter-ory-network/lib/blocs/auth/auth_bloc.freezed.dart b/flutter-ory-network/lib/blocs/auth/auth_bloc.freezed.dart index f38e48d..d9c8dbd 100644 --- a/flutter-ory-network/lib/blocs/auth/auth_bloc.freezed.dart +++ b/flutter-ory-network/lib/blocs/auth/auth_bloc.freezed.dart @@ -152,22 +152,22 @@ class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState> } /// @nodoc -abstract class _$$AuthUninitializedCopyWith<$Res> +abstract class _$$AuthUninitializedImplCopyWith<$Res> implements $AuthStateCopyWith<$Res> { - factory _$$AuthUninitializedCopyWith( - _$AuthUninitialized value, $Res Function(_$AuthUninitialized) then) = - __$$AuthUninitializedCopyWithImpl<$Res>; + factory _$$AuthUninitializedImplCopyWith(_$AuthUninitializedImpl value, + $Res Function(_$AuthUninitializedImpl) then) = + __$$AuthUninitializedImplCopyWithImpl<$Res>; @override @useResult $Res call({AuthStatus status, bool isLoading, String? errorMessage}); } /// @nodoc -class __$$AuthUninitializedCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$AuthUninitialized> - implements _$$AuthUninitializedCopyWith<$Res> { - __$$AuthUninitializedCopyWithImpl( - _$AuthUninitialized _value, $Res Function(_$AuthUninitialized) _then) +class __$$AuthUninitializedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthUninitializedImpl> + implements _$$AuthUninitializedImplCopyWith<$Res> { + __$$AuthUninitializedImplCopyWithImpl(_$AuthUninitializedImpl _value, + $Res Function(_$AuthUninitializedImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -177,7 +177,7 @@ class __$$AuthUninitializedCopyWithImpl<$Res> Object? isLoading = null, Object? errorMessage = freezed, }) { - return _then(_$AuthUninitialized( + return _then(_$AuthUninitializedImpl( status: null == status ? _value.status : status // ignore: cast_nullable_to_non_nullable @@ -196,8 +196,8 @@ class __$$AuthUninitializedCopyWithImpl<$Res> /// @nodoc -class _$AuthUninitialized implements AuthUninitialized { - const _$AuthUninitialized( +class _$AuthUninitializedImpl implements AuthUninitialized { + const _$AuthUninitializedImpl( {this.status = AuthStatus.uninitialized, this.isLoading = false, this.errorMessage}); @@ -220,7 +220,7 @@ class _$AuthUninitialized implements AuthUninitialized { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$AuthUninitialized && + other is _$AuthUninitializedImpl && (identical(other.status, status) || other.status == status) && (identical(other.isLoading, isLoading) || other.isLoading == isLoading) && @@ -234,8 +234,9 @@ class _$AuthUninitialized implements AuthUninitialized { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$AuthUninitializedCopyWith<_$AuthUninitialized> get copyWith => - __$$AuthUninitializedCopyWithImpl<_$AuthUninitialized>(this, _$identity); + _$$AuthUninitializedImplCopyWith<_$AuthUninitializedImpl> get copyWith => + __$$AuthUninitializedImplCopyWithImpl<_$AuthUninitializedImpl>( + this, _$identity); @override @optionalTypeArgs @@ -347,7 +348,7 @@ abstract class AuthUninitialized implements AuthState { const factory AuthUninitialized( {final AuthStatus status, final bool isLoading, - final String? errorMessage}) = _$AuthUninitialized; + final String? errorMessage}) = _$AuthUninitializedImpl; @override AuthStatus get status; @@ -357,27 +358,27 @@ abstract class AuthUninitialized implements AuthState { String? get errorMessage; @override @JsonKey(ignore: true) - _$$AuthUninitializedCopyWith<_$AuthUninitialized> get copyWith => + _$$AuthUninitializedImplCopyWith<_$AuthUninitializedImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$AuthUnauthenticatedCopyWith<$Res> +abstract class _$$AuthUnauthenticatedImplCopyWith<$Res> implements $AuthStateCopyWith<$Res> { - factory _$$AuthUnauthenticatedCopyWith(_$AuthUnauthenticated value, - $Res Function(_$AuthUnauthenticated) then) = - __$$AuthUnauthenticatedCopyWithImpl<$Res>; + factory _$$AuthUnauthenticatedImplCopyWith(_$AuthUnauthenticatedImpl value, + $Res Function(_$AuthUnauthenticatedImpl) then) = + __$$AuthUnauthenticatedImplCopyWithImpl<$Res>; @override @useResult $Res call({AuthStatus status, bool isLoading, String? errorMessage}); } /// @nodoc -class __$$AuthUnauthenticatedCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$AuthUnauthenticated> - implements _$$AuthUnauthenticatedCopyWith<$Res> { - __$$AuthUnauthenticatedCopyWithImpl( - _$AuthUnauthenticated _value, $Res Function(_$AuthUnauthenticated) _then) +class __$$AuthUnauthenticatedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthUnauthenticatedImpl> + implements _$$AuthUnauthenticatedImplCopyWith<$Res> { + __$$AuthUnauthenticatedImplCopyWithImpl(_$AuthUnauthenticatedImpl _value, + $Res Function(_$AuthUnauthenticatedImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -387,7 +388,7 @@ class __$$AuthUnauthenticatedCopyWithImpl<$Res> Object? isLoading = null, Object? errorMessage = freezed, }) { - return _then(_$AuthUnauthenticated( + return _then(_$AuthUnauthenticatedImpl( status: null == status ? _value.status : status // ignore: cast_nullable_to_non_nullable @@ -406,8 +407,8 @@ class __$$AuthUnauthenticatedCopyWithImpl<$Res> /// @nodoc -class _$AuthUnauthenticated implements AuthUnauthenticated { - const _$AuthUnauthenticated( +class _$AuthUnauthenticatedImpl implements AuthUnauthenticated { + const _$AuthUnauthenticatedImpl( {this.status = AuthStatus.unauthenticated, this.isLoading = false, this.errorMessage}); @@ -430,7 +431,7 @@ class _$AuthUnauthenticated implements AuthUnauthenticated { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$AuthUnauthenticated && + other is _$AuthUnauthenticatedImpl && (identical(other.status, status) || other.status == status) && (identical(other.isLoading, isLoading) || other.isLoading == isLoading) && @@ -444,8 +445,8 @@ class _$AuthUnauthenticated implements AuthUnauthenticated { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$AuthUnauthenticatedCopyWith<_$AuthUnauthenticated> get copyWith => - __$$AuthUnauthenticatedCopyWithImpl<_$AuthUnauthenticated>( + _$$AuthUnauthenticatedImplCopyWith<_$AuthUnauthenticatedImpl> get copyWith => + __$$AuthUnauthenticatedImplCopyWithImpl<_$AuthUnauthenticatedImpl>( this, _$identity); @override @@ -558,7 +559,7 @@ abstract class AuthUnauthenticated implements AuthState { const factory AuthUnauthenticated( {final AuthStatus status, final bool isLoading, - final String? errorMessage}) = _$AuthUnauthenticated; + final String? errorMessage}) = _$AuthUnauthenticatedImpl; @override AuthStatus get status; @@ -568,16 +569,16 @@ abstract class AuthUnauthenticated implements AuthState { String? get errorMessage; @override @JsonKey(ignore: true) - _$$AuthUnauthenticatedCopyWith<_$AuthUnauthenticated> get copyWith => + _$$AuthUnauthenticatedImplCopyWith<_$AuthUnauthenticatedImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$AuthAuthenticatedCopyWith<$Res> +abstract class _$$AuthAuthenticatedImplCopyWith<$Res> implements $AuthStateCopyWith<$Res> { - factory _$$AuthAuthenticatedCopyWith( - _$AuthAuthenticated value, $Res Function(_$AuthAuthenticated) then) = - __$$AuthAuthenticatedCopyWithImpl<$Res>; + factory _$$AuthAuthenticatedImplCopyWith(_$AuthAuthenticatedImpl value, + $Res Function(_$AuthAuthenticatedImpl) then) = + __$$AuthAuthenticatedImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -588,11 +589,11 @@ abstract class _$$AuthAuthenticatedCopyWith<$Res> } /// @nodoc -class __$$AuthAuthenticatedCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$AuthAuthenticated> - implements _$$AuthAuthenticatedCopyWith<$Res> { - __$$AuthAuthenticatedCopyWithImpl( - _$AuthAuthenticated _value, $Res Function(_$AuthAuthenticated) _then) +class __$$AuthAuthenticatedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthAuthenticatedImpl> + implements _$$AuthAuthenticatedImplCopyWith<$Res> { + __$$AuthAuthenticatedImplCopyWithImpl(_$AuthAuthenticatedImpl _value, + $Res Function(_$AuthAuthenticatedImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -603,7 +604,7 @@ class __$$AuthAuthenticatedCopyWithImpl<$Res> Object? isLoading = null, Object? errorMessage = freezed, }) { - return _then(_$AuthAuthenticated( + return _then(_$AuthAuthenticatedImpl( status: null == status ? _value.status : status // ignore: cast_nullable_to_non_nullable @@ -626,8 +627,8 @@ class __$$AuthAuthenticatedCopyWithImpl<$Res> /// @nodoc -class _$AuthAuthenticated implements AuthAuthenticated { - const _$AuthAuthenticated( +class _$AuthAuthenticatedImpl implements AuthAuthenticated { + const _$AuthAuthenticatedImpl( {this.status = AuthStatus.authenticated, required this.session, this.isLoading = false, @@ -653,7 +654,7 @@ class _$AuthAuthenticated implements AuthAuthenticated { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$AuthAuthenticated && + other is _$AuthAuthenticatedImpl && (identical(other.status, status) || other.status == status) && (identical(other.session, session) || other.session == session) && (identical(other.isLoading, isLoading) || @@ -669,8 +670,9 @@ class _$AuthAuthenticated implements AuthAuthenticated { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$AuthAuthenticatedCopyWith<_$AuthAuthenticated> get copyWith => - __$$AuthAuthenticatedCopyWithImpl<_$AuthAuthenticated>(this, _$identity); + _$$AuthAuthenticatedImplCopyWith<_$AuthAuthenticatedImpl> get copyWith => + __$$AuthAuthenticatedImplCopyWithImpl<_$AuthAuthenticatedImpl>( + this, _$identity); @override @optionalTypeArgs @@ -783,7 +785,7 @@ abstract class AuthAuthenticated implements AuthState { {final AuthStatus status, required final Session session, final bool isLoading, - final String? errorMessage}) = _$AuthAuthenticated; + final String? errorMessage}) = _$AuthAuthenticatedImpl; @override AuthStatus get status; @@ -794,27 +796,27 @@ abstract class AuthAuthenticated implements AuthState { String? get errorMessage; @override @JsonKey(ignore: true) - _$$AuthAuthenticatedCopyWith<_$AuthAuthenticated> get copyWith => + _$$AuthAuthenticatedImplCopyWith<_$AuthAuthenticatedImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$Aal2RequestedCopyWith<$Res> +abstract class _$$Aal2RequestedImplCopyWith<$Res> implements $AuthStateCopyWith<$Res> { - factory _$$Aal2RequestedCopyWith( - _$Aal2Requested value, $Res Function(_$Aal2Requested) then) = - __$$Aal2RequestedCopyWithImpl<$Res>; + factory _$$Aal2RequestedImplCopyWith( + _$Aal2RequestedImpl value, $Res Function(_$Aal2RequestedImpl) then) = + __$$Aal2RequestedImplCopyWithImpl<$Res>; @override @useResult $Res call({AuthStatus status, bool isLoading, String? errorMessage}); } /// @nodoc -class __$$Aal2RequestedCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$Aal2Requested> - implements _$$Aal2RequestedCopyWith<$Res> { - __$$Aal2RequestedCopyWithImpl( - _$Aal2Requested _value, $Res Function(_$Aal2Requested) _then) +class __$$Aal2RequestedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$Aal2RequestedImpl> + implements _$$Aal2RequestedImplCopyWith<$Res> { + __$$Aal2RequestedImplCopyWithImpl( + _$Aal2RequestedImpl _value, $Res Function(_$Aal2RequestedImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -824,7 +826,7 @@ class __$$Aal2RequestedCopyWithImpl<$Res> Object? isLoading = null, Object? errorMessage = freezed, }) { - return _then(_$Aal2Requested( + return _then(_$Aal2RequestedImpl( status: null == status ? _value.status : status // ignore: cast_nullable_to_non_nullable @@ -843,8 +845,8 @@ class __$$Aal2RequestedCopyWithImpl<$Res> /// @nodoc -class _$Aal2Requested implements Aal2Requested { - const _$Aal2Requested( +class _$Aal2RequestedImpl implements Aal2Requested { + const _$Aal2RequestedImpl( {this.status = AuthStatus.aal2Requested, this.isLoading = false, this.errorMessage}); @@ -867,7 +869,7 @@ class _$Aal2Requested implements Aal2Requested { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Aal2Requested && + other is _$Aal2RequestedImpl && (identical(other.status, status) || other.status == status) && (identical(other.isLoading, isLoading) || other.isLoading == isLoading) && @@ -881,8 +883,8 @@ class _$Aal2Requested implements Aal2Requested { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$Aal2RequestedCopyWith<_$Aal2Requested> get copyWith => - __$$Aal2RequestedCopyWithImpl<_$Aal2Requested>(this, _$identity); + _$$Aal2RequestedImplCopyWith<_$Aal2RequestedImpl> get copyWith => + __$$Aal2RequestedImplCopyWithImpl<_$Aal2RequestedImpl>(this, _$identity); @override @optionalTypeArgs @@ -994,7 +996,7 @@ abstract class Aal2Requested implements AuthState { const factory Aal2Requested( {final AuthStatus status, final bool isLoading, - final String? errorMessage}) = _$Aal2Requested; + final String? errorMessage}) = _$Aal2RequestedImpl; @override AuthStatus get status; @@ -1004,16 +1006,17 @@ abstract class Aal2Requested implements AuthState { String? get errorMessage; @override @JsonKey(ignore: true) - _$$Aal2RequestedCopyWith<_$Aal2Requested> get copyWith => + _$$Aal2RequestedImplCopyWith<_$Aal2RequestedImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$LocationChangeRequiredCopyWith<$Res> +abstract class _$$LocationChangeRequiredImplCopyWith<$Res> implements $AuthStateCopyWith<$Res> { - factory _$$LocationChangeRequiredCopyWith(_$LocationChangeRequired value, - $Res Function(_$LocationChangeRequired) then) = - __$$LocationChangeRequiredCopyWithImpl<$Res>; + factory _$$LocationChangeRequiredImplCopyWith( + _$LocationChangeRequiredImpl value, + $Res Function(_$LocationChangeRequiredImpl) then) = + __$$LocationChangeRequiredImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -1021,11 +1024,12 @@ abstract class _$$LocationChangeRequiredCopyWith<$Res> } /// @nodoc -class __$$LocationChangeRequiredCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$LocationChangeRequired> - implements _$$LocationChangeRequiredCopyWith<$Res> { - __$$LocationChangeRequiredCopyWithImpl(_$LocationChangeRequired _value, - $Res Function(_$LocationChangeRequired) _then) +class __$$LocationChangeRequiredImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$LocationChangeRequiredImpl> + implements _$$LocationChangeRequiredImplCopyWith<$Res> { + __$$LocationChangeRequiredImplCopyWithImpl( + _$LocationChangeRequiredImpl _value, + $Res Function(_$LocationChangeRequiredImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -1036,7 +1040,7 @@ class __$$LocationChangeRequiredCopyWithImpl<$Res> Object? isLoading = null, Object? errorMessage = freezed, }) { - return _then(_$LocationChangeRequired( + return _then(_$LocationChangeRequiredImpl( status: null == status ? _value.status : status // ignore: cast_nullable_to_non_nullable @@ -1059,8 +1063,8 @@ class __$$LocationChangeRequiredCopyWithImpl<$Res> /// @nodoc -class _$LocationChangeRequired implements LocationChangeRequired { - const _$LocationChangeRequired( +class _$LocationChangeRequiredImpl implements LocationChangeRequired { + const _$LocationChangeRequiredImpl( {this.status = AuthStatus.locationChangeRequired, required this.url, this.isLoading = false, @@ -1086,7 +1090,7 @@ class _$LocationChangeRequired implements LocationChangeRequired { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$LocationChangeRequired && + other is _$LocationChangeRequiredImpl && (identical(other.status, status) || other.status == status) && (identical(other.url, url) || other.url == url) && (identical(other.isLoading, isLoading) || @@ -1102,9 +1106,9 @@ class _$LocationChangeRequired implements LocationChangeRequired { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$LocationChangeRequiredCopyWith<_$LocationChangeRequired> get copyWith => - __$$LocationChangeRequiredCopyWithImpl<_$LocationChangeRequired>( - this, _$identity); + _$$LocationChangeRequiredImplCopyWith<_$LocationChangeRequiredImpl> + get copyWith => __$$LocationChangeRequiredImplCopyWithImpl< + _$LocationChangeRequiredImpl>(this, _$identity); @override @optionalTypeArgs @@ -1217,7 +1221,7 @@ abstract class LocationChangeRequired implements AuthState { {final AuthStatus status, required final String url, final bool isLoading, - final String? errorMessage}) = _$LocationChangeRequired; + final String? errorMessage}) = _$LocationChangeRequiredImpl; @override AuthStatus get status; @@ -1228,6 +1232,6 @@ abstract class LocationChangeRequired implements AuthState { String? get errorMessage; @override @JsonKey(ignore: true) - _$$LocationChangeRequiredCopyWith<_$LocationChangeRequired> get copyWith => - throw _privateConstructorUsedError; + _$$LocationChangeRequiredImplCopyWith<_$LocationChangeRequiredImpl> + get copyWith => throw _privateConstructorUsedError; } diff --git a/flutter-ory-network/lib/blocs/login/login_bloc.dart b/flutter-ory-network/lib/blocs/login/login_bloc.dart index 2a4a270..a3c7a68 100644 --- a/flutter-ory-network/lib/blocs/login/login_bloc.dart +++ b/flutter-ory-network/lib/blocs/login/login_bloc.dart @@ -102,23 +102,21 @@ class LoginBloc extends Bloc { value: event.value, nodes: state.loginFlow!.ui.nodes.toList()); authBloc.add(AddSession(session: session)); - } on CustomException catch (e) { - if (e case BadRequestException _) { - emit(state.copyWith(loginFlow: e.flow, isLoading: false)); - } else if (e case LocationChangeRequiredException _) { - emit(state.copyWith(isLoading: false)); - add(LoginWithWebAuth(url: e.url)); - } else if (e case UnauthorizedException _) { - authBloc.add(ChangeAuthStatus(status: AuthStatus.unauthenticated)); - } else if (e case FlowExpiredException _) { - add(GetLoginFlow(flowId: e.flowId)); - } else if (e case TwoFactorAuthRequiredException _) { - authBloc.add(ChangeAuthStatus(status: AuthStatus.aal2Requested)); - } else if (e case UnknownException _) { - emit(state.copyWith(isLoading: false, message: e.message)); - } else { - emit(state.copyWith(isLoading: false)); - } + } on BadRequestException catch (e) { + emit(state.copyWith(loginFlow: e.flow, isLoading: false)); + } on LocationChangeRequiredException catch (e) { + emit(state.copyWith(isLoading: false)); + add(LoginWithWebAuth(url: e.url)); + } on UnauthorizedException catch (_) { + authBloc.add(ChangeAuthStatus(status: AuthStatus.unauthenticated)); + } on FlowExpiredException catch (e) { + add(GetLoginFlow(flowId: e.flowId)); + } on TwoFactorAuthRequiredException catch (_) { + authBloc.add(ChangeAuthStatus(status: AuthStatus.aal2Requested)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); } } } diff --git a/flutter-ory-network/lib/blocs/login/login_bloc.freezed.dart b/flutter-ory-network/lib/blocs/login/login_bloc.freezed.dart index 805f093..52bd212 100644 --- a/flutter-ory-network/lib/blocs/login/login_bloc.freezed.dart +++ b/flutter-ory-network/lib/blocs/login/login_bloc.freezed.dart @@ -72,22 +72,22 @@ class _$LoginStateCopyWithImpl<$Res, $Val extends LoginState> } /// @nodoc -abstract class _$$_LoginStateCopyWith<$Res> +abstract class _$$LoginStateImplCopyWith<$Res> implements $LoginStateCopyWith<$Res> { - factory _$$_LoginStateCopyWith( - _$_LoginState value, $Res Function(_$_LoginState) then) = - __$$_LoginStateCopyWithImpl<$Res>; + factory _$$LoginStateImplCopyWith( + _$LoginStateImpl value, $Res Function(_$LoginStateImpl) then) = + __$$LoginStateImplCopyWithImpl<$Res>; @override @useResult $Res call({LoginFlow? loginFlow, bool isLoading, String? message}); } /// @nodoc -class __$$_LoginStateCopyWithImpl<$Res> - extends _$LoginStateCopyWithImpl<$Res, _$_LoginState> - implements _$$_LoginStateCopyWith<$Res> { - __$$_LoginStateCopyWithImpl( - _$_LoginState _value, $Res Function(_$_LoginState) _then) +class __$$LoginStateImplCopyWithImpl<$Res> + extends _$LoginStateCopyWithImpl<$Res, _$LoginStateImpl> + implements _$$LoginStateImplCopyWith<$Res> { + __$$LoginStateImplCopyWithImpl( + _$LoginStateImpl _value, $Res Function(_$LoginStateImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -97,7 +97,7 @@ class __$$_LoginStateCopyWithImpl<$Res> Object? isLoading = null, Object? message = freezed, }) { - return _then(_$_LoginState( + return _then(_$LoginStateImpl( loginFlow: freezed == loginFlow ? _value.loginFlow : loginFlow // ignore: cast_nullable_to_non_nullable @@ -116,8 +116,9 @@ class __$$_LoginStateCopyWithImpl<$Res> /// @nodoc -class _$_LoginState implements _LoginState { - const _$_LoginState({this.loginFlow, this.isLoading = false, this.message}); +class _$LoginStateImpl implements _LoginState { + const _$LoginStateImpl( + {this.loginFlow, this.isLoading = false, this.message}); @override final LoginFlow? loginFlow; @@ -136,7 +137,7 @@ class _$_LoginState implements _LoginState { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_LoginState && + other is _$LoginStateImpl && (identical(other.loginFlow, loginFlow) || other.loginFlow == loginFlow) && (identical(other.isLoading, isLoading) || @@ -150,15 +151,15 @@ class _$_LoginState implements _LoginState { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_LoginStateCopyWith<_$_LoginState> get copyWith => - __$$_LoginStateCopyWithImpl<_$_LoginState>(this, _$identity); + _$$LoginStateImplCopyWith<_$LoginStateImpl> get copyWith => + __$$LoginStateImplCopyWithImpl<_$LoginStateImpl>(this, _$identity); } abstract class _LoginState implements LoginState { const factory _LoginState( {final LoginFlow? loginFlow, final bool isLoading, - final String? message}) = _$_LoginState; + final String? message}) = _$LoginStateImpl; @override LoginFlow? get loginFlow; @@ -168,6 +169,6 @@ abstract class _LoginState implements LoginState { String? get message; @override @JsonKey(ignore: true) - _$$_LoginStateCopyWith<_$_LoginState> get copyWith => + _$$LoginStateImplCopyWith<_$LoginStateImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/flutter-ory-network/lib/blocs/registration/registration_bloc.dart b/flutter-ory-network/lib/blocs/registration/registration_bloc.dart index d4bc5db..97cc172 100644 --- a/flutter-ory-network/lib/blocs/registration/registration_bloc.dart +++ b/flutter-ory-network/lib/blocs/registration/registration_bloc.dart @@ -106,19 +106,17 @@ class RegistrationBloc extends Bloc { nodes: state.registrationFlow!.ui.nodes.toList()); authBloc.add(ChangeAuthStatus(status: AuthStatus.authenticated)); } + } on BadRequestException catch (e) { + emit(state.copyWith(registrationFlow: e.flow, isLoading: false)); } on LocationChangeRequiredException catch (e) { emit(state.copyWith(isLoading: false)); add(RegisterWithWebAuth(url: e.url)); - } on CustomException catch (e) { - if (e case BadRequestException _) { - emit(state.copyWith(registrationFlow: e.flow, isLoading: false)); - } else if (e case FlowExpiredException _) { - add(GetRegistrationFlow(flowId: e.flowId)); - } else if (e case UnknownException _) { - emit(state.copyWith(isLoading: false, message: e.message)); - } else { - emit(state.copyWith(isLoading: false)); - } + } on FlowExpiredException catch (e) { + add(GetRegistrationFlow(flowId: e.flowId)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); } } } diff --git a/flutter-ory-network/lib/blocs/registration/registration_bloc.freezed.dart b/flutter-ory-network/lib/blocs/registration/registration_bloc.freezed.dart index f31c6b2..ef634d0 100644 --- a/flutter-ory-network/lib/blocs/registration/registration_bloc.freezed.dart +++ b/flutter-ory-network/lib/blocs/registration/registration_bloc.freezed.dart @@ -73,11 +73,11 @@ class _$RegistrationStateCopyWithImpl<$Res, $Val extends RegistrationState> } /// @nodoc -abstract class _$$_RegistrationStateCopyWith<$Res> +abstract class _$$RegistrationStateImplCopyWith<$Res> implements $RegistrationStateCopyWith<$Res> { - factory _$$_RegistrationStateCopyWith(_$_RegistrationState value, - $Res Function(_$_RegistrationState) then) = - __$$_RegistrationStateCopyWithImpl<$Res>; + factory _$$RegistrationStateImplCopyWith(_$RegistrationStateImpl value, + $Res Function(_$RegistrationStateImpl) then) = + __$$RegistrationStateImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -85,11 +85,11 @@ abstract class _$$_RegistrationStateCopyWith<$Res> } /// @nodoc -class __$$_RegistrationStateCopyWithImpl<$Res> - extends _$RegistrationStateCopyWithImpl<$Res, _$_RegistrationState> - implements _$$_RegistrationStateCopyWith<$Res> { - __$$_RegistrationStateCopyWithImpl( - _$_RegistrationState _value, $Res Function(_$_RegistrationState) _then) +class __$$RegistrationStateImplCopyWithImpl<$Res> + extends _$RegistrationStateCopyWithImpl<$Res, _$RegistrationStateImpl> + implements _$$RegistrationStateImplCopyWith<$Res> { + __$$RegistrationStateImplCopyWithImpl(_$RegistrationStateImpl _value, + $Res Function(_$RegistrationStateImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -99,7 +99,7 @@ class __$$_RegistrationStateCopyWithImpl<$Res> Object? isLoading = null, Object? message = freezed, }) { - return _then(_$_RegistrationState( + return _then(_$RegistrationStateImpl( registrationFlow: freezed == registrationFlow ? _value.registrationFlow : registrationFlow // ignore: cast_nullable_to_non_nullable @@ -118,8 +118,8 @@ class __$$_RegistrationStateCopyWithImpl<$Res> /// @nodoc -class _$_RegistrationState implements _RegistrationState { - const _$_RegistrationState( +class _$RegistrationStateImpl implements _RegistrationState { + const _$RegistrationStateImpl( {this.registrationFlow, this.isLoading = false, this.message}); @override @@ -139,7 +139,7 @@ class _$_RegistrationState implements _RegistrationState { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_RegistrationState && + other is _$RegistrationStateImpl && (identical(other.registrationFlow, registrationFlow) || other.registrationFlow == registrationFlow) && (identical(other.isLoading, isLoading) || @@ -154,8 +154,8 @@ class _$_RegistrationState implements _RegistrationState { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_RegistrationStateCopyWith<_$_RegistrationState> get copyWith => - __$$_RegistrationStateCopyWithImpl<_$_RegistrationState>( + _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => + __$$RegistrationStateImplCopyWithImpl<_$RegistrationStateImpl>( this, _$identity); } @@ -163,7 +163,7 @@ abstract class _RegistrationState implements RegistrationState { const factory _RegistrationState( {final RegistrationFlow? registrationFlow, final bool isLoading, - final String? message}) = _$_RegistrationState; + final String? message}) = _$RegistrationStateImpl; @override RegistrationFlow? get registrationFlow; @@ -173,6 +173,6 @@ abstract class _RegistrationState implements RegistrationState { String? get message; @override @JsonKey(ignore: true) - _$$_RegistrationStateCopyWith<_$_RegistrationState> get copyWith => + _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/flutter-ory-network/lib/pages/login.dart b/flutter-ory-network/lib/pages/login.dart index f8fe97d..e5790cd 100644 --- a/flutter-ory-network/lib/pages/login.dart +++ b/flutter-ory-network/lib/pages/login.dart @@ -146,7 +146,6 @@ class LoginForm extends StatelessWidget { if (totpNodes.isNotEmpty) buildGroup(context, UiNodeGroupEnum.totp, totpNodes, _onInputChange, _onInputSubmit), - const SizedBox( height: 32, ), diff --git a/flutter-ory-network/lib/pages/registration.dart b/flutter-ory-network/lib/pages/registration.dart index dc8f9a0..b0ad52c 100644 --- a/flutter-ory-network/lib/pages/registration.dart +++ b/flutter-ory-network/lib/pages/registration.dart @@ -11,7 +11,6 @@ import '../blocs/auth/auth_bloc.dart'; import '../blocs/registration/registration_bloc.dart'; import '../repositories/auth.dart'; import '../widgets/helpers.dart'; - import 'login.dart'; class RegistrationPage extends StatelessWidget { diff --git a/flutter-ory-network/lib/services/exceptions.freezed.dart b/flutter-ory-network/lib/services/exceptions.freezed.dart index 11fb8fa..692afea 100644 --- a/flutter-ory-network/lib/services/exceptions.freezed.dart +++ b/flutter-ory-network/lib/services/exceptions.freezed.dart @@ -108,20 +108,20 @@ class _$CustomExceptionCopyWithImpl> } /// @nodoc -abstract class _$$BadRequestExceptionCopyWith { - factory _$$BadRequestExceptionCopyWith(_$BadRequestException value, - $Res Function(_$BadRequestException) then) = - __$$BadRequestExceptionCopyWithImpl; +abstract class _$$BadRequestExceptionImplCopyWith { + factory _$$BadRequestExceptionImplCopyWith(_$BadRequestExceptionImpl value, + $Res Function(_$BadRequestExceptionImpl) then) = + __$$BadRequestExceptionImplCopyWithImpl; @useResult $Res call({T flow}); } /// @nodoc -class __$$BadRequestExceptionCopyWithImpl - extends _$CustomExceptionCopyWithImpl> - implements _$$BadRequestExceptionCopyWith { - __$$BadRequestExceptionCopyWithImpl(_$BadRequestException _value, - $Res Function(_$BadRequestException) _then) +class __$$BadRequestExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$BadRequestExceptionImplCopyWith { + __$$BadRequestExceptionImplCopyWithImpl(_$BadRequestExceptionImpl _value, + $Res Function(_$BadRequestExceptionImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -129,7 +129,7 @@ class __$$BadRequestExceptionCopyWithImpl $Res call({ Object? flow = freezed, }) { - return _then(_$BadRequestException( + return _then(_$BadRequestExceptionImpl( flow: freezed == flow ? _value.flow : flow // ignore: cast_nullable_to_non_nullable @@ -140,9 +140,9 @@ class __$$BadRequestExceptionCopyWithImpl /// @nodoc -class _$BadRequestException extends BadRequestException +class _$BadRequestExceptionImpl extends BadRequestException with DiagnosticableTreeMixin { - const _$BadRequestException({required this.flow}) : super._(); + const _$BadRequestExceptionImpl({required this.flow}) : super._(); @override final T flow; @@ -164,7 +164,7 @@ class _$BadRequestException extends BadRequestException bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$BadRequestException && + other is _$BadRequestExceptionImpl && const DeepCollectionEquality().equals(other.flow, flow)); } @@ -175,9 +175,9 @@ class _$BadRequestException extends BadRequestException @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$BadRequestExceptionCopyWith> get copyWith => - __$$BadRequestExceptionCopyWithImpl>( - this, _$identity); + _$$BadRequestExceptionImplCopyWith> + get copyWith => __$$BadRequestExceptionImplCopyWithImpl>(this, _$identity); @override @optionalTypeArgs @@ -274,36 +274,39 @@ class _$BadRequestException extends BadRequestException abstract class BadRequestException extends CustomException { const factory BadRequestException({required final T flow}) = - _$BadRequestException; + _$BadRequestExceptionImpl; const BadRequestException._() : super._(); T get flow; @JsonKey(ignore: true) - _$$BadRequestExceptionCopyWith> get copyWith => - throw _privateConstructorUsedError; + _$$BadRequestExceptionImplCopyWith> + get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$UnauthorizedExceptionCopyWith { - factory _$$UnauthorizedExceptionCopyWith(_$UnauthorizedException value, - $Res Function(_$UnauthorizedException) then) = - __$$UnauthorizedExceptionCopyWithImpl; +abstract class _$$UnauthorizedExceptionImplCopyWith { + factory _$$UnauthorizedExceptionImplCopyWith( + _$UnauthorizedExceptionImpl value, + $Res Function(_$UnauthorizedExceptionImpl) then) = + __$$UnauthorizedExceptionImplCopyWithImpl; } /// @nodoc -class __$$UnauthorizedExceptionCopyWithImpl - extends _$CustomExceptionCopyWithImpl> - implements _$$UnauthorizedExceptionCopyWith { - __$$UnauthorizedExceptionCopyWithImpl(_$UnauthorizedException _value, - $Res Function(_$UnauthorizedException) _then) +class __$$UnauthorizedExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$UnauthorizedExceptionImplCopyWith { + __$$UnauthorizedExceptionImplCopyWithImpl( + _$UnauthorizedExceptionImpl _value, + $Res Function(_$UnauthorizedExceptionImpl) _then) : super(_value, _then); } /// @nodoc -class _$UnauthorizedException extends UnauthorizedException +class _$UnauthorizedExceptionImpl extends UnauthorizedException with DiagnosticableTreeMixin { - const _$UnauthorizedException() : super._(); + const _$UnauthorizedExceptionImpl() : super._(); @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { @@ -321,7 +324,7 @@ class _$UnauthorizedException extends UnauthorizedException bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$UnauthorizedException); + other is _$UnauthorizedExceptionImpl); } @override @@ -421,25 +424,27 @@ class _$UnauthorizedException extends UnauthorizedException } abstract class UnauthorizedException extends CustomException { - const factory UnauthorizedException() = _$UnauthorizedException; + const factory UnauthorizedException() = _$UnauthorizedExceptionImpl; const UnauthorizedException._() : super._(); } /// @nodoc -abstract class _$$FlowExpiredExceptionCopyWith { - factory _$$FlowExpiredExceptionCopyWith(_$FlowExpiredException value, - $Res Function(_$FlowExpiredException) then) = - __$$FlowExpiredExceptionCopyWithImpl; +abstract class _$$FlowExpiredExceptionImplCopyWith { + factory _$$FlowExpiredExceptionImplCopyWith( + _$FlowExpiredExceptionImpl value, + $Res Function(_$FlowExpiredExceptionImpl) then) = + __$$FlowExpiredExceptionImplCopyWithImpl; @useResult $Res call({String flowId, String? message}); } /// @nodoc -class __$$FlowExpiredExceptionCopyWithImpl - extends _$CustomExceptionCopyWithImpl> - implements _$$FlowExpiredExceptionCopyWith { - __$$FlowExpiredExceptionCopyWithImpl(_$FlowExpiredException _value, - $Res Function(_$FlowExpiredException) _then) +class __$$FlowExpiredExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$FlowExpiredExceptionImplCopyWith { + __$$FlowExpiredExceptionImplCopyWithImpl(_$FlowExpiredExceptionImpl _value, + $Res Function(_$FlowExpiredExceptionImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -448,7 +453,7 @@ class __$$FlowExpiredExceptionCopyWithImpl Object? flowId = null, Object? message = freezed, }) { - return _then(_$FlowExpiredException( + return _then(_$FlowExpiredExceptionImpl( flowId: null == flowId ? _value.flowId : flowId // ignore: cast_nullable_to_non_nullable @@ -463,9 +468,9 @@ class __$$FlowExpiredExceptionCopyWithImpl /// @nodoc -class _$FlowExpiredException extends FlowExpiredException +class _$FlowExpiredExceptionImpl extends FlowExpiredException with DiagnosticableTreeMixin { - const _$FlowExpiredException({required this.flowId, this.message}) + const _$FlowExpiredExceptionImpl({required this.flowId, this.message}) : super._(); @override @@ -491,7 +496,7 @@ class _$FlowExpiredException extends FlowExpiredException bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$FlowExpiredException && + other is _$FlowExpiredExceptionImpl && (identical(other.flowId, flowId) || other.flowId == flowId) && (identical(other.message, message) || other.message == message)); } @@ -502,9 +507,9 @@ class _$FlowExpiredException extends FlowExpiredException @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$FlowExpiredExceptionCopyWith> get copyWith => - __$$FlowExpiredExceptionCopyWithImpl>( - this, _$identity); + _$$FlowExpiredExceptionImplCopyWith> + get copyWith => __$$FlowExpiredExceptionImplCopyWithImpl>(this, _$identity); @override @optionalTypeArgs @@ -602,34 +607,34 @@ class _$FlowExpiredException extends FlowExpiredException abstract class FlowExpiredException extends CustomException { const factory FlowExpiredException( {required final String flowId, - final String? message}) = _$FlowExpiredException; + final String? message}) = _$FlowExpiredExceptionImpl; const FlowExpiredException._() : super._(); String get flowId; String? get message; @JsonKey(ignore: true) - _$$FlowExpiredExceptionCopyWith> get copyWith => - throw _privateConstructorUsedError; + _$$FlowExpiredExceptionImplCopyWith> + get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$TwoFactorAuthRequiredExceptionCopyWith { - factory _$$TwoFactorAuthRequiredExceptionCopyWith( - _$TwoFactorAuthRequiredException value, - $Res Function(_$TwoFactorAuthRequiredException) then) = - __$$TwoFactorAuthRequiredExceptionCopyWithImpl; +abstract class _$$TwoFactorAuthRequiredExceptionImplCopyWith { + factory _$$TwoFactorAuthRequiredExceptionImplCopyWith( + _$TwoFactorAuthRequiredExceptionImpl value, + $Res Function(_$TwoFactorAuthRequiredExceptionImpl) then) = + __$$TwoFactorAuthRequiredExceptionImplCopyWithImpl; @useResult $Res call({Session? session}); } /// @nodoc -class __$$TwoFactorAuthRequiredExceptionCopyWithImpl +class __$$TwoFactorAuthRequiredExceptionImplCopyWithImpl extends _$CustomExceptionCopyWithImpl> - implements _$$TwoFactorAuthRequiredExceptionCopyWith { - __$$TwoFactorAuthRequiredExceptionCopyWithImpl( - _$TwoFactorAuthRequiredException _value, - $Res Function(_$TwoFactorAuthRequiredException) _then) + _$TwoFactorAuthRequiredExceptionImpl> + implements _$$TwoFactorAuthRequiredExceptionImplCopyWith { + __$$TwoFactorAuthRequiredExceptionImplCopyWithImpl( + _$TwoFactorAuthRequiredExceptionImpl _value, + $Res Function(_$TwoFactorAuthRequiredExceptionImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -637,7 +642,7 @@ class __$$TwoFactorAuthRequiredExceptionCopyWithImpl $Res call({ Object? session = freezed, }) { - return _then(_$TwoFactorAuthRequiredException( + return _then(_$TwoFactorAuthRequiredExceptionImpl( session: freezed == session ? _value.session : session // ignore: cast_nullable_to_non_nullable @@ -648,9 +653,9 @@ class __$$TwoFactorAuthRequiredExceptionCopyWithImpl /// @nodoc -class _$TwoFactorAuthRequiredException +class _$TwoFactorAuthRequiredExceptionImpl extends TwoFactorAuthRequiredException with DiagnosticableTreeMixin { - const _$TwoFactorAuthRequiredException({this.session}) : super._(); + const _$TwoFactorAuthRequiredExceptionImpl({this.session}) : super._(); @override final Session? session; @@ -673,7 +678,7 @@ class _$TwoFactorAuthRequiredException bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$TwoFactorAuthRequiredException && + other is _$TwoFactorAuthRequiredExceptionImpl && (identical(other.session, session) || other.session == session)); } @@ -683,10 +688,10 @@ class _$TwoFactorAuthRequiredException @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$TwoFactorAuthRequiredExceptionCopyWith> - get copyWith => __$$TwoFactorAuthRequiredExceptionCopyWithImpl>(this, _$identity); + _$$TwoFactorAuthRequiredExceptionImplCopyWith> + get copyWith => __$$TwoFactorAuthRequiredExceptionImplCopyWithImpl>(this, _$identity); @override @optionalTypeArgs @@ -783,34 +788,34 @@ class _$TwoFactorAuthRequiredException abstract class TwoFactorAuthRequiredException extends CustomException { const factory TwoFactorAuthRequiredException({final Session? session}) = - _$TwoFactorAuthRequiredException; + _$TwoFactorAuthRequiredExceptionImpl; const TwoFactorAuthRequiredException._() : super._(); Session? get session; @JsonKey(ignore: true) - _$$TwoFactorAuthRequiredExceptionCopyWith> + _$$TwoFactorAuthRequiredExceptionImplCopyWith> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$LocationChangeRequiredExceptionCopyWith { - factory _$$LocationChangeRequiredExceptionCopyWith( - _$LocationChangeRequiredException value, - $Res Function(_$LocationChangeRequiredException) then) = - __$$LocationChangeRequiredExceptionCopyWithImpl; +abstract class _$$LocationChangeRequiredExceptionImplCopyWith { + factory _$$LocationChangeRequiredExceptionImplCopyWith( + _$LocationChangeRequiredExceptionImpl value, + $Res Function(_$LocationChangeRequiredExceptionImpl) then) = + __$$LocationChangeRequiredExceptionImplCopyWithImpl; @useResult $Res call({String url}); } /// @nodoc -class __$$LocationChangeRequiredExceptionCopyWithImpl +class __$$LocationChangeRequiredExceptionImplCopyWithImpl extends _$CustomExceptionCopyWithImpl> - implements _$$LocationChangeRequiredExceptionCopyWith { - __$$LocationChangeRequiredExceptionCopyWithImpl( - _$LocationChangeRequiredException _value, - $Res Function(_$LocationChangeRequiredException) _then) + _$LocationChangeRequiredExceptionImpl> + implements _$$LocationChangeRequiredExceptionImplCopyWith { + __$$LocationChangeRequiredExceptionImplCopyWithImpl( + _$LocationChangeRequiredExceptionImpl _value, + $Res Function(_$LocationChangeRequiredExceptionImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -818,7 +823,7 @@ class __$$LocationChangeRequiredExceptionCopyWithImpl $Res call({ Object? url = null, }) { - return _then(_$LocationChangeRequiredException( + return _then(_$LocationChangeRequiredExceptionImpl( url: null == url ? _value.url : url // ignore: cast_nullable_to_non_nullable @@ -829,9 +834,9 @@ class __$$LocationChangeRequiredExceptionCopyWithImpl /// @nodoc -class _$LocationChangeRequiredException +class _$LocationChangeRequiredExceptionImpl extends LocationChangeRequiredException with DiagnosticableTreeMixin { - const _$LocationChangeRequiredException({required this.url}) : super._(); + const _$LocationChangeRequiredExceptionImpl({required this.url}) : super._(); @override final String url; @@ -854,7 +859,7 @@ class _$LocationChangeRequiredException bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$LocationChangeRequiredException && + other is _$LocationChangeRequiredExceptionImpl && (identical(other.url, url) || other.url == url)); } @@ -864,10 +869,10 @@ class _$LocationChangeRequiredException @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$LocationChangeRequiredExceptionCopyWith> - get copyWith => __$$LocationChangeRequiredExceptionCopyWithImpl>(this, _$identity); + _$$LocationChangeRequiredExceptionImplCopyWith> + get copyWith => __$$LocationChangeRequiredExceptionImplCopyWithImpl>(this, _$identity); @override @optionalTypeArgs @@ -964,31 +969,31 @@ class _$LocationChangeRequiredException abstract class LocationChangeRequiredException extends CustomException { const factory LocationChangeRequiredException({required final String url}) = - _$LocationChangeRequiredException; + _$LocationChangeRequiredExceptionImpl; const LocationChangeRequiredException._() : super._(); String get url; @JsonKey(ignore: true) - _$$LocationChangeRequiredExceptionCopyWith> + _$$LocationChangeRequiredExceptionImplCopyWith> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$UnknownExceptionCopyWith { - factory _$$UnknownExceptionCopyWith(_$UnknownException value, - $Res Function(_$UnknownException) then) = - __$$UnknownExceptionCopyWithImpl; +abstract class _$$UnknownExceptionImplCopyWith { + factory _$$UnknownExceptionImplCopyWith(_$UnknownExceptionImpl value, + $Res Function(_$UnknownExceptionImpl) then) = + __$$UnknownExceptionImplCopyWithImpl; @useResult $Res call({String? message}); } /// @nodoc -class __$$UnknownExceptionCopyWithImpl - extends _$CustomExceptionCopyWithImpl> - implements _$$UnknownExceptionCopyWith { - __$$UnknownExceptionCopyWithImpl( - _$UnknownException _value, $Res Function(_$UnknownException) _then) +class __$$UnknownExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$UnknownExceptionImplCopyWith { + __$$UnknownExceptionImplCopyWithImpl(_$UnknownExceptionImpl _value, + $Res Function(_$UnknownExceptionImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -996,7 +1001,7 @@ class __$$UnknownExceptionCopyWithImpl $Res call({ Object? message = freezed, }) { - return _then(_$UnknownException( + return _then(_$UnknownExceptionImpl( message: freezed == message ? _value.message : message // ignore: cast_nullable_to_non_nullable @@ -1007,9 +1012,9 @@ class __$$UnknownExceptionCopyWithImpl /// @nodoc -class _$UnknownException extends UnknownException +class _$UnknownExceptionImpl extends UnknownException with DiagnosticableTreeMixin { - const _$UnknownException( + const _$UnknownExceptionImpl( {this.message = 'An error occured. Please try again later.'}) : super._(); @@ -1034,7 +1039,7 @@ class _$UnknownException extends UnknownException bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$UnknownException && + other is _$UnknownExceptionImpl && (identical(other.message, message) || other.message == message)); } @@ -1044,8 +1049,8 @@ class _$UnknownException extends UnknownException @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$UnknownExceptionCopyWith> get copyWith => - __$$UnknownExceptionCopyWithImpl>( + _$$UnknownExceptionImplCopyWith> get copyWith => + __$$UnknownExceptionImplCopyWithImpl>( this, _$identity); @override @@ -1143,11 +1148,11 @@ class _$UnknownException extends UnknownException abstract class UnknownException extends CustomException { const factory UnknownException({final String? message}) = - _$UnknownException; + _$UnknownExceptionImpl; const UnknownException._() : super._(); String? get message; @JsonKey(ignore: true) - _$$UnknownExceptionCopyWith> get copyWith => + _$$UnknownExceptionImplCopyWith> get copyWith => throw _privateConstructorUsedError; } diff --git a/flutter-ory-network/lib/widgets/helpers.dart b/flutter-ory-network/lib/widgets/helpers.dart index 9eba3b7..ad6f03c 100644 --- a/flutter-ory-network/lib/widgets/helpers.dart +++ b/flutter-ory-network/lib/widgets/helpers.dart @@ -73,7 +73,6 @@ buildInputNode( void Function(BuildContext, UiNodeGroupEnum, String, String) onInputSubmit) { final inputNode = node.attributes.oneOf.value as UiNodeInputAttributes; - switch (inputNode.type) { case UiNodeInputAttributesTypeEnum.submit: return InputSubmitNode( diff --git a/flutter-ory-network/lib/widgets/nodes/provider.dart b/flutter-ory-network/lib/widgets/nodes/provider.dart new file mode 100644 index 0000000..d389084 --- /dev/null +++ b/flutter-ory-network/lib/widgets/nodes/provider.dart @@ -0,0 +1,28 @@ +// Copyright © 2023 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:ory_client/ory_client.dart'; + +class SocialProviderInput extends StatelessWidget { + final UiNode node; + + const SocialProviderInput({super.key, required this.node}); + @override + Widget build(BuildContext context) { + final provider = node.attributes.oneOf.isType(UiNodeInputAttributes) + ? (node.attributes.oneOf.value as UiNodeInputAttributes).value?.asString + : null; + return SizedBox( + width: double.infinity, + child: OutlinedButton.icon( + icon: Image.asset( + 'assets/images/flows-auth-buttons-social-$provider.png'), + label: Text(node.meta.label?.text ?? ''), + onPressed: () { + //TODO + }, + ), + ); + } +} diff --git a/flutter-ory-network/lib/widgets/social_provider_box.dart b/flutter-ory-network/lib/widgets/social_provider_box.dart new file mode 100644 index 0000000..5c1e788 --- /dev/null +++ b/flutter-ory-network/lib/widgets/social_provider_box.dart @@ -0,0 +1,28 @@ +// Copyright © 2023 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; + +class SocialProviderBox extends StatelessWidget { + final SocialProvider provider; + + const SocialProviderBox({super.key, required this.provider}); + @override + Widget build(BuildContext context) { + return Expanded( + child: AspectRatio( + aspectRatio: 1.6, + child: Container( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16), + decoration: BoxDecoration( + border: Border.all(width: 1, color: const Color(0xFFE2E8F0))), + child: // get icon from assets depending on provider + Image.asset( + 'assets/images/flows-auth-buttons-social-${provider.name}.png'), + ), + ), + ); + } +} + +enum SocialProvider { google, github, apple, linkedin } diff --git a/flutter-ory-network/pubspec.lock b/flutter-ory-network/pubspec.lock index 6767951..1535585 100644 --- a/flutter-ory-network/pubspec.lock +++ b/flutter-ory-network/pubspec.lock @@ -77,10 +77,10 @@ packages: dependency: transitive description: name: build_resolvers - sha256: "6c4dd11d05d056e76320b828a1db0fc01ccd376922526f8e9d6c796a5adbac20" + sha256: "64e12b0521812d1684b1917bc80945625391cb9bdd4312536b1d69dcb6133ed8" url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.4.1" build_runner: dependency: "direct dev" description: @@ -93,10 +93,10 @@ packages: dependency: transitive description: name: build_runner_core - sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41" + sha256: c9e32d21dd6626b5c163d48b037ce906bbe428bc23ab77bcd77bb21e593b6185 url: "https://pub.dev" source: hosted - version: "7.2.10" + version: "7.2.11" built_collection: dependency: "direct main" description: @@ -109,10 +109,10 @@ packages: dependency: "direct main" description: name: built_value - sha256: ff627b645b28fb8bdb69e645f910c2458fd6b65f6585c3a53e0626024897dedf + sha256: a8de5955205b4d1dbbbc267daddf2178bd737e4bab8987c04a500478c9651e74 url: "https://pub.dev" source: hosted - version: "8.6.2" + version: "8.6.3" characters: dependency: transitive description: @@ -141,10 +141,10 @@ packages: dependency: transitive description: name: code_builder - sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189" + sha256: "1be9be30396d7e4c0db42c35ea6ccd7cc6a1e19916b5dc64d6ac216b5544d677" url: "https://pub.dev" source: hosted - version: "4.5.0" + version: "4.7.0" collection: dependency: "direct main" description: @@ -173,10 +173,10 @@ packages: dependency: transitive description: name: dart_style - sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" + sha256: abd7625e16f51f554ea244d090292945ec4d4be7bfbaf2ec8cccea568919d334 url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.3.3" deep_collection: dependency: "direct main" description: @@ -189,18 +189,18 @@ packages: dependency: "direct main" description: name: dio - sha256: ce75a1b40947fea0a0e16ce73337122a86762e38b982e1ccb909daa3b9bc4197 + sha256: "417e2a6f9d83ab396ec38ff4ea5da6c254da71e4db765ad737a42af6930140b7" url: "https://pub.dev" source: hosted - version: "5.3.2" + version: "5.3.3" dotenv: dependency: "direct main" description: name: dotenv - sha256: e169b516bc7b88801919e1c508772bcb8e3d0d1776a43f74ab692c57e741cd8a + sha256: "379e64b6fc82d3df29461d349a1796ecd2c436c480d4653f3af6872eccbc90e1" url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "4.2.0" effective_dart: dependency: transitive description: @@ -237,10 +237,10 @@ packages: dependency: transitive description: name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted - version: "6.1.4" + version: "7.0.0" fixnum: dependency: transitive description: @@ -274,58 +274,58 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.3" flutter_secure_storage: dependency: "direct main" description: name: flutter_secure_storage - sha256: "98352186ee7ad3639ccc77ad7924b773ff6883076ab952437d20f18a61f0a7c5" + sha256: "22dbf16f23a4bcf9d35e51be1c84ad5bb6f627750565edd70dab70f3ff5fff8f" url: "https://pub.dev" source: hosted - version: "8.0.0" + version: "8.1.0" flutter_secure_storage_linux: dependency: transitive description: name: flutter_secure_storage_linux - sha256: "0912ae29a572230ad52d8a4697e5518d7f0f429052fd51df7e5a7952c7efe2a3" + sha256: "3d5032e314774ee0e1a7d0a9f5e2793486f0dff2dd9ef5a23f4e3fb2a0ae6a9e" url: "https://pub.dev" source: hosted - version: "1.1.3" + version: "1.2.0" flutter_secure_storage_macos: dependency: transitive description: name: flutter_secure_storage_macos - sha256: "083add01847fc1c80a07a08e1ed6927e9acd9618a35e330239d4422cd2a58c50" + sha256: bd33935b4b628abd0b86c8ca20655c5b36275c3a3f5194769a7b3f37c905369c url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.0.1" flutter_secure_storage_platform_interface: dependency: transitive description: name: flutter_secure_storage_platform_interface - sha256: b3773190e385a3c8a382007893d678ae95462b3c2279e987b55d140d3b0cb81b + sha256: "0d4d3a5dd4db28c96ae414d7ba3b8422fd735a8255642774803b2532c9a61d7e" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.0.2" flutter_secure_storage_web: dependency: transitive description: name: flutter_secure_storage_web - sha256: "42938e70d4b872e856e678c423cc0e9065d7d294f45bc41fc1981a4eb4beaffe" + sha256: "30f84f102df9dcdaa2241866a958c2ec976902ebdaa8883fbfe525f1f2f3cf20" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" flutter_secure_storage_windows: dependency: transitive description: name: flutter_secure_storage_windows - sha256: fc2910ec9b28d60598216c29ea763b3a96c401f0ce1d13cdf69ccb0e5c93c3ee + sha256: "38f9501c7cb6f38961ef0e1eacacee2b2d4715c63cc83fe56449c4d3d0b47255" url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.1" flutter_test: dependency: "direct dev" description: flutter @@ -348,10 +348,10 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "83462cfc33dc9680533a7f3a4a6ab60aa94f287db5f4ee6511248c22833c497f" + sha256: "21bf2825311de65501d22e563e3d7605dff57fb5e6da982db785ae5372ff018a" url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.4.5" freezed_annotation: dependency: "direct main" description: @@ -388,10 +388,10 @@ packages: dependency: transitive description: name: google_identity_services_web - sha256: "554748f2478619076128152c58905620d10f9c7fc270ff1d3a9675f9f53838ed" + sha256: "000b7a31e1fa17ee04b6c0553a2b2ea18f9f9352e4dcc0c9fcc785cf10f2484e" url: "https://pub.dev" source: hosted - version: "0.2.1+1" + version: "0.2.2" google_sign_in: dependency: "direct main" description: @@ -572,10 +572,10 @@ packages: dependency: "direct main" description: name: ory_client - sha256: "151372511353601d4afd81213523ea0662be0f754b44b4be17c40c91bf1967cc" + sha256: "2eb2fb2ad8abe8093c970420972e5cb4a932640d031c52cae962dc444e0a7a54" url: "https://pub.dev" source: hosted - version: "1.2.10" + version: "1.2.11" package_config: dependency: transitive description: @@ -596,66 +596,66 @@ packages: dependency: transitive description: name: path_provider - sha256: "909b84830485dbcd0308edf6f7368bc8fd76afa26a270420f34cabea2a6467a0" + sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "5d44fc3314d969b84816b569070d7ace0f1dea04bd94a83f74c4829615d22ad8" + sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72 url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.2.1" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "1b744d3d774e5a879bb76d6cd1ecee2ba2c6960c03b1020cd35212f6aa267ac5" + sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.3.1" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: ba2b77f0c52a33db09fc8caf85b12df691bf28d983e84cf87ff6d693cfa007b3 + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.1" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - sha256: bced5679c7df11190e1ddc35f3222c858f328fff85c3942e46e7f5589bf9eb84 + sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" path_provider_windows: dependency: transitive description: name: path_provider_windows - sha256: ee0e0d164516b90ae1f970bdf29f726f1aa730d7cfc449ecc74c495378b705da + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.1" platform: dependency: transitive description: name: platform - sha256: "57c07bf82207aee366dfaa3867b3164e4f03a238a461a11b0e8a3a510d51203d" + sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.3" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.6" pool: dependency: transitive description: @@ -865,18 +865,18 @@ packages: dependency: transitive description: name: win32 - sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0 + sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3" url: "https://pub.dev" source: hosted - version: "5.0.6" + version: "5.0.9" xdg_directories: dependency: transitive description: name: xdg_directories - sha256: f0c26453a2d47aa4c2570c6a033246a3fc62da2fe23c7ffdd0a7495086dc0247 + sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2" url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.0.3" yaml: dependency: transitive description: