diff --git a/.env.development b/.env.development new file mode 100644 index 00000000..e77609dc --- /dev/null +++ b/.env.development @@ -0,0 +1,2 @@ +ENV_NAME=development +BASE_URL=https://syncrow-dev.azurewebsites.net \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 00000000..4e9dcb81 --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +ENV_NAME=production +BASE_URL=https://syncrow-staging.azurewebsites.net \ No newline at end of file diff --git a/.env.staging b/.env.staging new file mode 100644 index 00000000..9565b426 --- /dev/null +++ b/.env.staging @@ -0,0 +1,2 @@ +ENV_NAME=staging +BASE_URL=https://syncrow-staging.azurewebsites.net \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..b6f83bdc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,61 @@ +{ + "configurations": [ + + { + + "name": "DEVELOPMENT", + + "request": "launch", + + "type": "dart", + + "args": [ + + "--dart-define", + + "FLAVOR=development" + + ], + + "flutterMode": "debug" + + },{ + + "name": "STAGING", + + "request": "launch", + + "type": "dart", + + "args": [ + + "--dart-define", + + "FLAVOR=staging" + + ], + + "flutterMode": "debug" + + },{ + + "name": "PRODUCTION", + + "request": "launch", + + "type": "dart", + + "args": [ + + "--dart-define", + + "FLAVOR=production" + + ], + + "flutterMode": "debug" + + }, + + ] +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index b4fcb72d..eeaa4685 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart'; import 'package:syncrow_web/pages/home/bloc/home_bloc.dart'; import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart'; @@ -11,8 +12,12 @@ import 'package:syncrow_web/utils/constants/routes_const.dart'; import 'package:syncrow_web/utils/theme/theme.dart'; Future main() async { - WidgetsFlutterBinding.ensureInitialized(); - initialSetup(); + try { + const environment = String.fromEnvironment('FLAVOR', defaultValue: 'production'); + await dotenv.load(fileName: '.env.$environment'); + WidgetsFlutterBinding.ensureInitialized(); + initialSetup(); + } catch (_) {} runApp(MyApp()); } diff --git a/lib/pages/space_management/spaseManagementIcon.dart b/lib/pages/space_management/spaseManagementIcon.dart deleted file mode 100644 index 510b90b9..00000000 --- a/lib/pages/space_management/spaseManagementIcon.dart +++ /dev/null @@ -1,16 +0,0 @@ - - - -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -class SpaseManagementicon extends StatelessWidget { - const SpaseManagementicon({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Container(), - ); - } -} diff --git a/lib/utils/constants/api_const.dart b/lib/utils/constants/api_const.dart index 2d85a7f5..5d24b501 100644 --- a/lib/utils/constants/api_const.dart +++ b/lib/utils/constants/api_const.dart @@ -1,41 +1,35 @@ -abstract class ApiEndpoints { - static const String baseUrl = 'https://syncrow-dev.azurewebsites.net'; - // static const String baseUrl = 'http://100.107.182.63:4001'; //Localhost -//https://syncrow-staging.azurewebsites.net -////////////////////////////////////// Authentication /////////////////////////////// - static const String signUp = '$baseUrl/authentication/user/signup'; - static const String login = '$baseUrl/authentication/user/login'; - static const String forgetPassword = - '$baseUrl/authentication/user/forget-password'; - static const String sendOtp = '$baseUrl/authentication/user/send-otp'; - static const String verifyOtp = '$baseUrl/authentication/user/verify-otp'; - static const String getRegion = '$baseUrl/region'; - static const String visitorPassword = '$baseUrl/visitor-password'; - static const String getDevices = '$baseUrl/visitor-password/devices'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; - static const String sendOnlineOneTime = - '$baseUrl/visitor-password/temporary-password/online/one-time'; +abstract class ApiEndpoints { + static String baseUrl = dotenv.env['BASE_URL'] ?? ''; + static const String signUp = '/authentication/user/signup'; + static const String login = '/authentication/user/login'; + static const String forgetPassword = '/authentication/user/forget-password'; + static const String sendOtp = '/authentication/user/send-otp'; + static const String verifyOtp = '/authentication/user/verify-otp'; + static const String getRegion = '/region'; + static const String visitorPassword = '/visitor-password'; + static const String getDevices = '/visitor-password/devices'; + + static const String sendOnlineOneTime = '/visitor-password/temporary-password/online/one-time'; static const String sendOnlineMultipleTime = - '$baseUrl/visitor-password/temporary-password/online/multiple-time'; + '/visitor-password/temporary-password/online/multiple-time'; //offline Password - static const String sendOffLineOneTime = - '$baseUrl/visitor-password/temporary-password/offline/one-time'; + static const String sendOffLineOneTime = '/visitor-password/temporary-password/offline/one-time'; static const String sendOffLineMultipleTime = - '$baseUrl/visitor-password/temporary-password/offline/multiple-time'; + '/visitor-password/temporary-password/offline/multiple-time'; - static const String getUser = '$baseUrl/user/{userUuid}'; + static const String getUser = '/user/{userUuid}'; ////// Devices Management //////////////// - static const String getAllDevices = '$baseUrl/device'; - static const String getDeviceStatus = - '$baseUrl/device/{uuid}/functions/status'; + static const String getAllDevices = '/device'; + static const String getDeviceStatus = '/device/{uuid}/functions/status'; - static const String deviceControl = '$baseUrl/device/{uuid}/control'; + static const String deviceControl = '/device/{uuid}/control'; static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices'; static const String openDoorLock = '/door-lock/open/{doorLockUuid}'; - static const String getDeviceLogs = - '$baseUrl/device/report-logs/{uuid}?code={code}'; + static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}'; } diff --git a/pubspec.lock b/pubspec.lock index 3da608f2..8b9df6d6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -150,6 +150,14 @@ packages: url: "https://pub.dev" source: hosted version: "8.1.5" + flutter_dotenv: + dependency: "direct main" + description: + name: flutter_dotenv + sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77" + url: "https://pub.dev" + source: hosted + version: "5.1.0" flutter_lints: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index ea0138ea..d187cf1a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,8 @@ dependencies: go_router: intl: ^0.19.0 dropdown_search: ^5.0.6 + flutter_dotenv: ^5.1.0 + dev_dependencies: flutter_test: @@ -77,6 +79,9 @@ flutter: - assets/icons/ - assets/images/ - assets/ + - .env.development + - .env.staging + - .env.production # An image asset can refer to one or more resolution-specific "variants", see