Make the base urls defineable by environment variable.
All checks were successful
Build Flutter Web and Docker Image for Local Registry / Build Flutter Web App (push) Successful in 3m13s
All checks were successful
Build Flutter Web and Docker Image for Local Registry / Build Flutter Web App (push) Successful in 3m13s
This commit is contained in:
parent
d746a3ca19
commit
ce211a2eb7
@ -3,12 +3,16 @@ import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
import 'profile_screen.dart';
|
||||
import 'shared_preferences_provider.dart';
|
||||
import 'status_page.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
// Load environment variables
|
||||
await dotenv.load();
|
||||
runApp(
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => SharedPreferencesProvider(),
|
||||
|
@ -6,6 +6,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
import 'shared_preferences_provider.dart';
|
||||
|
||||
@ -24,6 +25,8 @@ class StatusPageState extends State<StatusPage> with WidgetsBindingObserver {
|
||||
late StreamController<dynamic> controller;
|
||||
List<Map<String, dynamic>> messages = [];
|
||||
final Map<String, ImageProvider> _imageCache = {};
|
||||
final wsBaseUrl = dotenv.env['WS_BASE_URL'];
|
||||
final restBaseUrl = dotenv.env['REST_BASE_URL'];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -34,8 +37,7 @@ class StatusPageState extends State<StatusPage> with WidgetsBindingObserver {
|
||||
|
||||
void _initializeWebSocket() {
|
||||
channel = WebSocketChannel.connect(
|
||||
Uri.parse('wss://api.pogdark.com:8889/ws'),
|
||||
//Uri.parse('ws://localhost:8080/ws'),
|
||||
Uri.parse('$wsBaseUrl/ws'),
|
||||
);
|
||||
|
||||
controller = StreamController<dynamic>.broadcast();
|
||||
@ -89,7 +91,7 @@ class StatusPageState extends State<StatusPage> with WidgetsBindingObserver {
|
||||
};
|
||||
|
||||
//final url = Uri.parse('http://localhost:8080/set');
|
||||
final url = Uri.parse('https://api.pogdark.com:8889/set');
|
||||
final url = Uri.parse('$restBaseUrl/set');
|
||||
try {
|
||||
final response = await http.post(
|
||||
url,
|
||||
|
@ -38,6 +38,7 @@ dependencies:
|
||||
uuid: ^4.4.2
|
||||
fluttertoast: ^8.2.8
|
||||
http: ^1.2.2
|
||||
flutter_dotenv: ^5.0.3
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
|
Loading…
Reference in New Issue
Block a user