sign in smoothness
This commit is contained in:
@@ -12,14 +12,16 @@ class AuthCheck extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder(
|
return Scaffold(
|
||||||
future: doesSessionExist(),
|
body: FutureBuilder(
|
||||||
builder: (context, snapshot) {
|
future: doesSessionExist(),
|
||||||
if (snapshot.data == true) {
|
builder: (context, snapshot) {
|
||||||
return const Home();
|
if (snapshot.data == true) {
|
||||||
} else {
|
return const Home();
|
||||||
return const SignInOrRegister();
|
} else {
|
||||||
}
|
return const SignInOrRegister();
|
||||||
});
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,25 +55,23 @@ class _AddOrViewPatientState extends State<AddOrViewPatient> {
|
|||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: fetchPatient(),
|
future: fetchPatient(),
|
||||||
builder: (ctx, snapshot) {
|
builder: (ctx, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.done &&
|
||||||
|
snapshot.hasData) {
|
||||||
|
// Extracting data from snapshot object
|
||||||
|
//final data = snapshot.data as String;
|
||||||
|
return PatientView(
|
||||||
|
arguments: PatientViewArguments(
|
||||||
|
widget.arguments.signedInUser,
|
||||||
|
snapshot.requireData,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
widget.arguments.type,
|
||||||
|
));
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return const Mihloadingcircle();
|
return const Mihloadingcircle();
|
||||||
|
} else {
|
||||||
|
return AddPatient(signedInUser: widget.arguments.signedInUser);
|
||||||
}
|
}
|
||||||
// Checking if future is resolved
|
|
||||||
else if (snapshot.connectionState == ConnectionState.done) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
// Extracting data from snapshot object
|
|
||||||
//final data = snapshot.data as String;
|
|
||||||
return PatientView(
|
|
||||||
arguments: PatientViewArguments(
|
|
||||||
widget.arguments.signedInUser,
|
|
||||||
snapshot.requireData,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
widget.arguments.type,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return AddPatient(signedInUser: widget.arguments.signedInUser);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class _RegisterState extends State<Register> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
Navigator.of(context).popAndPushNamed('/home');
|
Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
|
||||||
signUpSuccess();
|
signUpSuccess();
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// successfulSignUp = true;
|
// successfulSignUp = true;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class _SignInState extends State<SignIn> {
|
|||||||
} else {
|
} else {
|
||||||
await signUserIn();
|
await signUserIn();
|
||||||
if (successfulSignIn) {
|
if (successfulSignIn) {
|
||||||
Navigator.of(context).popAndPushNamed('/home');
|
Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user