From 8967b1698e55aa8e992c4fbc13d6eb80aad46552 Mon Sep 17 00:00:00 2001 From: tk Date: Sat, 16 Aug 2025 17:13:49 +0200 Subject: [PATCH] move client instantiation into main --- .../wien_talks_flutter/lib/helper/funmap_mgr.dart | 11 ++++++++--- wien_talks/wien_talks_flutter/lib/main.dart | 2 ++ .../wien_talks_flutter/lib/widgets/add-quote-fab.dart | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wien_talks/wien_talks_flutter/lib/helper/funmap_mgr.dart b/wien_talks/wien_talks_flutter/lib/helper/funmap_mgr.dart index 31a211c..9ed543c 100644 --- a/wien_talks/wien_talks_flutter/lib/helper/funmap_mgr.dart +++ b/wien_talks/wien_talks_flutter/lib/helper/funmap_mgr.dart @@ -22,9 +22,14 @@ class FunmapMgr { // address by running `ipconfig` on Windows or `ifconfig` on Mac/Linux. // You can set the variable when running or building your app like this: // E.g. `flutter run --dart-define=SERVER_URL=https://api.example.com/` - const serverUrlFromEnv = String.fromEnvironment('SERVER_URL'); - final serverUrl = serverUrlFromEnv.isEmpty ? 'http://localhost:8080/' : serverUrlFromEnv; - client = Client(serverUrl, connectionTimeout: const Duration(seconds: 5))..connectivityMonitor = FlutterConnectivityMonitor(); + const serverUrlFromEnv = String.fromEnvironment('SERVER_URL'); + final serverUrl = + serverUrlFromEnv.isEmpty ? 'http://$localhost:8080/' : serverUrlFromEnv; + + client = Client(serverUrl, connectionTimeout: const Duration(seconds: 5)) + ..connectivityMonitor = FlutterConnectivityMonitor(); + + client.openStreamingConnection(); } } diff --git a/wien_talks/wien_talks_flutter/lib/main.dart b/wien_talks/wien_talks_flutter/lib/main.dart index 4438c2a..9e7d98f 100644 --- a/wien_talks/wien_talks_flutter/lib/main.dart +++ b/wien_talks/wien_talks_flutter/lib/main.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:wien_talks_flutter/helper/funmap_mgr.dart'; import 'package:wien_talks_flutter/helper/go_router.dart'; void main() { + FunmapMgr(); runApp(const MyApp()); } diff --git a/wien_talks/wien_talks_flutter/lib/widgets/add-quote-fab.dart b/wien_talks/wien_talks_flutter/lib/widgets/add-quote-fab.dart index 1c58ee1..054493b 100644 --- a/wien_talks/wien_talks_flutter/lib/widgets/add-quote-fab.dart +++ b/wien_talks/wien_talks_flutter/lib/widgets/add-quote-fab.dart @@ -10,7 +10,8 @@ class AddQuoteFab extends StatelessWidget { @override Widget build(BuildContext context) { return FloatingActionButton(onPressed: () { - FunmapMgr().client.quote.createQuote(CreateQuoteRequest(text: 'Quote Text', lat: 22, lng: 140)); + FunmapMgr().client.quote.createQuote( + CreateQuoteRequest(text: 'Quote Text', lat: 22, lng: 140)); }); } }