You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6KB

  1. import 'app_environment.dart';
  2. class FlavorValues {
  3. FlavorValues({
  4. required this.server,
  5. required this.baseUrl,
  6. required this.appName,
  7. required this.LocalDBName,
  8. });
  9. final String server;
  10. final String baseUrl;
  11. final String appName;
  12. final String LocalDBName;
  13. }
  14. abstract class FlavorConfig {
  15. static AppEnvironment? _flavor;
  16. static FlavorValues? _values;
  17. static void set(AppEnvironment flavor, FlavorValues values) {
  18. _flavor = flavor;
  19. _values = values;
  20. }
  21. static bool isInitialized() => _flavor != null;
  22. static bool isDev() => _flavor! == AppEnvironment.DEV;
  23. static bool isTest() => _flavor! == AppEnvironment.TEST;
  24. static bool isProduction() => _flavor! == AppEnvironment.PROD;
  25. static FlavorValues get values => _values!;
  26. }
  27. void setFlavorDevelopment() {
  28. FlavorConfig.set(
  29. AppEnvironment.DEV,
  30. FlavorValues(
  31. appName: '[DEV] Thaco Agri',
  32. server: 'https://dev-trangtraibo.aristqnu.com/',
  33. baseUrl: 'https://dev-trangtraibo.aristqnu.com/',
  34. LocalDBName: 'AppLocalStorage-DEV',
  35. ),
  36. );
  37. }
  38. void setFlavorTest() {
  39. FlavorConfig.set(
  40. AppEnvironment.TEST,
  41. FlavorValues(
  42. appName: 'Thaco Agri',
  43. server: 'https://test-trangtraibo.aristqnu.com/',
  44. baseUrl: 'https://test-trangtraibo.aristqnu.com/',
  45. LocalDBName: 'AppLocalStorage-TEST',
  46. ),
  47. );
  48. }
  49. void setFlavorProduction() {
  50. FlavorConfig.set(
  51. AppEnvironment.PROD,
  52. FlavorValues(
  53. appName: 'Trang Trai Bo',
  54. server: 'https://trangtraibo.thacoagri.com.vn/',
  55. baseUrl: 'https://trangtraibo.thacoagri.com.vn/',
  56. LocalDBName: 'AppLocalStorage',
  57. ),
  58. );
  59. }