feat: initialize new Flutter project with core feature structure and cross-platform configuration

This commit is contained in:
Ümit Tunç
2026-04-29 21:58:29 +03:00
parent 859460434d
commit 34c5b44ddf
149 changed files with 6882 additions and 0 deletions
@@ -0,0 +1,50 @@
import 'dart:async';
import 'package:nsd/nsd.dart';
abstract class IDiscoveryService {
Future<void> registerService(int port);
Future<void> stopRegistration();
Stream<List<Service>> discoverServices();
}
class DiscoveryService implements IDiscoveryService {
Registration? _registration;
final String _serviceType = '_http._tcp';
final String _serviceName = 'FastWatcher';
@override
Future<void> registerService(int port) async {
_registration = await register(
Service(
name: _serviceName,
type: _serviceType,
port: port,
),
);
}
@override
Future<void> stopRegistration() async {
if (_registration != null) {
await unregister(_registration!);
_registration = null;
}
}
@override
Stream<List<Service>> discoverServices() async* {
final discovery = await startDiscovery(_serviceType);
final controller = StreamController<List<Service>>();
void update() {
controller.add(discovery.services);
}
discovery.addListener(update);
yield* controller.stream;
// Note: In a real app, handle disposal
}
}