Load Flutter runtime config from Vault
Build and deploy Flutter Web / build (push) Successful in 6m25s
Build and deploy Flutter Web / build (push) Successful in 6m25s
This commit is contained in:
@@ -15,16 +15,17 @@ import '../../../app/router/app_router.dart';
|
||||
import '../../../app/theme/mapflow_theme.dart';
|
||||
import '../../../shared/auth/telegram_login_button.dart';
|
||||
import '../../../shared/auth/telegram_session.dart' as telegram_session;
|
||||
import '../../../shared/runtime_config/runtime_config.dart' as runtime_config;
|
||||
import '../application/place_cubit.dart';
|
||||
import '../data/auth_repository.dart';
|
||||
import '../data/places_repository.dart';
|
||||
import '../domain/place_models.dart';
|
||||
import 'widgets/place_photo_card.dart';
|
||||
|
||||
const _mapboxStyle = String.fromEnvironment(
|
||||
'MAPBOX_STYLE',
|
||||
defaultValue: 'mapbox/standard',
|
||||
);
|
||||
String get _mapboxStyle {
|
||||
final style = runtime_config.mapboxStyle();
|
||||
return style.isEmpty ? 'mapbox/standard' : style;
|
||||
}
|
||||
|
||||
class MapflowShell extends StatelessWidget {
|
||||
const MapflowShell({super.key});
|
||||
|
||||
+4
-4
@@ -4,13 +4,13 @@ import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart' as mbx;
|
||||
|
||||
import 'app/app.dart';
|
||||
import 'shared/auth/telegram_session.dart' as telegram_session;
|
||||
|
||||
const _mapboxAccessToken = String.fromEnvironment('MAPBOX_ACCESS_TOKEN');
|
||||
import 'shared/runtime_config/runtime_config.dart' as runtime_config;
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
if (_mapboxAccessToken.isNotEmpty) {
|
||||
mbx.MapboxOptions.setAccessToken(_mapboxAccessToken);
|
||||
final mapboxAccessToken = runtime_config.mapboxAccessToken();
|
||||
if (mapboxAccessToken.isNotEmpty) {
|
||||
mbx.MapboxOptions.setAccessToken(mapboxAccessToken);
|
||||
}
|
||||
usePathUrlStrategy();
|
||||
telegram_session.configureTelegramWebApp();
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export 'runtime_config_stub.dart'
|
||||
if (dart.library.js_interop) 'runtime_config_web.dart';
|
||||
@@ -0,0 +1,3 @@
|
||||
String mapboxAccessToken() => '';
|
||||
|
||||
String mapboxStyle() => '';
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'dart:js_interop';
|
||||
|
||||
@JS('__MAPFLOW_CONFIG__')
|
||||
external _MapflowConfig? get _config;
|
||||
|
||||
extension type _MapflowConfig(JSObject _) implements JSObject {
|
||||
external JSString? get mapboxAccessToken;
|
||||
external JSString? get mapboxStyle;
|
||||
}
|
||||
|
||||
String mapboxAccessToken() => _config?.mapboxAccessToken?.toDart ?? '';
|
||||
|
||||
String mapboxStyle() => _config?.mapboxStyle?.toDart ?? '';
|
||||
Reference in New Issue
Block a user