flutter_cast_framework_modern/example/lib/main.dart
gianlucaparadise 344c5b6b8a Initial CastContext setup;
CastState handling
2019-11-08 06:52:35 +01:00

40 lines
928 B
Dart

import 'package:flutter/material.dart';
import 'package:flutter_cast_framework/cast/CastContext.dart';
import 'package:flutter_cast_framework/flutter_cast_framework.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
CastState _castState;
@override
void initState() {
super.initState();
FlutterCastFramework.castContext.state.addListener(_onCastStateChanged);
}
void _onCastStateChanged() {
setState(() {
_castState = FlutterCastFramework.castContext.state.value;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Cast plugin example app'),
),
body: Center(
child: Text('Cast State: $_castState'),
),
),
);
}
}