Skip to content

Instantly share code, notes, and snippets.

@mondoktamas
Created December 1, 2021 13:06
Show Gist options
  • Save mondoktamas/4906773aa1c982a3bc96cb1c98060f12 to your computer and use it in GitHub Desktop.
Save mondoktamas/4906773aa1c982a3bc96cb1c98060f12 to your computer and use it in GitHub Desktop.
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