Compare commits

...

2 commits

Author SHA1 Message Date
tk
642dddaaa3 type quote stream 2025-08-16 17:18:01 +02:00
tk
8967b1698e move client instantiation into main 2025-08-16 17:13:49 +02:00
4 changed files with 13 additions and 6 deletions

View file

@ -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();
}
}

View file

@ -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());
}

View file

@ -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));
});
}
}

View file

@ -54,7 +54,6 @@ class QuoteEndpoint extends Endpoint {
throw Exception('Quote not found');
}
// Only for dev
Future<List<Quote>> getAllQuotes(Session session) async {
final quotes = await Quote.db.find(session);
return quotes;
@ -66,7 +65,7 @@ class QuoteEndpoint extends Endpoint {
}) async* {
if (limit <= 0 || limit > 500) limit = 200;
final quoteStream = session.messages.createStream('quotes');
final quoteStream = session.messages.createStream<Quote>('quotes');
await for (final Quote quote in quoteStream) {
yield quote;