Created
December 1, 2021 13:06
-
-
Save mondoktamas/4906773aa1c982a3bc96cb1c98060f12 to your computer and use it in GitHub Desktop.
This file contains 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 'package:auto_route/auto_route.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'package:skogluft/application/di/injection.dart'; | |
import 'package:skogluft/application/presentation/bloc/bloc.dart'; | |
import 'package:skogluft/application/presentation/deeplink/dynamic_links_handler.dart'; | |
import 'package:skogluft/application/presentation/router/router.gr.dart'; | |
class AuthScopePage extends StatelessWidget { | |
const AuthScopePage({final Key? key}) : super(key: key); | |
@override | |
Widget build(final BuildContext context) => BlocConsumer<AuthBloc, AuthState>( | |
listener: (context, state) async { | |
if (state is AuthorizedState) { | |
await setupAuthorizedScope(); | |
} else if (state is UnauthorizedState) { | |
await setupUnauthorizedScope(); | |
} | |
await getIt<DynamicLinksHandler>().initDynamicLink(); | |
}, | |
builder: (context, state) { | |
if (state is AuthorizedState) { | |
return AutoRouter.declarative(routes: (_) => [const AuthorizedRoute()]); | |
} else if (state is UnauthorizedState) { | |
return AutoRouter.declarative(routes: (_) => [const UnauthorizedRoute()]); | |
} else { | |
return AutoRouter.declarative(routes: (_) => [const SplashRoute()]); | |
} | |
}, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment