Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ build/
.classpath
.settings
/.fvm

.melos_tool/
19 changes: 17 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
include: package:pedantic/analysis_options.1.8.0.yaml
# This is the default analysis_options.yaml for all packages and examples
# If a package needs specific rules, create the analysis_options.yaml on it
# include this file, like:
#
# include: ../../analysis_options.yaml
#
include: package:pedantic/analysis_options.1.9.0.yaml

analyzer:
exclude:
# Ignore generated files
- '**/*.g.dart'
- 'lib/src/generated/*.dart'

linter:
rules:
- public_member_api_docs
public_member_api_docs: true
prefer_final_in_for_each: true
prefer_final_locals: true
4 changes: 2 additions & 2 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ scripts:
rm -rf ./build ./android/.gradle ./ios/.symlinks ./ios/Pods ./android/.idea ./.idea ./.dart-tool/build

dev_dependencies:
pedantic: 1.8.0
pedantic: 1.9.2

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
10 changes: 0 additions & 10 deletions packages/android_alarm_manager_plus/analysis_options.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion packages/android_alarm_manager_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class _AlarmHomePageState extends State<_AlarmHomePage> {

// Get the previous cached count and increment it.
final prefs = await SharedPreferences.getInstance();
var currentCount = prefs.getInt(countKey);
final currentCount = prefs.getInt(countKey);
await prefs.setInt(countKey, currentCount + 1);

// This will be null if we're running in the background.
Expand Down
6 changes: 5 additions & 1 deletion packages/android_alarm_manager_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: android_alarm_manager_example
description: Demonstrates how to use the android_alarm_manager_plus plugin.

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"

dependencies:
flutter:
sdk: flutter
Expand All @@ -16,7 +20,7 @@ dev_dependencies:
sdk: flutter
flutter_test:
sdk: flutter
pedantic: ^1.8.0
pedantic: ^1.9.2

flutter:
uses-material-design: true
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Future<StreamSubscription<VMIsolateRef>> resumeIsolatesOnPause(
FlutterDriver driver) async {
final vm = await driver.serviceClient.getVM();
print('for isolates');
for (var isolateRef in vm.isolates) {
for (final isolateRef in vm.isolates) {
final isolate = await isolateRef.load();
if (isolate.isPaused) {
print('isolate.resume');
Expand Down
2 changes: 1 addition & 1 deletion packages/android_alarm_manager_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.9.0
pedantic: ^1.9.2

flutter:
plugin:
Expand Down
10 changes: 0 additions & 10 deletions packages/android_intent_plus/analysis_options.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion packages/android_intent_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dev_dependencies:
mockito: ^3.0.0
flutter_test:
sdk: flutter
pedantic: ^1.9.0
pedantic: ^1.9.2

environment:
sdk: ">=2.3.0 <3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/battery_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {
Battery _battery = Battery();
final Battery _battery = Battery();

BatteryState _batteryState;
StreamSubscription<BatteryState> _batteryStateSubscription;
Expand Down Expand Up @@ -64,7 +64,7 @@ class _MyHomePageState extends State<MyHomePage> {
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.battery_unknown),
onPressed: () async {
final int batteryLevel = await _battery.batteryLevel;
final batteryLevel = await _battery.batteryLevel;
// ignore: unawaited_futures
showDialog<void>(
context: context,
Expand Down
3 changes: 1 addition & 2 deletions packages/battery_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: battery_plus_example
description: Demonstrates how to use the battery_plus plugin.
version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"
Expand All @@ -15,7 +14,7 @@ dev_dependencies:
flutter_driver:
sdk: flutter
integration_test: ^0.9.1
pedantic: ^1.9.0
pedantic: ^1.9.2

flutter:
uses-material-design: true
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('Can get battery level', (WidgetTester tester) async {
final Battery battery = Battery();
final int batteryLevel = await battery.batteryLevel;
final battery = Battery();
final batteryLevel = await battery.batteryLevel;
expect(batteryLevel, isNotNull);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';

Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String data =
final driver = await FlutterDriver.connect();
final data =
await driver.requestData(null, timeout: const Duration(minutes: 1));
await driver.close();
final Map<String, dynamic> result = jsonDecode(data);
Expand Down
4 changes: 1 addition & 3 deletions packages/battery_plus/lib/battery_plus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class Battery {
// EventChannel because it is overridden. Forcing the class to be a singleton class can prevent
// misuse of creating a second instance from a programmer.
factory Battery() {
if (_singleton == null) {
_singleton = Battery._();
}
_singleton ??= Battery._();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice, I've been tempted to fix these

return _singleton;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/battery_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dev_dependencies:
sdk: flutter
integration_test: ^0.9.1
plugin_platform_interface: ^1.0.0
pedantic: ^1.9.0
pedantic: ^1.9.2

environment:
sdk: '>=2.1.0 <3.0.0'
Expand Down
3 changes: 1 addition & 2 deletions packages/battery_plus/test/battery_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ void main() {
});

test('receive values', () async {
final StreamQueue<BatteryState> queue =
StreamQueue<BatteryState>(battery.onBatteryStateChanged);
final queue = StreamQueue<BatteryState>(battery.onBatteryStateChanged);

controller.add(BatteryState.full);
expect(await queue.next, BatteryState.full);
Expand Down
1 change: 0 additions & 1 deletion packages/battery_plus_linux/analysis_options.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extension _ToBatteryState on UPowerBatteryState {
}
}

///
@visibleForTesting
typedef UPowerDeviceFactory = UPowerDevice Function();

Expand Down Expand Up @@ -49,6 +50,7 @@ class BatteryPlusLinux extends BatteryPlatform {
StreamController<BatteryState> _stateController;

@visibleForTesting
// ignore: public_member_api_docs
UPowerDeviceFactory createDevice = () => UPowerDevice.display();

void _addState(UPowerBatteryState value) {
Expand Down
3 changes: 3 additions & 0 deletions packages/battery_plus_linux/lib/src/upower_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const _kInterface = 'org.freedesktop.UPower';
const _kDeviceAddress = 'org.freedesktop.UPower.Device';
const _kDisplayDevicePath = '/org/freedesktop/UPower/devices/DisplayDevice';

// Used internally
// ignore_for_file: public_member_api_docs

enum UPowerBatteryState {
unknown,
charging,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ class MethodChannelBattery extends BatteryPlatform {
Stream<BatteryState> _onBatteryStateChanged;

/// Returns the current battery level in percent.
@override
Future<int> get batteryLevel => methodChannel
.invokeMethod<int>('getBatteryLevel')
.then<int>((dynamic result) => result);

/// Fires whenever the battery state changes.
@override
Stream<BatteryState> get onBatteryStateChanged {
if (_onBatteryStateChanged == null) {
_onBatteryStateChanged = eventChannel
.receiveBroadcastStream()
.map((dynamic event) => parseBatteryState(event));
}
_onBatteryStateChanged ??= eventChannel
.receiveBroadcastStream()
.map((dynamic event) => parseBatteryState(event));
return _onBatteryStateChanged;
}
}
2 changes: 1 addition & 1 deletion packages/battery_plus_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.9.0
pedantic: ^1.9.2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();

group('$MethodChannelBattery', () {
final List<MethodCall> log = <MethodCall>[];
final log = <MethodCall>[];
MethodChannelBattery methodChannelBattery;

setUp(() async {
Expand Down Expand Up @@ -44,13 +44,12 @@ void main() {
});

test('onBatteryChanged', () async {
final BatteryState result =
await methodChannelBattery.onBatteryStateChanged.first;
final result = await methodChannelBattery.onBatteryStateChanged.first;
expect(result, BatteryState.full);
});

test('getBatteryLevel', () async {
final int result = await methodChannelBattery.batteryLevel;
final result = await methodChannelBattery.batteryLevel;
expect(result, 100);
expect(
log,
Expand Down
1 change: 1 addition & 0 deletions packages/battery_plus_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dev_dependencies:
sdk: flutter
integration_test: ^0.9.1
mockito: ^4.1.2
pedantic: ^1.9.2

environment:
sdk: '>=2.6.0 <3.0.0'
Expand Down
4 changes: 4 additions & 0 deletions packages/connectivity_plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.1

- Bump linux version.

## 0.7.0

- Add Linux support (`connectivity_plus_linux`).
Expand Down
12 changes: 5 additions & 7 deletions packages/connectivity_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class _MyHomePageState extends State<MyHomePage> {

try {
if (!kIsWeb && Platform.isIOS) {
LocationAuthorizationStatus status =
await _connectivity.getLocationServiceAuthorization();
var status = await _connectivity.getLocationServiceAuthorization();
if (status == LocationAuthorizationStatus.notDetermined) {
status =
await _connectivity.requestLocationServiceAuthorization();
Expand All @@ -121,13 +120,12 @@ class _MyHomePageState extends State<MyHomePage> {
}
} on PlatformException catch (e) {
print(e.toString());
wifiName = "Failed to get Wifi Name";
wifiName = 'Failed to get Wifi Name';
}

try {
if (!kIsWeb && Platform.isIOS) {
LocationAuthorizationStatus status =
await _connectivity.getLocationServiceAuthorization();
var status = await _connectivity.getLocationServiceAuthorization();
if (status == LocationAuthorizationStatus.notDetermined) {
status =
await _connectivity.requestLocationServiceAuthorization();
Expand All @@ -143,14 +141,14 @@ class _MyHomePageState extends State<MyHomePage> {
}
} on PlatformException catch (e) {
print(e.toString());
wifiBSSID = "Failed to get Wifi BSSID";
wifiBSSID = 'Failed to get Wifi BSSID';
}

try {
wifiIP = await _connectivity.getWifiIP();
} on PlatformException catch (e) {
print(e.toString());
wifiIP = "Failed to get Wifi IP";
wifiIP = 'Failed to get Wifi IP';
}

setState(() {
Expand Down
5 changes: 4 additions & 1 deletion packages/connectivity_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: connectivity_plus_example
description: Demonstrates how to use the connectivity_plus plugin.

environment:
sdk: ">=2.7.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
Expand All @@ -12,7 +15,7 @@ dev_dependencies:
sdk: flutter
test: any
integration_test: ^0.9.1
pedantic: ^1.8.0
pedantic: ^1.9.2

flutter:
uses-material-design: true
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void main() {
});

testWidgets('test connectivity result', (WidgetTester tester) async {
final ConnectivityResult result = await _connectivity.checkConnectivity();
final result = await _connectivity.checkConnectivity();
expect(result, isNotNull);
switch (result) {
case ConnectivityResult.wifi:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';

Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String data =
final driver = await FlutterDriver.connect();
final data =
await driver.requestData(null, timeout: const Duration(minutes: 1));
await driver.close();
final Map<String, dynamic> result = jsonDecode(data);
Expand Down
4 changes: 1 addition & 3 deletions packages/connectivity_plus/lib/connectivity_plus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class Connectivity {
// EventChannel because it is overridden. Forcing the class to be a singleton class can prevent
// misuse of creating a second instance from a programmer.
factory Connectivity() {
if (_singleton == null) {
_singleton = Connectivity._();
}
_singleton ??= Connectivity._();
return _singleton;
}

Expand Down
Loading