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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
46 deletions
+67
-46
analysis_options.yaml
+30
-22
example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
+8
-0
example/lib/main.dart
+27
-22
lib/permission_handler.dart
+2
-2
No files found.
analysis_options.yaml
View file @
0b460b5e
...
...
@@ -7,7 +7,9 @@
# See the configuration guide for more
# 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)
# - packages/flutter/lib/analysis_options_user.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
...
...
@@ -15,13 +17,8 @@
#
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# 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
:
language
:
enableSuperMixins
:
true
strong-mode
:
implicit-dynamic
:
false
errors
:
...
...
@@ -67,38 +64,43 @@ linter:
-
avoid_relative_lib_imports
-
avoid_renaming_method_parameters
-
avoid_return_types_on_setters
# - avoid_returning_null #
we do this commonly
# - avoid_returning_this #
https://github.com/dart-lang/linter/issues/842
# - avoid_returning_null #
there are plenty of valid reasons to return null
# - avoid_returning_this #
there are plenty of valid reasons to return this
# - avoid_setters_without_getters # not yet tested
# - avoid_single_cascade_in_expression_statements # not yet tested
-
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_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
-
avoid_unused_constructor_parameters
-
avoid_void_async
-
await_only_futures
-
camel_case_types
-
cancel_subscriptions
# - cascade_invocations # not yet tested
# - close_sinks #
https://github.com/flutter/flutter/issues/5789
# - comment_references # blocked on https://github.com/
dart-lang/dartdoc/issues/1153
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
# - close_sinks #
not reliable enough
# - comment_references # blocked on https://github.com/
flutter/flutter/issues/20765
# - constant_identifier_names #
needs an opt-out
https://github.com/dart-lang/linter/issues/204
-
control_flow_in_finally
# - curly_braces_in_flow_control_structures # not yet tested
-
directives_ordering
-
empty_catches
-
empty_constructor_bodies
-
empty_statements
# - file_names # not yet tested
-
hash_and_equals
-
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
# - join_return_with_assignment # not yet tested
-
library_names
-
library_prefixes
# - lines_longer_than_80_chars # not yet tested
-
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_duplicate_case_values
-
non_constant_identifier_names
# - null_closures # not yet tested
# - omit_local_variable_types # opposite of always_specify_types
# - one_member_abstracts # too many false positives
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
...
...
@@ -124,13 +126,17 @@ linter:
-
prefer_final_locals
-
prefer_foreach
# - prefer_function_declarations_over_variables # not yet tested
-
prefer_generic_function_type_aliases
-
prefer_initializing_formals
# - prefer_interpolation_to_compose_strings # not yet tested
# - prefer_iterable_whereType # https://github.com/dart-lang/sdk/issues/32463
-
prefer_is_empty
-
prefer_is_not_empty
-
prefer_iterable_whereType
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
-
prefer_single_quotes
-
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
-
slash_for_doc_comments
-
sort_constructors_first
...
...
@@ -140,21 +146,22 @@ linter:
-
throw_in_finally
# - type_annotate_public_apis # subset of always_specify_types
-
type_init_formals
# - unawaited_futures #
https://github.com/flutter/flutter/issues/5793
# - unawaited_futures #
too many false positives
-
unnecessary_brace_in_string_interps
#
- unnecessary_const
-
unnecessary_const
-
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_in_if_null_operators
-
unnecessary_overrides
-
unnecessary_parenthesis
# - unnecessary_statements # not yet tested
-
unnecessary_statements
-
unnecessary_this
-
unrelated_type_equality_checks
-
use_rethrow_when_possible
# - 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
-
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';
import
'package:flutter/material.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
void
main
(
)
=>
runApp
(
new
MyApp
());
void
main
(
)
=>
runApp
(
MyApp
());
class
MyApp
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
new
MaterialApp
(
home:
new
Scaffold
(
appBar:
new
AppBar
(
return
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Plugin example app'
),
actions:
<
Widget
>[
IconButton
(
...
...
@@ -21,8 +21,8 @@ class MyApp extends StatelessWidget {
)
],
),
body:
new
Center
(
child:
new
ListView
(
body:
Center
(
child:
ListView
(
children:
PermissionGroup
.
values
.
where
((
PermissionGroup
permission
)
{
if
(
Platform
.
isIOS
)
{
...
...
@@ -38,7 +38,7 @@ class MyApp extends StatelessWidget {
}
})
.
map
((
PermissionGroup
permission
)
=>
new
PermissionWidget
(
permission
))
PermissionWidget
(
permission
))
.
toList
()),
),
));
...
...
@@ -67,12 +67,14 @@ class _PermissionState extends State<PermissionWidget> {
_listenForPermissionStatus
();
}
void
_listenForPermissionStatus
()
async
{
final
PermissionStatus
status
=
await
PermissionHandler
().
checkPermissionStatus
(
_permissionGroup
);
void
_listenForPermissionStatus
()
{
final
Future
<
PermissionStatus
>
statusFuture
=
PermissionHandler
().
checkPermissionStatus
(
_permissionGroup
);
setState
(()
{
_permissionStatus
=
status
;
statusFuture
.
then
((
PermissionStatus
status
)
{
setState
(()
{
_permissionStatus
=
status
;
});
});
}
...
...
@@ -89,11 +91,11 @@ class _PermissionState extends State<PermissionWidget> {
@override
Widget
build
(
BuildContext
context
)
{
return
new
ListTile
(
title:
new
Text
(
_permissionGroup
.
toString
()),
subtitle:
new
Text
(
return
ListTile
(
title:
Text
(
_permissionGroup
.
toString
()),
subtitle:
Text
(
_permissionStatus
.
toString
(),
style:
new
TextStyle
(
color:
getPermissionColor
()),
style:
TextStyle
(
color:
getPermissionColor
()),
),
onTap:
()
async
{
requestPermission
(
_permissionGroup
);
...
...
@@ -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
Map
<
PermissionGroup
,
PermissionStatus
>
permissionRequestResult
=
await
PermissionHandler
().
requestPermissions
(
permissions
);
setState
(()
{
_permissionStatus
=
permissionRequestResult
[
permission
];
final
Future
<
Map
<
PermissionGroup
,
PermissionStatus
>>
requestFuture
=
PermissionHandler
().
requestPermissions
(
permissions
);
requestFuture
.
then
((
Map
<
PermissionGroup
,
PermissionStatus
>
permissionRequestResult
)
{
setState
(()
{
_permissionStatus
=
permissionRequestResult
[
permission
];
});
});
}
}
lib/permission_handler.dart
View file @
0b460b5e
...
...
@@ -15,9 +15,9 @@ class PermissionHandler {
factory
PermissionHandler
()
{
if
(
_instance
==
null
)
{
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
;
}
...
...
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