mirror of
https://github.com/timokz/flutter-vienna-hackathon-25.git
synced 2025-11-08 21:04:20 +01:00
Compare commits
2 commits
35edff13ef
...
642dddaaa3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
642dddaaa3 | ||
|
|
8967b1698e |
4 changed files with 13 additions and 6 deletions
|
|
@ -22,9 +22,14 @@ class FunmapMgr {
|
||||||
// address by running `ipconfig` on Windows or `ifconfig` on Mac/Linux.
|
// address by running `ipconfig` on Windows or `ifconfig` on Mac/Linux.
|
||||||
// You can set the variable when running or building your app like this:
|
// 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/`
|
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:wien_talks_flutter/helper/funmap_mgr.dart';
|
||||||
import 'package:wien_talks_flutter/helper/go_router.dart';
|
import 'package:wien_talks_flutter/helper/go_router.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
FunmapMgr();
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ class AddQuoteFab extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FloatingActionButton(onPressed: () {
|
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));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ class QuoteEndpoint extends Endpoint {
|
||||||
throw Exception('Quote not found');
|
throw Exception('Quote not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only for dev
|
|
||||||
Future<List<Quote>> getAllQuotes(Session session) async {
|
Future<List<Quote>> getAllQuotes(Session session) async {
|
||||||
final quotes = await Quote.db.find(session);
|
final quotes = await Quote.db.find(session);
|
||||||
return quotes;
|
return quotes;
|
||||||
|
|
@ -66,7 +65,7 @@ class QuoteEndpoint extends Endpoint {
|
||||||
}) async* {
|
}) async* {
|
||||||
if (limit <= 0 || limit > 500) limit = 200;
|
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) {
|
await for (final Quote quote in quoteStream) {
|
||||||
yield quote;
|
yield quote;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue