serverpod_live_flutter 0.1.1
serverpod_live_flutter: ^0.1.1 copied to clipboard
Flutter lifecycle support for Serverpod Live channels, collections, and presence.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:serverpod_live_flutter/serverpod_live_flutter.dart';
void main() => runApp(const ExampleApp());
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(home: TodoScreen());
}
}
class TodoScreen extends StatefulWidget {
const TodoScreen({super.key});
@override
State<TodoScreen> createState() => _TodoScreenState();
}
class _TodoScreenState extends State<TodoScreen> {
late final LiveChannelLifecycle _liveLifecycle;
@override
void initState() {
super.initState();
_liveLifecycle = LiveChannelLifecycle();
// Register the screen's LiveChannel, LiveCollection, or LivePresence here.
}
@override
void dispose() {
unawaited(_liveLifecycle.dispose());
super.dispose();
}
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(child: Text('A lifecycle-managed live todo screen')),
);
}
}