From 46ef1788fae8af855498eadd5e4bfe04302981e2 Mon Sep 17 00:00:00 2001 From: deakjahn Date: Sat, 20 Mar 2021 15:16:07 +0100 Subject: [PATCH 1/4] Null safety --- CHANGELOG.md | 5 + .../.flutter-plugins-dependencies | 1 + .../ios/Flutter/flutter_export_environment.sh | 14 ++ example/flutter_example/lib/main.dart | 53 ++++-- example/flutter_example/pubspec.lock | 168 ++++++++++++++++++ example/flutter_example/pubspec.yaml | 5 +- lib/src/network_analyzer.dart | 11 +- pubspec.lock | 146 +++++++++++++++ pubspec.yaml | 4 +- 9 files changed, 379 insertions(+), 28 deletions(-) create mode 100644 example/flutter_example/.flutter-plugins-dependencies create mode 100644 example/flutter_example/ios/Flutter/flutter_export_environment.sh create mode 100644 example/flutter_example/pubspec.lock create mode 100644 pubspec.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index a5b4612..2b8bed7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +#Changelog + +## [1.0.0] +* Null safety. + ## [0.2.0] * Two pinging methods: ping ip addresses one by one OR all at once. diff --git a/example/flutter_example/.flutter-plugins-dependencies b/example/flutter_example/.flutter-plugins-dependencies new file mode 100644 index 0000000..9d354e0 --- /dev/null +++ b/example/flutter_example/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"wifi","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\wifi-0.1.5\\\\","dependencies":[]}],"android":[{"name":"wifi","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\wifi-0.1.5\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"wifi","dependencies":[]}],"date_created":"2021-03-20 15:02:06.258763","version":"2.1.0-12.1.pre"} \ No newline at end of file diff --git a/example/flutter_example/ios/Flutter/flutter_export_environment.sh b/example/flutter_example/ios/Flutter/flutter_export_environment.sh new file mode 100644 index 0000000..a95a1d3 --- /dev/null +++ b/example/flutter_example/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=E:\Android\flutter-dev" +export "FLUTTER_APPLICATION_PATH=E:\Android\Projects\ping_discover_network\example\flutter_example" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=lib\main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build\ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=false" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.packages" diff --git a/example/flutter_example/lib/main.dart b/example/flutter_example/lib/main.dart index 293626b..84cbaf2 100644 --- a/example/flutter_example/lib/main.dart +++ b/example/flutter_example/lib/main.dart @@ -1,6 +1,7 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:ping_discover_network/ping_discover_network.dart'; -import 'package:wifi/wifi.dart'; void main() => runApp(MyApp()); @@ -38,12 +39,11 @@ class _MyHomePageState extends State { String ip; try { - ip = await Wifi.ip; + ip = await _getLocalIpAddress(); print('local ip:\t$ip'); } catch (e) { - final snackBar = SnackBar( - content: Text('WiFi is not connected', textAlign: TextAlign.center)); - Scaffold.of(ctx).showSnackBar(snackBar); + final snackBar = SnackBar(content: Text('WiFi is not connected', textAlign: TextAlign.center)); + ScaffoldMessenger.of(ctx).showSnackBar(snackBar); return; } setState(() { @@ -77,12 +77,36 @@ class _MyHomePageState extends State { }); }) ..onError((dynamic e) { - final snackBar = SnackBar( - content: Text('Unexpected exception', textAlign: TextAlign.center)); - Scaffold.of(ctx).showSnackBar(snackBar); + final snackBar = SnackBar(content: Text('Unexpected exception', textAlign: TextAlign.center)); + ScaffoldMessenger.of(ctx).showSnackBar(snackBar); }); } + // https://stackoverflow.com/questions/63514434/flutter-get-local-ip-address-on-android + Future _getLocalIpAddress() async { + final interfaces = await NetworkInterface.list(type: InternetAddressType.IPv4, includeLinkLocal: true); + + try { + // Try VPN connection first + final vpnInterface = interfaces.firstWhere((element) => element.name == 'tun0'); + return vpnInterface.addresses.first.address; + } on StateError { + // Try wlan connection next + try { + final interface = interfaces.firstWhere((element) => element.name == 'wlan0'); + return interface.addresses.first.address; + } catch (ex) { + // Try any other connection next + try { + final interface = interfaces.firstWhere((element) => !(element.name == 'tun0' || element.name == 'wlan0')); + return interface.addresses.first.address; + } catch (ex) { + return ''; + } + } + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -107,15 +131,9 @@ class _MyHomePageState extends State { SizedBox(height: 10), Text('Local ip: $localIp', style: TextStyle(fontSize: 16)), SizedBox(height: 15), - RaisedButton( - child: Text( - '${isDiscovering ? 'Discovering...' : 'Discover'}'), - onPressed: isDiscovering ? null : () => discover(context)), + ElevatedButton(child: Text('${isDiscovering ? 'Discovering...' : 'Discover'}'), onPressed: isDiscovering ? null : () => discover(context)), SizedBox(height: 15), - found >= 0 - ? Text('Found: $found device(s)', - style: TextStyle(fontSize: 16)) - : Container(), + found >= 0 ? Text('Found: $found device(s)', style: TextStyle(fontSize: 16)) : Container(), Expanded( child: ListView.builder( itemCount: devices.length, @@ -132,8 +150,7 @@ class _MyHomePageState extends State { SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Text( diff --git a/example/flutter_example/pubspec.lock b/example/flutter_example/pubspec.lock new file mode 100644 index 0000000..6f88755 --- /dev/null +++ b/example/flutter_example/pubspec.lock @@ -0,0 +1,168 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.10" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + ping_discover_network: + dependency: "direct main" + description: + path: "../.." + relative: true + source: path + version: "1.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.19" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + wifi: + dependency: "direct main" + description: + name: wifi + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" +sdks: + dart: ">=2.12.0 <3.0.0" + flutter: ">=0.1.4" diff --git a/example/flutter_example/pubspec.yaml b/example/flutter_example/pubspec.yaml index 6ee1810..5797a30 100644 --- a/example/flutter_example/pubspec.yaml +++ b/example/flutter_example/pubspec.yaml @@ -4,15 +4,14 @@ description: A new Flutter project. version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter - cupertino_icons: ^0.1.2 + cupertino_icons: ^1.0.2 ping_discover_network: path: ../../ - wifi: ^0.1.5 dev_dependencies: flutter_test: diff --git a/lib/src/network_analyzer.dart b/lib/src/network_analyzer.dart index b806e14..c465499 100644 --- a/lib/src/network_analyzer.dart +++ b/lib/src/network_analyzer.dart @@ -8,11 +8,14 @@ import 'dart:async'; import 'dart:io'; +// ignore_for_file: avoid_classes_with_only_static_members + /// [NetworkAnalyzer] class returns instances of [NetworkAddress]. /// /// Found ip addresses will have [exists] == true field. class NetworkAddress { NetworkAddress(this.ip, this.exists); + bool exists; String ip; } @@ -45,7 +48,7 @@ class NetworkAnalyzer { } // Check if connection timed out or we got one of predefined errors - if (e.osError == null || _errorCodes.contains(e.osError.errorCode)) { + if (e.osError == null || _errorCodes.contains(e.osError!.errorCode)) { yield NetworkAddress(host, false); } else { // Error 23,24: Too many open files in system @@ -83,7 +86,7 @@ class NetworkAnalyzer { } // Check if connection timed out or we got one of predefined errors - if (e.osError == null || _errorCodes.contains(e.osError.errorCode)) { + if (e.osError == null || _errorCodes.contains(e.osError!.errorCode)) { out.sink.add(NetworkAddress(host, false)); } else { // Error 23,24: Too many open files in system @@ -92,9 +95,7 @@ class NetworkAnalyzer { }); } - Future.wait(futures) - .then((sockets) => out.close()) - .catchError((dynamic e) => out.close()); + Future.wait(futures).then((sockets) => out.close()).catchError((dynamic e) => out.close()); return out.stream; } diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..85d5b84 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,146 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.10" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.19" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" +sdks: + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 9c95788..f1a72de 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: ping_discover_network description: Library that allows to ping IP subnet and discover network devices. Could be used to find printers and other devices and services in a local network. -version: 0.2.0+1 +version: 1.0.0 author: Andrey Ushakov homepage: https://github.com/andrey-ushakov/ping_discover_network environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: From fb866bc7006970c44acb746910b7ec1cdc0a92ec Mon Sep 17 00:00:00 2001 From: deakjahn Date: Mon, 24 Jan 2022 17:47:12 +0100 Subject: [PATCH 2/4] Remove .lock --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9d7edcf..c4ce1ac 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ .pub-cache/ .pub/ build/ +*.lock # Android related **/android/**/gradle-wrapper.jar From 0dca660df0cdc66521b559061b244dc54da8a76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor?= Date: Mon, 24 Jan 2022 17:55:45 +0100 Subject: [PATCH 3/4] Remove .lock --- pubspec.lock | 146 --------------------------------------------------- 1 file changed, 146 deletions(-) delete mode 100644 pubspec.lock diff --git a/pubspec.lock b/pubspec.lock deleted file mode 100644 index 85d5b84..0000000 --- a/pubspec.lock +++ /dev/null @@ -1,146 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.5.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.15.0" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.10" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.1" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.19" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" -sdks: - dart: ">=2.12.0 <3.0.0" From c94f4ccce3b843e57f0243445bb0ac00206d0ff8 Mon Sep 17 00:00:00 2001 From: deakjahn Date: Tue, 1 Mar 2022 15:21:58 +0100 Subject: [PATCH 4/4] Changes (local IP) --- README.md | 2 + .../.flutter-plugins-dependencies | 2 +- .../android/app/src/main/AndroidManifest.xml | 20 +-- .../ios/Flutter/flutter_export_environment.sh | 1 - example/flutter_example/lib/main.dart | 3 +- example/flutter_example/pubspec.lock | 129 ++++++++++++++++-- example/flutter_example/pubspec.yaml | 5 +- 7 files changed, 131 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 8fcad2e..8d82dab 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # ping_discover_network +Changed to null safety. + ![Pub](https://img.shields.io/pub/v/ping_discover_network.svg) [Dart](https://dart.dev)/[Flutter](https://flutter.dev) library that allows to ping IP subnet and discover network devices. diff --git a/example/flutter_example/.flutter-plugins-dependencies b/example/flutter_example/.flutter-plugins-dependencies index 9d354e0..4a45df7 100644 --- a/example/flutter_example/.flutter-plugins-dependencies +++ b/example/flutter_example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"wifi","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\wifi-0.1.5\\\\","dependencies":[]}],"android":[{"name":"wifi","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\wifi-0.1.5\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"wifi","dependencies":[]}],"date_created":"2021-03-20 15:02:06.258763","version":"2.1.0-12.1.pre"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"network_info_plus","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\network_info_plus-2.1.3\\\\","dependencies":[]}],"android":[{"name":"network_info_plus","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\network_info_plus-2.1.3\\\\","dependencies":[]}],"macos":[{"name":"network_info_plus_macos","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\network_info_plus_macos-1.3.0\\\\","dependencies":[]}],"linux":[{"name":"network_info_plus_linux","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\network_info_plus_linux-1.1.2\\\\","dependencies":[]}],"windows":[{"name":"network_info_plus_windows","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\network_info_plus_windows-1.0.2\\\\","dependencies":[]}],"web":[{"name":"network_info_plus_web","path":"E:\\\\Android\\\\flutter-dev\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\network_info_plus_web-1.0.1\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"network_info_plus","dependencies":["network_info_plus_linux","network_info_plus_macos","network_info_plus_windows","network_info_plus_web"]},{"name":"network_info_plus_linux","dependencies":[]},{"name":"network_info_plus_macos","dependencies":[]},{"name":"network_info_plus_web","dependencies":[]},{"name":"network_info_plus_windows","dependencies":[]}],"date_created":"2022-03-01 15:17:03.215673","version":"2.10.0-0.3.pre"} \ No newline at end of file diff --git a/example/flutter_example/android/app/src/main/AndroidManifest.xml b/example/flutter_example/android/app/src/main/AndroidManifest.xml index b8c4588..e08ad51 100644 --- a/example/flutter_example/android/app/src/main/AndroidManifest.xml +++ b/example/flutter_example/android/app/src/main/AndroidManifest.xml @@ -1,13 +1,7 @@ - - - - + + diff --git a/example/flutter_example/ios/Flutter/flutter_export_environment.sh b/example/flutter_example/ios/Flutter/flutter_export_environment.sh index a95a1d3..7d8a5b8 100644 --- a/example/flutter_example/ios/Flutter/flutter_export_environment.sh +++ b/example/flutter_example/ios/Flutter/flutter_export_environment.sh @@ -5,7 +5,6 @@ export "FLUTTER_APPLICATION_PATH=E:\Android\Projects\ping_discover_network\examp export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_TARGET=lib\main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build\ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" export "DART_OBFUSCATION=false" diff --git a/example/flutter_example/lib/main.dart b/example/flutter_example/lib/main.dart index 84cbaf2..a63eecc 100644 --- a/example/flutter_example/lib/main.dart +++ b/example/flutter_example/lib/main.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:network_info_plus/network_info_plus.dart'; import 'package:ping_discover_network/ping_discover_network.dart'; void main() => runApp(MyApp()); @@ -39,7 +40,7 @@ class _MyHomePageState extends State { String ip; try { - ip = await _getLocalIpAddress(); + ip = (await NetworkInfo().getWifiIP())!; print('local ip:\t$ip'); } catch (e) { final snackBar = SnackBar(content: Text('WiFi is not connected', textAlign: TextAlign.center)); diff --git a/example/flutter_example/pubspec.lock b/example/flutter_example/pubspec.lock index 6f88755..202edd3 100644 --- a/example/flutter_example/pubspec.lock +++ b/example/flutter_example/pubspec.lock @@ -1,13 +1,20 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -21,14 +28,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -49,7 +56,14 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.4" + dbus: + dependency: transitive + description: + name: dbus + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.1" fake_async: dependency: transitive description: @@ -57,6 +71,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" flutter: dependency: "direct main" description: flutter @@ -67,20 +88,88 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted + version: "1.7.0" + network_info_plus: + dependency: "direct main" + description: + name: network_info_plus + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + network_info_plus_linux: + dependency: transitive + description: + name: network_info_plus_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + network_info_plus_macos: + dependency: transitive + description: + name: network_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted version: "1.3.0" + network_info_plus_platform_interface: + dependency: transitive + description: + name: network_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + network_info_plus_web: + dependency: transitive + description: + name: network_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + network_info_plus_windows: + dependency: transitive + description: + name: network_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + nm: + dependency: transitive + description: + name: nm + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" path: dependency: transitive description: @@ -88,6 +177,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "4.4.0" ping_discover_network: dependency: "direct main" description: @@ -95,6 +191,13 @@ packages: relative: true source: path version: "1.0.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" sky_engine: dependency: transitive description: flutter @@ -141,7 +244,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.8" typed_data: dependency: transitive description: @@ -155,14 +258,14 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" - wifi: - dependency: "direct main" + version: "2.1.1" + xml: + dependency: transitive description: - name: wifi + name: xml url: "https://pub.dartlang.org" source: hosted - version: "0.1.5" + version: "5.3.1" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=0.1.4" + dart: ">=2.15.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/example/flutter_example/pubspec.yaml b/example/flutter_example/pubspec.yaml index 5797a30..e15e5c4 100644 --- a/example/flutter_example/pubspec.yaml +++ b/example/flutter_example/pubspec.yaml @@ -5,18 +5,21 @@ version: 1.0.0+1 environment: sdk: ">=2.12.0 <3.0.0" + flutter: ">=1.17.0" dependencies: flutter: sdk: flutter + cupertino_icons: ^1.0.2 + ping_discover_network: path: ../../ + network_info_plus: ^2.1.3 dev_dependencies: flutter_test: sdk: flutter - flutter: uses-material-design: true