Skip to content

Commit e07ce94

Browse files
committed
Merge branch 'release/2.1.1'
2 parents 8bc7564 + 5ca3b60 commit e07ce94

File tree

12 files changed

+88
-56
lines changed

12 files changed

+88
-56
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ matrix:
4646
env:
4747
- SHARD="Build example ipas"
4848
language: generic
49-
osx_image: xcode9.3
49+
osx_image: xcode10.1
5050
before_script:
5151
- ./scripts/before_build_ipas.sh
5252
- export PATH=$HOME/flutter/bin:$HOME/flutter/bin/cache/dart-sdk/bin:$PATH

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.1.1
2+
3+
* Update to the latest version of Swift (4.2);
4+
* Make sure that the correct Swift version is set in the `Podfile` of consuming Apps;
5+
* Updated configuration for statis code analyses, so it complies with the Flutter recommendations.
6+
17
## 2.1.0
28

39
* Added Android support to check if location services are enabled. If location services are not running the permission check returns `PermissionStatus.DISABLED`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To use this plugin, add `permission_handler` as a [dependency in your pubspec.ya
2222

2323
```yaml
2424
dependencies:
25-
permission_handler: '^2.1.0'
25+
permission_handler: '^2.1.1'
2626
```
2727
2828
> **NOTE:** There's a known issue with integrating plugins that use Swift into a Flutter project created with the Objective-C template. See issue [Flutter#16049](https://github.com/flutter/flutter/issues/16049) for help on integration.

analysis_options.yaml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@
77
# See the configuration guide for more
88
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
99
#
10-
# There are four similar analysis options files in the flutter repos:
10+
# There are other similar analysis options files in the flutter repos,
11+
# which should be kept in sync with this file:
12+
#
1113
# - analysis_options.yaml (this file)
1214
# - packages/flutter/lib/analysis_options_user.yaml
1315
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
1416
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
1517
#
1618
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
1719
# Android Studio, and the `flutter analyze` command.
18-
#
19-
# The flutter/plugins repo contains a copy of this file, which should be kept
20-
# in sync with this file.
2120

2221
analyzer:
23-
language:
24-
enableSuperMixins: true
2522
strong-mode:
2623
implicit-dynamic: false
2724
errors:
@@ -67,38 +64,43 @@ linter:
6764
- avoid_relative_lib_imports
6865
- avoid_renaming_method_parameters
6966
- avoid_return_types_on_setters
70-
# - avoid_returning_null # we do this commonly
71-
# - avoid_returning_this # https://github.com/dart-lang/linter/issues/842
67+
# - avoid_returning_null # there are plenty of valid reasons to return null
68+
# - avoid_returning_this # there are plenty of valid reasons to return this
7269
# - avoid_setters_without_getters # not yet tested
7370
# - avoid_single_cascade_in_expression_statements # not yet tested
7471
- avoid_slow_async_io
75-
# - avoid_types_as_parameter_names # https://github.com/dart-lang/linter/pull/954/files
72+
- avoid_types_as_parameter_names
7673
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
77-
# - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
74+
- avoid_unused_constructor_parameters
75+
- avoid_void_async
7876
- await_only_futures
7977
- camel_case_types
8078
- cancel_subscriptions
8179
# - cascade_invocations # not yet tested
82-
# - close_sinks # https://github.com/flutter/flutter/issues/5789
83-
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
84-
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
80+
# - close_sinks # not reliable enough
81+
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
82+
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
8583
- control_flow_in_finally
84+
# - curly_braces_in_flow_control_structures # not yet tested
8685
- directives_ordering
8786
- empty_catches
8887
- empty_constructor_bodies
8988
- empty_statements
89+
# - file_names # not yet tested
9090
- hash_and_equals
9191
- implementation_imports
92-
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
92+
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
9393
- iterable_contains_unrelated_type
9494
# - join_return_with_assignment # not yet tested
9595
- library_names
9696
- library_prefixes
97+
# - lines_longer_than_80_chars # not yet tested
9798
- list_remove_unrelated_type
98-
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
99+
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
99100
- no_adjacent_strings_in_list
100101
- no_duplicate_case_values
101102
- non_constant_identifier_names
103+
# - null_closures # not yet tested
102104
# - omit_local_variable_types # opposite of always_specify_types
103105
# - one_member_abstracts # too many false positives
104106
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
@@ -124,13 +126,17 @@ linter:
124126
- prefer_final_locals
125127
- prefer_foreach
126128
# - prefer_function_declarations_over_variables # not yet tested
129+
- prefer_generic_function_type_aliases
127130
- prefer_initializing_formals
128131
# - prefer_interpolation_to_compose_strings # not yet tested
129-
# - prefer_iterable_whereType # https://github.com/dart-lang/sdk/issues/32463
130132
- prefer_is_empty
131133
- prefer_is_not_empty
134+
- prefer_iterable_whereType
135+
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
132136
- prefer_single_quotes
133137
- prefer_typing_uninitialized_variables
138+
- prefer_void_to_null
139+
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
134140
- recursive_getters
135141
- slash_for_doc_comments
136142
- sort_constructors_first
@@ -140,21 +146,22 @@ linter:
140146
- throw_in_finally
141147
# - type_annotate_public_apis # subset of always_specify_types
142148
- type_init_formals
143-
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
149+
# - unawaited_futures # too many false positives
144150
- unnecessary_brace_in_string_interps
145-
# - unnecessary_const
151+
- unnecessary_const
146152
- unnecessary_getters_setters
147-
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
153+
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
154+
- unnecessary_new
148155
- unnecessary_null_aware_assignments
149156
- unnecessary_null_in_if_null_operators
150157
- unnecessary_overrides
151158
- unnecessary_parenthesis
152-
# - unnecessary_statements # not yet tested
159+
- unnecessary_statements
153160
- unnecessary_this
154161
- unrelated_type_equality_checks
155162
- use_rethrow_when_possible
156163
# - use_setters_to_change_properties # not yet tested
157-
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
164+
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
158165
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
159166
- valid_regexps
160-
# - void_checks # not yet tested
167+
# - void_checks # not yet tested

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
);
223223
inputPaths = (
224224
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
225-
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
225+
"${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework",
226226
"${BUILT_PRODUCTS_DIR}/permission_handler/permission_handler.framework",
227227
);
228228
name = "[CP] Embed Pods Frameworks";
@@ -445,7 +445,7 @@
445445
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
446446
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
447447
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
448-
SWIFT_VERSION = 4.0;
448+
SWIFT_VERSION = 4.2;
449449
VERSIONING_SYSTEM = "apple-generic";
450450
};
451451
name = Debug;
@@ -472,7 +472,7 @@
472472
PRODUCT_NAME = "$(TARGET_NAME)";
473473
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
474474
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
475-
SWIFT_VERSION = 4.0;
475+
SWIFT_VERSION = 4.2;
476476
VERSIONING_SYSTEM = "apple-generic";
477477
};
478478
name = Release;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>BuildSystemType</key>
6+
<string>Original</string>
7+
</dict>
8+
</plist>

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Flutter
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,
8-
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
8+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
99
) -> Bool {
1010
GeneratedPluginRegistrant.register(with: self)
1111
return super.application(application, didFinishLaunchingWithOptions: launchOptions)

example/lib/main.dart

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import 'dart:io';
33
import 'package:flutter/material.dart';
44
import 'package:permission_handler/permission_handler.dart';
55

6-
void main() => runApp(new MyApp());
6+
void main() => runApp(MyApp());
77

88
class MyApp extends StatelessWidget {
99
@override
1010
Widget build(BuildContext context) {
11-
return new MaterialApp(
12-
home: new Scaffold(
13-
appBar: new AppBar(
11+
return MaterialApp(
12+
home: Scaffold(
13+
appBar: AppBar(
1414
title: const Text('Plugin example app'),
1515
actions: <Widget>[
1616
IconButton(
@@ -21,8 +21,8 @@ class MyApp extends StatelessWidget {
2121
)
2222
],
2323
),
24-
body: new Center(
25-
child: new ListView(
24+
body: Center(
25+
child: ListView(
2626
children: PermissionGroup.values
2727
.where((PermissionGroup permission) {
2828
if (Platform.isIOS) {
@@ -38,7 +38,7 @@ class MyApp extends StatelessWidget {
3838
}
3939
})
4040
.map((PermissionGroup permission) =>
41-
new PermissionWidget(permission))
41+
PermissionWidget(permission))
4242
.toList()),
4343
),
4444
));
@@ -67,12 +67,14 @@ class _PermissionState extends State<PermissionWidget> {
6767
_listenForPermissionStatus();
6868
}
6969

70-
void _listenForPermissionStatus() async {
71-
final PermissionStatus status =
72-
await PermissionHandler().checkPermissionStatus(_permissionGroup);
70+
void _listenForPermissionStatus() {
71+
final Future<PermissionStatus> statusFuture =
72+
PermissionHandler().checkPermissionStatus(_permissionGroup);
7373

74-
setState(() {
75-
_permissionStatus = status;
74+
statusFuture.then((PermissionStatus status) {
75+
setState(() {
76+
_permissionStatus = status;
77+
});
7678
});
7779
}
7880

@@ -89,25 +91,28 @@ class _PermissionState extends State<PermissionWidget> {
8991

9092
@override
9193
Widget build(BuildContext context) {
92-
return new ListTile(
93-
title: new Text(_permissionGroup.toString()),
94-
subtitle: new Text(
94+
return ListTile(
95+
title: Text(_permissionGroup.toString()),
96+
subtitle: Text(
9597
_permissionStatus.toString(),
96-
style: new TextStyle(color: getPermissionColor()),
98+
style: TextStyle(color: getPermissionColor()),
9799
),
98100
onTap: () async {
99101
requestPermission(_permissionGroup);
100102
},
101103
);
102104
}
103105

104-
void requestPermission(PermissionGroup permission) async {
106+
void requestPermission(PermissionGroup permission) {
105107
final List<PermissionGroup> permissions = <PermissionGroup>[permission];
106-
final Map<PermissionGroup, PermissionStatus> permissionRequestResult =
107-
await PermissionHandler().requestPermissions(permissions);
108-
109-
setState(() {
110-
_permissionStatus = permissionRequestResult[permission];
108+
final Future<Map<PermissionGroup, PermissionStatus>> requestFuture =
109+
PermissionHandler().requestPermissions(permissions);
110+
111+
requestFuture
112+
.then((Map<PermissionGroup, PermissionStatus> permissionRequestResult) {
113+
setState(() {
114+
_permissionStatus = permissionRequestResult[permission];
115+
});
111116
});
112117
}
113118
}

ios/Classes/PermissionManager.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ class PermissionManager: NSObject {
4747
static func openAppSettings(result: @escaping FlutterResult) {
4848
if #available(iOS 8.0, *) {
4949
if #available(iOS 10, *) {
50-
UIApplication.shared.open(URL.init(string: UIApplicationOpenSettingsURLString)!, options: [:],
50+
UIApplication.shared.open(URL.init(string: UIApplication.openSettingsURLString)!, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]),
5151
completionHandler: {
5252
(success) in result(success)
5353
})
5454
} else {
55-
let success = UIApplication.shared.openURL(URL.init(string: UIApplicationOpenSettingsURLString)!)
55+
let success = UIApplication.shared.openURL(URL.init(string: UIApplication.openSettingsURLString)!)
5656
result(success)
5757
}
5858
}
@@ -89,3 +89,8 @@ class PermissionManager: NSObject {
8989
}
9090
}
9191
}
92+
93+
// Helper function inserted by Swift 4.2 migrator.
94+
fileprivate func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
95+
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
96+
}

ios/permission_handler.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
Pod::Spec.new do |s|
55
s.name = 'permission_handler'
6-
s.version = '2.1.0'
6+
s.version = '2.1.1'
77
s.summary = 'Permission plugin for Flutter.'
88
s.description = <<-DESC
99
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
@@ -17,5 +17,6 @@ Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Andro
1717
s.dependency 'Flutter'
1818

1919
s.ios.deployment_target = '8.0'
20+
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' }
2021
end
2122

lib/permission_handler.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class PermissionHandler {
1515
factory PermissionHandler() {
1616
if (_instance == null) {
1717
const MethodChannel methodChannel =
18-
const MethodChannel('flutter.baseflow.com/permissions/methods');
18+
MethodChannel('flutter.baseflow.com/permissions/methods');
1919

20-
_instance = new PermissionHandler.private(methodChannel);
20+
_instance = PermissionHandler.private(methodChannel);
2121
}
2222
return _instance;
2323
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: permission_handler
22
description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
3-
version: 2.1.0
3+
version: 2.1.1
44
author: Baseflow <hello@baseflow.com>
55
homepage: https://github.com/baseflowit/flutter-permission-handler
66

0 commit comments

Comments
 (0)