Advertisement
FlyFar

check.dart

Jul 25th, 2023
856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.37 KB | Cybersecurity | 0 0
  1. import 'package:shared_preferences/shared_preferences.dart';
  2.  
  3. Future<bool> check() async {
  4.     final prefs = await SharedPreferences.getInstance();
  5.     final String? pas =prefs.getString('redis_pass');
  6.     final String? key = prefs.getString('redis_username');
  7.     final String? url = prefs.getString('redis_location');
  8.     final int? port = prefs.getInt('redis_port');
  9.     if (pas == null || key == null || url == null || port == null) {
  10.         return false;
  11.     } else {
  12.         return true;
  13.     }
  14. }
  15.  
  16. Future<void> newSignIn(
  17.     String pass, String username, String where, String port) async {
  18.   final prefs = await SharedPreferences.getInstance();
  19.   prefs.setString('redis_location', where);
  20.   prefs.setString('redis_pass', pass);
  21.   prefs.setString('redis_username', username);
  22.   prefs.setInt('redis_port', int.parse(port));
  23. }
  24.  
  25. Future<Map<String, dynamic>> getSignIn() async {
  26.   final prefs = await SharedPreferences.getInstance();
  27.   final String? pass = prefs.getString('redis_pass');
  28.   final String? username = prefs.getString('redis_username');
  29.   final String? where = prefs.getString('redis_location');
  30.   final int? port = prefs.getInt('redis_port');
  31.   if (pass == null || username == null || where == null || port == null) {
  32.     throw "null error";
  33.   }
  34.   return {
  35.     'pass': pass,
  36.     'username': username,
  37.     'where': where,
  38.     'port': port,
  39.   };
  40. }
Tags: check
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement