diff --git a/assets/ic_cast0_24dp.svg b/assets/ic_cast0_24dp.svg
new file mode 100644
index 0000000..d069ffe
--- /dev/null
+++ b/assets/ic_cast0_24dp.svg
@@ -0,0 +1,22 @@
+
+
\ No newline at end of file
diff --git a/assets/ic_cast1_24dp.svg b/assets/ic_cast1_24dp.svg
new file mode 100644
index 0000000..46b0c1b
--- /dev/null
+++ b/assets/ic_cast1_24dp.svg
@@ -0,0 +1,22 @@
+
+
\ No newline at end of file
diff --git a/assets/ic_cast2_24dp.svg b/assets/ic_cast2_24dp.svg
new file mode 100644
index 0000000..413d861
--- /dev/null
+++ b/assets/ic_cast2_24dp.svg
@@ -0,0 +1,22 @@
+
+
\ No newline at end of file
diff --git a/assets/ic_cast_24dp.svg b/assets/ic_cast_24dp.svg
new file mode 100644
index 0000000..9787dd8
--- /dev/null
+++ b/assets/ic_cast_24dp.svg
@@ -0,0 +1,19 @@
+
+
\ No newline at end of file
diff --git a/assets/ic_cast_connected_24dp.svg b/assets/ic_cast_connected_24dp.svg
new file mode 100644
index 0000000..2bbb393
--- /dev/null
+++ b/assets/ic_cast_connected_24dp.svg
@@ -0,0 +1,19 @@
+
+
\ No newline at end of file
diff --git a/example/lib/main.dart b/example/lib/main.dart
index d36b8b6..ee068b6 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_cast_framework/cast/CastContext.dart';
+import 'package:flutter_cast_framework/cast/widget/CastButton.dart';
import 'package:flutter_cast_framework/flutter_cast_framework.dart';
void main() => runApp(MyApp());
@@ -32,7 +33,12 @@ class _MyAppState extends State {
title: const Text('Cast plugin example app'),
),
body: Center(
- child: Text('Cast State: $_castState'),
+ child: Column(
+ children: [
+ Text('Cast State: $_castState'),
+ CastButton()
+ ],
+ )
),
),
);
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 2359ed9..2e7f787 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -29,6 +29,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
+ convert:
+ dependency: transitive
+ description:
+ name: convert
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.1"
cupertino_icons:
dependency: "direct main"
description:
@@ -48,6 +55,13 @@ packages:
relative: true
source: path
version: "0.0.1"
+ flutter_svg:
+ dependency: transitive
+ description:
+ name: flutter_svg
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.14.3"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -74,6 +88,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
+ path_drawing:
+ dependency: transitive
+ description:
+ name: path_drawing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.4.1"
+ path_parsing:
+ dependency: transitive
+ description:
+ name: path_parsing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.4"
pedantic:
dependency: transitive
description:
@@ -81,6 +109,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
+ petitparser:
+ dependency: transitive
+ description:
+ name: petitparser
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.4.0"
quiver:
dependency: transitive
description:
@@ -149,5 +184,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
+ xml:
+ dependency: transitive
+ description:
+ name: xml
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.5.0"
sdks:
- dart: ">=2.2.2 <3.0.0"
+ dart: ">=2.4.0 <3.0.0"
+ flutter: ">=1.5.9-pre.94 <2.0.0"
diff --git a/lib/cast/widget/CastButton.dart b/lib/cast/widget/CastButton.dart
new file mode 100644
index 0000000..d634537
--- /dev/null
+++ b/lib/cast/widget/CastButton.dart
@@ -0,0 +1,12 @@
+import 'package:flutter/widgets.dart';
+import 'package:flutter_cast_framework/cast/widget/CastIcon.dart';
+
+class CastButton extends StatelessWidget {
+ @override
+ Widget build(BuildContext context) {
+ return GestureDetector(
+ child: CastIcon(),
+ onTap: () => debugPrint("Clicked"),
+ );
+ }
+}
diff --git a/lib/cast/widget/CastIcon.dart b/lib/cast/widget/CastIcon.dart
new file mode 100644
index 0000000..80e0a76
--- /dev/null
+++ b/lib/cast/widget/CastIcon.dart
@@ -0,0 +1,64 @@
+import 'package:flutter/widgets.dart';
+import 'package:flutter_cast_framework/cast/CastContext.dart';
+import 'package:flutter_cast_framework/flutter_cast_framework.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+
+class CastIcon extends StatefulWidget {
+ @override
+ _CastIconState createState() => _CastIconState();
+}
+
+class _CastIconState extends State {
+ static const _connectingAssetNameList = {
+ 2: "assets/ic_cast_24dp.svg",
+ 3: "assets/ic_cast1_24dp.svg",
+ 4: "assets/ic_cast_connected_24dp.svg",
+ };
+
+ CastState _castState = CastState.unavailable;
+
+ CastState get castState => _castState;
+
+ @override
+ void initState() {
+ super.initState();
+
+ FlutterCastFramework.castContext.state.addListener(_onCastStateChanged);
+ }
+
+ void _onCastStateChanged() {
+ setState(() {
+ _castState = FlutterCastFramework.castContext.state.value;
+ });
+ }
+
+ Widget getEmpty() => Container();
+
+ Widget getButton() {
+ int stateIndex = FlutterCastFramework.castContext.state.value.index;
+ String assetName = _connectingAssetNameList[stateIndex];
+ return SvgPicture.asset(
+ assetName,
+ package: 'flutter_cast_framework',
+ semanticsLabel: 'Cast Button',
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ switch (_castState) {
+ case CastState.unavailable:
+ return getEmpty();
+
+ case CastState.unconnected:
+ case CastState.connecting:
+ case CastState.connected:
+ return getButton();
+
+ case CastState.default_state:
+ default:
+ debugPrint("State not handled: $_castState");
+ return getEmpty();
+ }
+ }
+}
diff --git a/pubspec.lock b/pubspec.lock
index aebdafa..8f013df 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -29,11 +29,25 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
+ convert:
+ dependency: transitive
+ description:
+ name: convert
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.1"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
+ flutter_svg:
+ dependency: "direct main"
+ description:
+ name: flutter_svg
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.14.3"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -60,6 +74,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
+ path_drawing:
+ dependency: transitive
+ description:
+ name: path_drawing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.4.1"
+ path_parsing:
+ dependency: transitive
+ description:
+ name: path_parsing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.4"
pedantic:
dependency: transitive
description:
@@ -67,6 +95,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
+ petitparser:
+ dependency: transitive
+ description:
+ name: petitparser
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.4.0"
quiver:
dependency: transitive
description:
@@ -135,5 +170,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
+ xml:
+ dependency: transitive
+ description:
+ name: xml
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.5.0"
sdks:
- dart: ">=2.2.2 <3.0.0"
+ dart: ">=2.4.0 <3.0.0"
+ flutter: ">=1.5.9-pre.94 <2.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 639ff21..aed25c2 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -10,6 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
+ flutter_svg: ^0.14.3
dev_dependencies:
flutter_test:
@@ -39,6 +40,9 @@ flutter:
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
+ assets:
+ - assets/
+
# To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a