Skip to content

Commit

Permalink
Updated kotlin to 1.6.10 and all dependencies to last version. Added …
Browse files Browse the repository at this point in the history
…support for lint
  • Loading branch information
guyluz11 committed Jan 18, 2022
1 parent 769d7b2 commit 3fb98d6
Show file tree
Hide file tree
Showing 16 changed files with 192 additions and 103 deletions.
34 changes: 34 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# lint analysis
include: package:lint/analysis_options.yaml

analyzer:
errors:
missing_required_param: error
missing_return: error
must_be_immutable: error
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "**/*.pb.dart"
- "**/*.pbenum.dart"
- "**/*.pbgrpc.dart"
- "**/*.pbjson.dart"
- "**/*.gr.dart"
- "**/*.config.dart"


linter:
rules:
# Use parameter order as in json response
# always_put_required_named_parameters_first: false

avoid_classes_with_only_static_members: false

sort_constructors_first: true

prefer_single_quotes: true

# Good packages document everything
public_member_api_docs: true

lines_longer_than_80_chars: true
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
Expand Down
11 changes: 6 additions & 5 deletions lib/api/isp_loader.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:convert';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:http/http.dart' as http;

import 'package:shared_preferences/shared_preferences.dart';
import 'package:vernet/models/internet_provider.dart';
import 'package:flutter/services.dart' show rootBundle;

class ISPLoader {
static Future<String> loadIP(String url) async {
Expand All @@ -19,7 +19,7 @@ class ISPLoader {
Future<InternetProvider> _mimicLoad() async {
return rootBundle.loadStructuredData<InternetProvider>(
'assets/ipwhois.json', (json) async {
return InternetProvider.fromMap(jsonDecode(json));
return InternetProvider.fromMap(jsonDecode(json) as Map<String, dynamic>);
});
}

Expand All @@ -40,7 +40,8 @@ class ISPLoader {
String? json = sp.getString(_ip);
if (json != null && json.isNotEmpty) {
// print('Response fetched from local $json');
return InternetProvider.fromMap(jsonDecode(json));
return InternetProvider.fromMap(
jsonDecode(json) as Map<String, dynamic>);
}
}

Expand All @@ -51,7 +52,7 @@ class ISPLoader {
String body = await compute(loadISP, url);
if (body.isNotEmpty) {
sp.setString(_ip, body);
return InternetProvider.fromMap(jsonDecode(body));
return InternetProvider.fromMap(jsonDecode(body) as Map<String, dynamic>);
}
return null;
}
Expand Down
15 changes: 8 additions & 7 deletions lib/api/update_checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ Future<bool> _checkUpdates(String v) async {
'https://api.github.com/repos/git-elliot/vernet/tags?per_page=1');
var response = await http.get(url);
if (response.statusCode == HttpStatus.ok) {
List<dynamic> res = jsonDecode(response.body);
List<dynamic> res = jsonDecode(response.body) as List<dynamic>;
debugPrint(res.toString());
if (res.length > 0) {
String tag = res[0]["name"];
String tag = res[0]["name"] as String;
if (tag.contains('v')) {
tag = tag.substring(1);
}
if (v.contains('-store')) {
List<String> sp = v.split('-store');
v = sp[0] + sp[1];
String tempV = v;
if (tempV.contains('-store')) {
List<String> sp = tempV.split('-store');
tempV = sp[0] + sp[1];
}
debugPrint("tag: $tag , v: $v");
return v.compareTo(tag) < 0;
debugPrint("tag: $tag , v: $tempV");
return tempV.compareTo(tag) < 0;
}
}
return false;
Expand Down
1 change: 1 addition & 0 deletions lib/generated_plugin_registrant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Generated file. Do not edit.
//

// ignore_for_file: directives_ordering
// ignore_for_file: lines_longer_than_80_chars

import 'package:network_info_plus_web/network_info_plus_web.dart';
Expand Down
7 changes: 4 additions & 3 deletions lib/helper/port_desc_loader.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:vernet/models/port.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:vernet/models/port.dart';

/// Do not put this method inside any class, be it top level function
/// Because this method runs inside isolate.
Future<Map<String, Port>> _parsePortDesc(String json) async {
Map<String, dynamic> ports = jsonDecode(json);
Map<String, dynamic> ports = jsonDecode(json) as Map<String, dynamic>;
Map<String, Port> mPorts = {};
for (String key in ports.keys) {
List<dynamic> port = ports[key];
List<dynamic> port = ports[key] as List<dynamic>;
if (port.length > 0) {
mPorts[key] = Port.fromJson(port[0]);
}
Expand Down
18 changes: 9 additions & 9 deletions lib/models/internet_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class InternetProvider {
String get ipType => _ipType;

InternetProvider.fromMap(Map<String, dynamic> json)
: _isp = json['isp'],
_ip = json['ip'],
_ipType = json['type'],
: _isp = json['isp'] as String,
_ip = json['ip'] as String,
_ipType = json['type'] as String,
_location = Location.fromMap(json);
}

Expand All @@ -30,10 +30,10 @@ class Location {
String get flagUrl => _flagUrl;

Location.fromMap(Map<String, dynamic> json)
: _country = json['country'],
_region = json['region'],
_city = json['city'],
_lat = json['latitude'],
_lng = json['longitude'],
_flagUrl = json['country_flag'];
: _country = json['country'] as String,
_region = json['region'] as String,
_city = json['city'] as String,
_lat = json['latitude'] as String,
_lng = json['longitude'] as String,
_flagUrl = json['country_flag'] as String;
}
10 changes: 5 additions & 5 deletions lib/models/port.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class Port {
String get status => _status;

Port.fromJson(dynamic map)
: _desc = map['description'],
_tcp = map['tcp'],
_udp = map['udp'],
_port = map['port'],
_status = map['status'];
: _desc = map['description'] as String,
_tcp = map['tcp'] as bool,
_udp = map['udp'] as bool,
_port = map['port'] as String,
_status = map['status'] as String;
}
2 changes: 1 addition & 1 deletion lib/pages/base_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract class BasePage<T extends StatefulWidget> extends State<T> {
String title();
String fieldLabel();

_getDomainChip(String label) {
Widget _getDomainChip(String label) {
return PopularChip(
label: label,
onPressed: () {
Expand Down
56 changes: 33 additions & 23 deletions lib/pages/host_scan_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,42 @@ class _HostScanPageState extends State<HostScanPage>
double _progress = 0;
StreamSubscription<ActiveHost>? _streamSubscription;

bool isScanning = true;

void _getDevices() async {
_devices.clear();
final String? ip = await (NetworkInfo().getWifiIP());
if (ip != null && ip.isNotEmpty) {
final String subnet = ip.substring(0, ip.lastIndexOf('.'));
final stream = HostScanner.discover(subnet,
firstSubnet: appSettings.firstSubnet,
lastSubnet: appSettings.lastSubnet, progressCallback: (progress) {
debugPrint('Progress : $progress');
if (this.mounted) {
final stream = HostScanner.discover(
subnet,
firstSubnet: appSettings.firstSubnet,
lastSubnet: appSettings.lastSubnet,
progressCallback: (progress) {
debugPrint('Progress : $progress');
if (this.mounted) {
setState(() {
_progress = progress;
});
}
},
);

_streamSubscription = stream.listen(
(ActiveHost device) {
debugPrint('Found device: ${device.ip}');
setState(() {
_progress = progress;
_devices.add(device);
});
}
});

_streamSubscription = stream.listen((ActiveHost device) {
debugPrint('Found device: ${device.ip}');
setState(() {
_devices.add(device);
});
}, onDone: () {
debugPrint('Scan completed');
if (this.mounted) {
setState(() {});
}
});
},
onDone: () {
debugPrint('Scan completed');
if (this.mounted) {
setState(() {});
}
isScanning = false;
},
);
}
}

Expand All @@ -71,7 +80,7 @@ class _HostScanPageState extends State<HostScanPage>
appBar: AppBar(
title: Text('Scan for Devices'),
actions: [
HostScanner.isScanning
isScanning
? Container(
margin: EdgeInsets.only(right: 20.0),
child: new CircularPercentIndicator(
Expand Down Expand Up @@ -100,7 +109,7 @@ class _HostScanPageState extends State<HostScanPage>
'No device found.\nTry changing first and last subnet in settings',
textAlign: TextAlign.center,
);
} else if (HostScanner.isScanning && _devices.isEmpty) {
} else if (isScanning && _devices.isEmpty) {
return CircularProgressIndicator.adaptive();
}

Expand All @@ -110,7 +119,8 @@ class _HostScanPageState extends State<HostScanPage>
child: ListView.builder(
itemCount: _devices.length,
itemBuilder: (context, index) {
ActiveHost device = SplayTreeSet.from(_devices).toList()[index];
ActiveHost device =
SplayTreeSet.from(_devices).toList()[index] as ActiveHost;
return ListTile(
title: Text(device.make),
subtitle: Text(device.ip),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/network_troubleshoot/ping_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class _PingPageState extends BasePage<PingPage> {
);
}

_getTime(Duration? time) {
String _getTime(Duration? time) {
if (time != null) {
final ms = time.inMicroseconds / Duration.millisecondsPerSecond;
return '$ms ms';
Expand Down
10 changes: 6 additions & 4 deletions lib/pages/network_troubleshoot/port_scan_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:network_tools/network_tools.dart';
Expand Down Expand Up @@ -123,7 +124,7 @@ class _PortScanPageState extends State<PortScanPage>
_streamSubscription?.cancel();
}

_getCustomRangeChip(String label, String start, String end) {
Widget _getCustomRangeChip(String label, String start, String end) {
return PopularChip(
label: label,
onPressed: () {
Expand All @@ -133,7 +134,7 @@ class _PortScanPageState extends State<PortScanPage>
);
}

_getSinglePortChip(String label, String port) {
Widget _getSinglePortChip(String label, String port) {
return PopularChip(
label: label,
onPressed: () {
Expand All @@ -142,7 +143,7 @@ class _PortScanPageState extends State<PortScanPage>
);
}

_getDomainChip(String label) {
Widget _getDomainChip(String label) {
return PopularChip(
label: label,
onPressed: () {
Expand All @@ -151,7 +152,7 @@ class _PortScanPageState extends State<PortScanPage>
);
}

_getFields() {
Widget _getFields() {
if (_type == ScanType.single) {
return TextFormField(
keyboardType: TextInputType.number,
Expand Down Expand Up @@ -185,6 +186,7 @@ class _PortScanPageState extends State<PortScanPage>
],
);
}
return const Text('');
}

String? validatePorts(String? value) {
Expand Down
2 changes: 2 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#include "generated_plugin_registrant.h"

#include <url_launcher_linux/url_launcher_plugin.h>
Expand Down
2 changes: 2 additions & 0 deletions linux/flutter/generated_plugin_registrant.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_

Expand Down
Loading

0 comments on commit 3fb98d6

Please sign in to comment.