Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dart 3 compatibility #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ linter:
# - always_specify_types
- annotate_overrides
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
- avoid_as
# - avoid_bool_literals_in_conditional_expressions # not yet tested
# - avoid_catches_without_on_clauses # we do this commonly
# - avoid_catching_errors # we do this commonly
Expand Down
1 change: 1 addition & 0 deletions example/flutter_example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"network_info_plus","path":"/Users/tonu/.pub-cache/hosted/pub.dartlang.org/network_info_plus-3.0.5/","native_build":true,"dependencies":[]}],"android":[{"name":"network_info_plus","path":"/Users/tonu/.pub-cache/hosted/pub.dartlang.org/network_info_plus-3.0.5/","native_build":true,"dependencies":[]}],"macos":[{"name":"network_info_plus","path":"/Users/tonu/.pub-cache/hosted/pub.dartlang.org/network_info_plus-3.0.5/","native_build":true,"dependencies":[]}],"linux":[{"name":"network_info_plus","path":"/Users/tonu/.pub-cache/hosted/pub.dartlang.org/network_info_plus-3.0.5/","native_build":false,"dependencies":[]}],"windows":[{"name":"network_info_plus","path":"/Users/tonu/.pub-cache/hosted/pub.dartlang.org/network_info_plus-3.0.5/","native_build":true,"dependencies":[]}],"web":[{"name":"network_info_plus","path":"/Users/tonu/.pub-cache/hosted/pub.dartlang.org/network_info_plus-3.0.5/","dependencies":[]}]},"dependencyGraph":[{"name":"network_info_plus","dependencies":[]}],"date_created":"2023-12-11 17:29:33.945557","version":"3.3.9"}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="flutter_example"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -21,14 +21,14 @@
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.example.flutter_example;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import androidx.annotation.NonNull;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
.setMethodCallHandler(
(call, result) -> {
// Your existing code
}
);
}
}
13 changes: 13 additions & 0 deletions example/flutter_example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/tonu/development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/tonu/Desktop/Workspace/Klikit/App/ping_discover_network/example/flutter_example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
10 changes: 5 additions & 5 deletions example/flutter_example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:network_info_plus/network_info_plus.dart';
import 'package:ping_discover_network/ping_discover_network.dart';
import 'package:wifi/wifi.dart';

void main() => runApp(MyApp());

Expand Down Expand Up @@ -38,12 +38,12 @@ class _MyHomePageState extends State<MyHomePage> {

String ip;
try {
ip = await Wifi.ip;
ip = await NetworkInfo().getWifiIP() ?? '';
print('local ip:\t$ip');
} catch (e) {
final snackBar = SnackBar(
content: Text('WiFi is not connected', textAlign: TextAlign.center));
Scaffold.of(ctx).showSnackBar(snackBar);
ScaffoldMessenger.of(ctx).showSnackBar(snackBar);
return;
}
setState(() {
Expand Down Expand Up @@ -79,7 +79,7 @@ class _MyHomePageState extends State<MyHomePage> {
..onError((dynamic e) {
final snackBar = SnackBar(
content: Text('Unexpected exception', textAlign: TextAlign.center));
Scaffold.of(ctx).showSnackBar(snackBar);
ScaffoldMessenger.of(ctx).showSnackBar(snackBar);
});
}

Expand Down Expand Up @@ -107,7 +107,7 @@ class _MyHomePageState extends State<MyHomePage> {
SizedBox(height: 10),
Text('Local ip: $localIp', style: TextStyle(fontSize: 16)),
SizedBox(height: 15),
RaisedButton(
TextButton(
child: Text(
'${isDiscovering ? 'Discovering...' : 'Discover'}'),
onPressed: isDiscovering ? null : () => discover(context)),
Expand Down
229 changes: 229 additions & 0 deletions example/flutter_example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
# 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.4.1"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.9.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.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
dbus:
dependency: transitive
description:
name: dbus
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.10"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
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"
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.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
network_info_plus:
dependency: "direct main"
description:
name: network_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.5"
network_info_plus_platform_interface:
dependency: transitive
description:
name: network_info_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
nm:
dependency: transitive
description:
name: nm
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.0"
ping_discover_network:
dependency: "direct main"
description:
path: "../.."
relative: true
source: path
version: "0.2.0+1"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
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.9.0"
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.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.12"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
sdks:
dart: ">=2.18.0 <3.0.0"
flutter: ">=2.11.0"
3 changes: 2 additions & 1 deletion example/flutter_example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: flutter_example
description: A new Flutter project.
publish_to: none

version: 1.0.0+1

Expand All @@ -12,7 +13,7 @@ dependencies:
cupertino_icons: ^0.1.2
ping_discover_network:
path: ../../
wifi: ^0.1.5
network_info_plus: ^3.0.5

dev_dependencies:
flutter_test:
Expand Down
4 changes: 2 additions & 2 deletions lib/src/network_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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
Expand Down Expand Up @@ -83,7 +83,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
Expand Down
Loading