Network tables impl
This commit is contained in:
parent
72610663cc
commit
e38494104b
|
|
@ -2,6 +2,17 @@ library;
|
||||||
|
|
||||||
import "package:nt4/nt4.dart";
|
import "package:nt4/nt4.dart";
|
||||||
|
|
||||||
|
NT4Client ntClient = NT4Client(serverBaseAddress: '10.5.78.2', onConnect: () { print("NT4 Connected"); }, onDisconnect: () { print("NT4 Disconnected"); });
|
||||||
|
|
||||||
|
List<NT4Subscription> nt4Subscriptions = [];
|
||||||
|
|
||||||
NT4Client? ntClient;
|
NT4Subscription subscribe(String topic){
|
||||||
|
|
||||||
|
NT4Subscription subscrip = ntClient.subscribe(topic, NT4SubscriptionOptions());
|
||||||
|
|
||||||
|
nt4Subscriptions.add(subscrip);
|
||||||
|
|
||||||
|
return subscrip;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NT4Topic> nt4Topics = [];
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import './base_card.dart';
|
import './base_card.dart';
|
||||||
|
import 'package:nt4/nt4.dart';
|
||||||
|
import '../globals.dart' as glob;
|
||||||
|
|
||||||
class TextCard extends StatefulWidget {
|
class TextCard extends StatefulWidget {
|
||||||
const TextCard({
|
const TextCard({
|
||||||
super.key,
|
super.key,
|
||||||
required this.cardTitle,
|
required this.cardTitle,
|
||||||
this.ntTopic,
|
this.ntTopic = '',
|
||||||
this.height = 1,
|
this.height = 1,
|
||||||
this.width = 1,
|
this.width = 1,
|
||||||
});
|
});
|
||||||
|
|
@ -20,14 +22,24 @@ class TextCard extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TextCardState extends State<TextCard> {
|
class _TextCardState extends State<TextCard> {
|
||||||
|
String _val = "";
|
||||||
|
|
||||||
|
void setVal( String newVal )
|
||||||
|
{
|
||||||
|
_val = newVal;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
NT4Subscription sub = glob.subscribe(widget.ntTopic!);
|
||||||
|
sub.listen( (data) => setVal(data.toString()) );
|
||||||
|
|
||||||
return BaseCard(
|
return BaseCard(
|
||||||
cardTitle: widget.cardTitle,
|
cardTitle: widget.cardTitle,
|
||||||
width: widget.width,
|
width: widget.width,
|
||||||
height: widget.height,
|
height: widget.height,
|
||||||
children: [
|
children: [
|
||||||
Text("WAHOOOO")
|
Text(_val)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue