diff --git a/apps/flutter_parent/lib/screens/pairing/pairing_util.dart b/apps/flutter_parent/lib/screens/pairing/pairing_util.dart index 2acfcb664e..6f2f704029 100644 --- a/apps/flutter_parent/lib/screens/pairing/pairing_util.dart +++ b/apps/flutter_parent/lib/screens/pairing/pairing_util.dart @@ -21,6 +21,7 @@ import 'package:flutter_parent/screens/pairing/pairing_code_dialog.dart'; import 'package:flutter_parent/utils/design/canvas_icons.dart'; import 'package:flutter_parent/utils/design/parent_colors.dart'; import 'package:flutter_parent/utils/quick_nav.dart'; +import 'package:flutter_parent/utils/remote_config_utils.dart'; import 'package:flutter_parent/utils/service_locator.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -37,7 +38,7 @@ class PairingUtil { Text(L10n(context).addStudentWith, style: Theme.of(context).textTheme.caption), SizedBox(height: 12), _pairingCode(context, onSuccess), - if (ApiPrefs.getCameraCount() != 0) _qrCode(context, onSuccess), + if (_isQRPairingEnabled()) _qrCode(context, onSuccess), ], ); }, @@ -88,3 +89,8 @@ class PairingUtil { class StudentAddedNotifier extends ChangeNotifier { void notify() => notifyListeners(); } + +bool _isQRPairingEnabled() { + return RemoteConfigUtils.getStringValue(RemoteConfigParams.QR_PAIR_OBSERVER_ENABLED).toLowerCase() == 'true' && + (ApiPrefs.getCameraCount() != null && ApiPrefs.getCameraCount() != 0); +} diff --git a/apps/flutter_parent/lib/utils/remote_config_utils.dart b/apps/flutter_parent/lib/utils/remote_config_utils.dart index 06a48226a6..dea24fdbf1 100644 --- a/apps/flutter_parent/lib/utils/remote_config_utils.dart +++ b/apps/flutter_parent/lib/utils/remote_config_utils.dart @@ -22,6 +22,7 @@ enum RemoteConfigParams { MOBILE_VERIFY_BETA_ENABLED, QR_LOGIN_ENABLED_PARENT, QR_ACCOUNT_CREATION_ENABLED_PARENT, + QR_PAIR_OBSERVER_ENABLED, } class RemoteConfigUtils { @@ -123,6 +124,8 @@ class RemoteConfigUtils { return 'mobile_verify_beta_enabled'; case RemoteConfigParams.QR_ACCOUNT_CREATION_ENABLED_PARENT: return 'qr_account_creation_enabled'; + case RemoteConfigParams.QR_PAIR_OBSERVER_ENABLED: + return 'qr_pair_observer_enabled'; default: return ''; } diff --git a/apps/flutter_parent/test/screens/pairing/pairing_util_test.dart b/apps/flutter_parent/test/screens/pairing/pairing_util_test.dart index ebdb8dc6d2..3c3cd7411f 100644 --- a/apps/flutter_parent/test/screens/pairing/pairing_util_test.dart +++ b/apps/flutter_parent/test/screens/pairing/pairing_util_test.dart @@ -22,6 +22,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import '../../utils/accessibility_utils.dart'; +import '../../utils/platform_config.dart'; import '../../utils/test_app.dart'; import '../../utils/test_helpers/mock_helpers.dart'; @@ -34,7 +35,9 @@ void main() { locator.registerLazySingleton(() => nav); }); - setUp(() { + setUp(() async { + final mockRemoteConfig = setupMockRemoteConfig(valueSettings: {'qr_pair_observer_enabled': 'true'}); + await setupPlatformChannels(config: PlatformConfig(initRemoteConfig: mockRemoteConfig)); reset(nav); });