getCurrentRounteAndArgs function
This method is used for the facebook authentication After successful authentication this method returns a FbInfo model FbInfo model includes accesstoken for fb and name of user.
Implementation
// Future<FbInfo?> fbAuthentication() async {
// try {
// final LoginResult result = await FacebookAuth.instance.login(
// permissions: [
// 'email',
// 'openid',
// 'public_profile',
// ],
// );
// if (result.status == LoginStatus.success) {
// final userData = await FacebookAuth.instance.getUserData();
// // _userData = userData;
// final fbToken = result.accessToken!.token;
// final userName = userData['name'];
// return FbInfo(fbToken: fbToken, name: userName);
// }
// return null;
// } catch (error) {
// log(error.toString());
// }
// return null;
// }
// Future<Result<String, Exception>> downloadNetworkFile(String url) async {
// try {
// // directly creating instance because of the dio's interceptor downloading files are getting corrupted
// final Dio client = Dio();
// // Example : https://baseUrl/User_Data.pdf?GoogleAccessId=token
// final fileName = url.split('/').last.split('?').first;
// final documentsDir = (await getApplicationDocumentsDirectory()).path;
// final path = '$documentsDir/$fileName';
// final request = await client.download(
// url,
// path,
// options: Options(
// responseType: ResponseType.bytes,
// followRedirects: false,
// validateStatus: (status) {
// if (status == null) return false;
// return status < 500;
// },
// ),
// );
// final bytes = request.data;
// if (!File(path).existsSync()) {
// final file = File(path);
// final fileWriter = file.openSync(mode: FileMode.write);
// fileWriter.writeFromSync(bytes);
// }
// return Success(path);
// } catch (e) {
// return Failure(Exception(e));
// }
// }
(String?, Object?) getCurrentRounteAndArgs(
GlobalKey<NavigatorState> navigatorKey,
) {
String? currentPath;
Object? args;
navigatorKey.currentState?.popUntil((route) {
currentPath = route.settings.name;
args = route.settings.arguments;
return true;
});
return (currentPath, args);
}