WebRequest.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'dart:async';
  2. import 'package:shared_preferences/shared_preferences.dart';
  3. class WebRequest extends Object {
  4. //
  5. bool ifPrd;
  6. bool ifIos;
  7. Future<Uri> generate(String path, Map<String, dynamic> params) async {
  8. final prefs = await SharedPreferences.getInstance();
  9. String hosts;
  10. String scheme;
  11. int ports;
  12. if (prefs.getBool("ifPrd")) {
  13. hosts = prefs.getString('urlPath_p');
  14. scheme = prefs.getString('scheme_p');
  15. ports = prefs.getInt('ports_p');
  16. } else {
  17. if (prefs.getBool("ifIOS")) {
  18. hosts = prefs.getString('urlPath_ios_d');
  19. scheme = prefs.getString('scheme_ios_d');
  20. ports = prefs.getInt('ports_ios_d');
  21. } else {
  22. hosts = prefs.getString('urlPath_and_d');
  23. scheme = prefs.getString('scheme_and_d');
  24. ports = prefs.getInt('ports_and_d');
  25. }
  26. }
  27. if(prefs.getBool("ifReal_d")){
  28. hosts = prefs.getString('urlPath_real_d');
  29. scheme = prefs.getString('scheme_real_d');
  30. ports = prefs.getInt('ports_real_d');
  31. }
  32. Uri url = Uri(
  33. scheme: scheme, //http https
  34. host: hosts,
  35. port: ports,
  36. path: path,
  37. queryParameters: params);
  38. return url;
  39. }
  40. }