arp_scanner 1.0.3 arp_scanner: ^1.0.3 copied to clipboard
A new flutter plugin project.
example/lib/main.dart
import 'package:arp_scanner/device.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:arp_scanner/arp_scanner.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = '';
@override
void initState() {
super.initState();
ArpScanner.onScanning.listen((Device device) {
setState(() {
_platformVersion =
"${_platformVersion}Mac:${device.mac} ip:${device.ip} hostname:${device.hostname} time:${device.time} vendor:${device.vendor} \n";
});
});
ArpScanner.onScanFinished.listen((List<Device> devices) {
setState(() {
_platformVersion = "${_platformVersion}total: ${devices.length}";
});
});
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.scanner_sharp),
onPressed: () async {
//scan sub net devices
await ArpScanner.scan();
setState(() {
_platformVersion = "";
});
}),
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text(_platformVersion),
),
),
);
}
}