Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
0b460b5e
Unverified
Commit
0b460b5e
authored
Nov 21, 2018
by
Maurits van Beusekom
Committed by
GitHub
Nov 21, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #42 from BaseflowIT/maintenance/fix_analysis
Update and fix Flutter Analyze configuration
parents
e18785fc
fc28a497
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
40 deletions
+61
-40
analysis_options.yaml
+29
-21
example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
+8
-0
example/lib/main.dart
+22
-17
lib/permission_handler.dart
+2
-2
No files found.
analysis_options.yaml
View file @
0b460b5e
...
@@ -7,7 +7,9 @@
...
@@ -7,7 +7,9 @@
# See the configuration guide for more
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
#
# There are four similar analysis options files in the flutter repos:
# There are other similar analysis options files in the flutter repos,
# which should be kept in sync with this file:
#
# - analysis_options.yaml (this file)
# - analysis_options.yaml (this file)
# - packages/flutter/lib/analysis_options_user.yaml
# - packages/flutter/lib/analysis_options_user.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
...
@@ -15,13 +17,8 @@
...
@@ -15,13 +17,8 @@
#
#
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.
# Android Studio, and the `flutter analyze` command.
#
# The flutter/plugins repo contains a copy of this file, which should be kept
# in sync with this file.
analyzer
:
analyzer
:
language
:
enableSuperMixins
:
true
strong-mode
:
strong-mode
:
implicit-dynamic
:
false
implicit-dynamic
:
false
errors
:
errors
:
...
@@ -67,38 +64,43 @@ linter:
...
@@ -67,38 +64,43 @@ linter:
-
avoid_relative_lib_imports
-
avoid_relative_lib_imports
-
avoid_renaming_method_parameters
-
avoid_renaming_method_parameters
-
avoid_return_types_on_setters
-
avoid_return_types_on_setters
# - avoid_returning_null #
we do this commonly
# - avoid_returning_null #
there are plenty of valid reasons to return null
# - avoid_returning_this #
https://github.com/dart-lang/linter/issues/842
# - avoid_returning_this #
there are plenty of valid reasons to return this
# - avoid_setters_without_getters # not yet tested
# - avoid_setters_without_getters # not yet tested
# - avoid_single_cascade_in_expression_statements # not yet tested
# - avoid_single_cascade_in_expression_statements # not yet tested
-
avoid_slow_async_io
-
avoid_slow_async_io
# - avoid_types_as_parameter_names # https://github.com/dart-lang/linter/pull/954/fil
es
-
avoid_types_as_parameter_nam
es
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
# - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
-
avoid_unused_constructor_parameters
-
avoid_void_async
-
await_only_futures
-
await_only_futures
-
camel_case_types
-
camel_case_types
-
cancel_subscriptions
-
cancel_subscriptions
# - cascade_invocations # not yet tested
# - cascade_invocations # not yet tested
# - close_sinks #
https://github.com/flutter/flutter/issues/5789
# - close_sinks #
not reliable enough
# - comment_references # blocked on https://github.com/
dart-lang/dartdoc/issues/1153
# - comment_references # blocked on https://github.com/
flutter/flutter/issues/20765
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
# - constant_identifier_names #
needs an opt-out
https://github.com/dart-lang/linter/issues/204
-
control_flow_in_finally
-
control_flow_in_finally
# - curly_braces_in_flow_control_structures # not yet tested
-
directives_ordering
-
directives_ordering
-
empty_catches
-
empty_catches
-
empty_constructor_bodies
-
empty_constructor_bodies
-
empty_statements
-
empty_statements
# - file_names # not yet tested
-
hash_and_equals
-
hash_and_equals
-
implementation_imports
-
implementation_imports
# - invariant_booleans #
https://github.com/flutter/flutter/issues/5790
# - invariant_booleans #
too many false positives: https://github.com/dart-lang/linter/issues/811
-
iterable_contains_unrelated_type
-
iterable_contains_unrelated_type
# - join_return_with_assignment # not yet tested
# - join_return_with_assignment # not yet tested
-
library_names
-
library_names
-
library_prefixes
-
library_prefixes
# - lines_longer_than_80_chars # not yet tested
-
list_remove_unrelated_type
-
list_remove_unrelated_type
# - literal_only_boolean_expressions #
https://github.com/flutter/flutter/issues/579
1
# - literal_only_boolean_expressions #
too many false positives: https://github.com/dart-lang/sdk/issues/3418
1
-
no_adjacent_strings_in_list
-
no_adjacent_strings_in_list
-
no_duplicate_case_values
-
no_duplicate_case_values
-
non_constant_identifier_names
-
non_constant_identifier_names
# - null_closures # not yet tested
# - omit_local_variable_types # opposite of always_specify_types
# - omit_local_variable_types # opposite of always_specify_types
# - one_member_abstracts # too many false positives
# - one_member_abstracts # too many false positives
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
...
@@ -124,13 +126,17 @@ linter:
...
@@ -124,13 +126,17 @@ linter:
-
prefer_final_locals
-
prefer_final_locals
-
prefer_foreach
-
prefer_foreach
# - prefer_function_declarations_over_variables # not yet tested
# - prefer_function_declarations_over_variables # not yet tested
-
prefer_generic_function_type_aliases
-
prefer_initializing_formals
-
prefer_initializing_formals
# - prefer_interpolation_to_compose_strings # not yet tested
# - prefer_interpolation_to_compose_strings # not yet tested
# - prefer_iterable_whereType # https://github.com/dart-lang/sdk/issues/32463
-
prefer_is_empty
-
prefer_is_empty
-
prefer_is_not_empty
-
prefer_is_not_empty
-
prefer_iterable_whereType
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
-
prefer_single_quotes
-
prefer_single_quotes
-
prefer_typing_uninitialized_variables
-
prefer_typing_uninitialized_variables
-
prefer_void_to_null
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
-
recursive_getters
-
recursive_getters
-
slash_for_doc_comments
-
slash_for_doc_comments
-
sort_constructors_first
-
sort_constructors_first
...
@@ -140,21 +146,22 @@ linter:
...
@@ -140,21 +146,22 @@ linter:
-
throw_in_finally
-
throw_in_finally
# - type_annotate_public_apis # subset of always_specify_types
# - type_annotate_public_apis # subset of always_specify_types
-
type_init_formals
-
type_init_formals
# - unawaited_futures #
https://github.com/flutter/flutter/issues/5793
# - unawaited_futures #
too many false positives
-
unnecessary_brace_in_string_interps
-
unnecessary_brace_in_string_interps
#
- unnecessary_const
-
unnecessary_const
-
unnecessary_getters_setters
-
unnecessary_getters_setters
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
-
unnecessary_new
-
unnecessary_null_aware_assignments
-
unnecessary_null_aware_assignments
-
unnecessary_null_in_if_null_operators
-
unnecessary_null_in_if_null_operators
-
unnecessary_overrides
-
unnecessary_overrides
-
unnecessary_parenthesis
-
unnecessary_parenthesis
# - unnecessary_statements # not yet tested
-
unnecessary_statements
-
unnecessary_this
-
unnecessary_this
-
unrelated_type_equality_checks
-
unrelated_type_equality_checks
-
use_rethrow_when_possible
-
use_rethrow_when_possible
# - use_setters_to_change_properties # not yet tested
# - use_setters_to_change_properties # not yet tested
# - use_string_buffers # h
ttps://github.com/dart-lang/linter/pull/664
# - use_string_buffers # h
as false positives: https://github.com/dart-lang/sdk/issues/34182
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
-
valid_regexps
-
valid_regexps
# - void_checks # not yet tested
# - void_checks # not yet tested
\ No newline at end of file
example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
0 → 100644
View file @
0b460b5e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
BuildSystemType
</key>
<string>
Original
</string>
</dict>
</plist>
example/lib/main.dart
View file @
0b460b5e
...
@@ -3,14 +3,14 @@ import 'dart:io';
...
@@ -3,14 +3,14 @@ import 'dart:io';
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
void
main
(
)
=>
runApp
(
new
MyApp
());
void
main
(
)
=>
runApp
(
MyApp
());
class
MyApp
extends
StatelessWidget
{
class
MyApp
extends
StatelessWidget
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
MaterialApp
(
return
MaterialApp
(
home:
new
Scaffold
(
home:
Scaffold
(
appBar:
new
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'Plugin example app'
),
title:
const
Text
(
'Plugin example app'
),
actions:
<
Widget
>[
actions:
<
Widget
>[
IconButton
(
IconButton
(
...
@@ -21,8 +21,8 @@ class MyApp extends StatelessWidget {
...
@@ -21,8 +21,8 @@ class MyApp extends StatelessWidget {
)
)
],
],
),
),
body:
new
Center
(
body:
Center
(
child:
new
ListView
(
child:
ListView
(
children:
PermissionGroup
.
values
children:
PermissionGroup
.
values
.
where
((
PermissionGroup
permission
)
{
.
where
((
PermissionGroup
permission
)
{
if
(
Platform
.
isIOS
)
{
if
(
Platform
.
isIOS
)
{
...
@@ -38,7 +38,7 @@ class MyApp extends StatelessWidget {
...
@@ -38,7 +38,7 @@ class MyApp extends StatelessWidget {
}
}
})
})
.
map
((
PermissionGroup
permission
)
=>
.
map
((
PermissionGroup
permission
)
=>
new
PermissionWidget
(
permission
))
PermissionWidget
(
permission
))
.
toList
()),
.
toList
()),
),
),
));
));
...
@@ -67,13 +67,15 @@ class _PermissionState extends State<PermissionWidget> {
...
@@ -67,13 +67,15 @@ class _PermissionState extends State<PermissionWidget> {
_listenForPermissionStatus
();
_listenForPermissionStatus
();
}
}
void
_listenForPermissionStatus
()
async
{
void
_listenForPermissionStatus
()
{
final
PermissionStatus
status
=
final
Future
<
PermissionStatus
>
statusFuture
=
await
PermissionHandler
().
checkPermissionStatus
(
_permissionGroup
);
PermissionHandler
().
checkPermissionStatus
(
_permissionGroup
);
statusFuture
.
then
((
PermissionStatus
status
)
{
setState
(()
{
setState
(()
{
_permissionStatus
=
status
;
_permissionStatus
=
status
;
});
});
});
}
}
Color
getPermissionColor
()
{
Color
getPermissionColor
()
{
...
@@ -89,11 +91,11 @@ class _PermissionState extends State<PermissionWidget> {
...
@@ -89,11 +91,11 @@ class _PermissionState extends State<PermissionWidget> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
ListTile
(
return
ListTile
(
title:
new
Text
(
_permissionGroup
.
toString
()),
title:
Text
(
_permissionGroup
.
toString
()),
subtitle:
new
Text
(
subtitle:
Text
(
_permissionStatus
.
toString
(),
_permissionStatus
.
toString
(),
style:
new
TextStyle
(
color:
getPermissionColor
()),
style:
TextStyle
(
color:
getPermissionColor
()),
),
),
onTap:
()
async
{
onTap:
()
async
{
requestPermission
(
_permissionGroup
);
requestPermission
(
_permissionGroup
);
...
@@ -101,13 +103,16 @@ class _PermissionState extends State<PermissionWidget> {
...
@@ -101,13 +103,16 @@ class _PermissionState extends State<PermissionWidget> {
);
);
}
}
void
requestPermission
(
PermissionGroup
permission
)
async
{
void
requestPermission
(
PermissionGroup
permission
)
{
final
List
<
PermissionGroup
>
permissions
=
<
PermissionGroup
>[
permission
];
final
List
<
PermissionGroup
>
permissions
=
<
PermissionGroup
>[
permission
];
final
Map
<
PermissionGroup
,
PermissionStatus
>
permissionRequestResult
=
final
Future
<
Map
<
PermissionGroup
,
PermissionStatus
>>
requestFuture
=
await
PermissionHandler
().
requestPermissions
(
permissions
);
PermissionHandler
().
requestPermissions
(
permissions
);
requestFuture
.
then
((
Map
<
PermissionGroup
,
PermissionStatus
>
permissionRequestResult
)
{
setState
(()
{
setState
(()
{
_permissionStatus
=
permissionRequestResult
[
permission
];
_permissionStatus
=
permissionRequestResult
[
permission
];
});
});
});
}
}
}
}
lib/permission_handler.dart
View file @
0b460b5e
...
@@ -15,9 +15,9 @@ class PermissionHandler {
...
@@ -15,9 +15,9 @@ class PermissionHandler {
factory
PermissionHandler
()
{
factory
PermissionHandler
()
{
if
(
_instance
==
null
)
{
if
(
_instance
==
null
)
{
const
MethodChannel
methodChannel
=
const
MethodChannel
methodChannel
=
const
MethodChannel
(
'flutter.baseflow.com/permissions/methods'
);
MethodChannel
(
'flutter.baseflow.com/permissions/methods'
);
_instance
=
new
PermissionHandler
.
private
(
methodChannel
);
_instance
=
PermissionHandler
.
private
(
methodChannel
);
}
}
return
_instance
;
return
_instance
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment