|
|
|
@ -1,4 +1,5 @@
|
|
|
|
import 'dart:developer';
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:connectivity/connectivity.dart';
|
|
|
|
import 'package:connectivity/connectivity.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
@ -43,10 +44,24 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
super.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future printIps() async {
|
|
|
|
|
|
|
|
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
|
|
|
|
|
|
|
|
print("interface: ${interface.name}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (interface.name == "eth0") {
|
|
|
|
|
|
|
|
for (var address in interface.addresses) {
|
|
|
|
|
|
|
|
DEVICE_IP = address.address;
|
|
|
|
|
|
|
|
log('${address.address} ${address.type.name}');
|
|
|
|
|
|
|
|
log(DEVICE_IP);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
listenNetworkConnectivity();
|
|
|
|
listenNetworkConnectivity();
|
|
|
|
|
|
|
|
printIps();
|
|
|
|
if (!signalRHelper.getConnectionState()) {
|
|
|
|
if (!signalRHelper.getConnectionState()) {
|
|
|
|
signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -84,30 +99,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// Row(
|
|
|
|
Padding(
|
|
|
|
// children: [
|
|
|
|
padding: const EdgeInsets.only(right: 20),
|
|
|
|
// const SizedBox(width: 60),
|
|
|
|
child: Text(DEVICE_IP, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() *2.6)),
|
|
|
|
// SizedBox(
|
|
|
|
),
|
|
|
|
// width: 200,
|
|
|
|
|
|
|
|
// child: TextField(
|
|
|
|
|
|
|
|
// controller: controller,
|
|
|
|
|
|
|
|
// )),
|
|
|
|
|
|
|
|
// const SizedBox(width: 30),
|
|
|
|
|
|
|
|
// isLoading
|
|
|
|
|
|
|
|
// ? const CircularProgressIndicator()
|
|
|
|
|
|
|
|
// : ElevatedButton(
|
|
|
|
|
|
|
|
// onPressed: onUpdateIPPressed,
|
|
|
|
|
|
|
|
// child: const Text(
|
|
|
|
|
|
|
|
// "Update IP",
|
|
|
|
|
|
|
|
// style: TextStyle(color: Colors.white),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// style: ElevatedButton.styleFrom(backgroundColor: AppGlobal.appRedColor),
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// const SizedBox(width: 30),
|
|
|
|
|
|
|
|
// Text("IP: $DEVICE_IP", style: const TextStyle(fontWeight: FontWeight.w600)),
|
|
|
|
|
|
|
|
// const SizedBox(width: 20),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|