AuthGuard function Null safety

Widget AuthGuard(
  1. BuildContext context,
  2. Widget widget
)

Guard: protect the access to screens (when the user is not authenticated)

Implementation

Widget AuthGuard(BuildContext context, Widget widget) {
  return BlocBuilder<AuthenticationBloc, AuthenticationState>(
    bloc: resolve<AuthenticationBloc>(),
    builder: (BuildContext context, state) {
      if (state is Uninitialized) return Scaffold(body: Container());
      return (state is Authenticated) ? widget : SignInScreen();
    },
  );
}