Skip to content

Commit 2a0d097

Browse files
authored
Fix lints in package:objective_c (#1326)
1 parent 133c7e5 commit 2a0d097

11 files changed

+35
-40
lines changed

pkgs/objective_c/analysis_options.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,3 @@ analyzer:
99
strict-casts: true
1010
strict-inference: true
1111
strict-raw-types: true
12-
13-
linter:
14-
rules:
15-
avoid_dynamic_calls: false # TODO(https://github.com/dart-lang/native/issues/1280): Fix
16-
combinators_ordering: false # TODO(https://github.com/dart-lang/native/issues/1280): Fix.
17-
comment_references: false # TODO(https://github.com/dart-lang/native/issues/1280): Fix
18-
directives_ordering: false # TODO(https://github.com/dart-lang/native/issues/1280): Fix
19-
library_annotations: false # TODO(https://github.com/dart-lang/native/issues/1280): Fix
20-
omit_local_variable_types: false # TODO(https://github.com/dart-lang/native/issues/1280): Fix
21-
prefer_single_quotes: false # TODO(https://github.com/dart-lang/native/issues/1280): Fix
22-
sort_pub_dependencies: false # TODO(https://github.com/dart-lang/native/issues/1280): Fix

pkgs/objective_c/example/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ packages:
219219
dependency: transitive
220220
description:
221221
name: vm_service
222-
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
222+
sha256: "360c4271613beb44db559547d02f8b0dc044741d0eeb9aa6ccdb47e8ec54c63a"
223223
url: "https://pub.dev"
224224
source: hosted
225-
version: "14.2.4"
225+
version: "14.2.3"
226226
yaml:
227227
dependency: transitive
228228
description:

pkgs/objective_c/lib/objective_c.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
export 'src/internal.dart' hide blockHasRegisteredClosure;
6-
export 'src/ns_data.dart';
7-
export 'src/ns_mutable_data.dart';
8-
export 'src/ns_string.dart';
9-
export 'src/protocol_builder.dart';
105
export 'src/c_bindings_generated.dart'
116
show
12-
ObjCSelector,
13-
ObjCObject,
147
ObjCBlock,
15-
objectRetain,
16-
objectRelease,
8+
ObjCObject,
9+
ObjCSelector,
1710
blockCopy,
18-
blockRelease;
19-
11+
blockRelease,
12+
objectRelease,
13+
objectRetain;
14+
export 'src/internal.dart' hide blockHasRegisteredClosure;
15+
export 'src/ns_data.dart';
16+
export 'src/ns_mutable_data.dart';
17+
export 'src/ns_string.dart';
2018
// Keep in sync with pkgs/objective_c/ffigen_objc.yaml.
2119
export 'src/objective_c_bindings_generated.dart'
2220
show
@@ -72,3 +70,4 @@ export 'src/objective_c_bindings_generated.dart'
7270
NSURLHandleStatus,
7371
NSValue,
7472
Protocol;
73+
export 'src/protocol_builder.dart';

pkgs/objective_c/lib/src/internal.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bool _isValidClass(Pointer<c.ObjCObject> clazz) {
176176
final count = countPtr.value;
177177
calloc.free(countPtr);
178178
_allClasses.clear();
179-
for (int i = 0; i < count; ++i) {
179+
for (var i = 0; i < count; ++i) {
180180
_allClasses.add(classList[i]);
181181
}
182182
calloc.free(classList);
@@ -267,7 +267,7 @@ final _blockClosureDisposer = () {
267267
final id = msg as int;
268268
assert(_blockClosureRegistry.containsKey(id));
269269
_blockClosureRegistry.remove(id);
270-
}, "ObjCBlockClosureDisposer")
270+
}, 'ObjCBlockClosureDisposer')
271271
..keepIsolateAlive = false;
272272
}();
273273

@@ -280,7 +280,7 @@ Pointer<Void> _registerBlockClosure(Function closure) {
280280

281281
/// Only for use by ffigen bindings.
282282
Function getBlockClosure(Pointer<c.ObjCBlock> block) {
283-
int id = block.ref.target.address;
283+
var id = block.ref.target.address;
284284
assert(_blockClosureRegistry.containsKey(id));
285285
return _blockClosureRegistry[id]!;
286286
}

pkgs/objective_c/lib/src/protocol_builder.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import 'dart:ffi';
66

77
import 'c_bindings_generated.dart' as c;
8-
import 'objective_c_bindings_generated.dart' as objc;
98
import 'internal.dart' show ObjCBlockBase;
9+
import 'objective_c_bindings_generated.dart' as objc;
1010

1111
/// Helper class for building Objective C objects that implement protocols.
1212
class ObjCProtocolBuilder {
@@ -45,8 +45,8 @@ class ObjCProtocolMethod<T extends Function> {
4545
/// Implement this method on the protocol [builder] using a Dart [function].
4646
///
4747
/// The implemented method must be invoked by ObjC code running on the same
48-
/// thread as the isolate that called [implementMethod]. Invoking the method
49-
/// on the wrong thread will result in a crash.
48+
/// thread as the isolate that called implementMethod. Invoking the method on
49+
/// the wrong thread will result in a crash.
5050
void implement(ObjCProtocolBuilder builder, T? function) {
5151
if (function != null) {
5252
builder.implementMethod(_sel, _signature, _createBlock(function));

pkgs/objective_c/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ environment:
1818
flutter: '>=3.3.0'
1919

2020
dependencies:
21+
ffi: ^2.1.0
2122
flutter:
2223
sdk: flutter
23-
ffi: ^2.1.0
2424
plugin_platform_interface: ^2.0.2
2525
yaml: ^3.1.0
2626

2727
dev_dependencies:
2828
coverage: ^1.8.0
2929
dart_flutter_team_lints: ^2.0.0
3030
ffigen: ^12.0.0
31+
flutter_lints: ^3.0.0
3132
flutter_test:
3233
sdk: flutter
33-
flutter_lints: ^3.0.0
3434
test: ^1.21.1
3535

3636
dependency_overrides:

pkgs/objective_c/test/generate_code_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// Objective C support is only available on mac.
66
@TestOn('mac-os')
7+
library;
78

89
import 'dart:io';
910

pkgs/objective_c/test/interface_lists_test.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// Objective C support is only available on mac.
66
@TestOn('mac-os')
7+
library;
78

89
import 'dart:io';
910

@@ -18,20 +19,22 @@ void main() {
1819
late List<String> yamlEnums;
1920

2021
setUpAll(() {
21-
final yaml = loadYaml(File('ffigen_objc.yaml').readAsStringSync());
22-
yamlInterfaces = yaml['objc-interfaces']['include']
22+
final yaml =
23+
loadYaml(File('ffigen_objc.yaml').readAsStringSync()) as YamlMap;
24+
yamlInterfaces = ((yaml['objc-interfaces'] as YamlMap)['include']
25+
as YamlList)
2326
.map<String>((dynamic i) => i as String)
24-
.toList() as List<String>
27+
.toList()
2528
..sort();
26-
final structRenames = yaml['structs']['rename'];
27-
yamlStructs = yaml['structs']['include']
29+
final structRenames = (yaml['structs'] as YamlMap)['rename'] as YamlMap;
30+
yamlStructs = ((yaml['structs'] as YamlMap)['include'] as YamlList)
2831
.map<String>(
2932
(dynamic name) => (structRenames[name] ?? name) as String)
30-
.toList() as List<String>
33+
.toList()
3134
..sort();
32-
yamlEnums = yaml['enums']['include']
35+
yamlEnums = ((yaml['enums'] as YamlMap)['include'] as YamlList)
3336
.map<String>((dynamic i) => i as String)
34-
.toList() as List<String>
37+
.toList()
3538
..sort();
3639
});
3740

pkgs/objective_c/test/ns_mutable_data_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// Objective C support is only available on mac.
66
@TestOn('mac-os')
7+
library;
78

89
import 'dart:ffi';
910

pkgs/objective_c/test/nsdata_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// Objective C support is only available on mac.
66
@TestOn('mac-os')
7+
library;
78

89
import 'dart:ffi';
910

0 commit comments

Comments
 (0)