Skip to content

Commit

Permalink
Fix warnings & code tidying (theyakka#19)
Browse files Browse the repository at this point in the history
* fix warnings & code tidying. bump copyright
* bump minor version and prep for pub
  • Loading branch information
lukef authored Jan 16, 2019
1 parent 574f07a commit 65db71e
Show file tree
Hide file tree
Showing 12 changed files with 312 additions and 88 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.1.6
- Adds analyzer configuration
- Fixes linting issues
- Migrate to Dart 2.x friendly syntax
- Tidy some initialization logic / code
- Bump copyright

# 1.1.5
- Add image data export functions (see `test/painter_tests.dart` for an example)

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
QR.Flutter

Copyright (c) 2018 the QR.Flutter authors.
Copyright (c) 2019 the QR.Flutter authors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can install the package by adding the following lines to your `pubspec.yaml`

```yaml
dependencies:
qr_flutter: ^1.1.5
qr_flutter: ^1.1.6
```
After adding the dependency to your `pubspec.yaml` you can run: `flutter packages get` or update your packages using
Expand Down
102 changes: 102 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
analyzer:
strong-mode:
implicit-dynamic: false
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
exclude:
- '.idea/**'
- 'android/**'
- 'assets/**'
- 'build/**'
- 'ios/**'
- 'res/**'
- 'example/**'

linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
- avoid_as
- avoid_empty_else
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_slow_async_io
- avoid_types_as_parameter_names
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_final_locals
- prefer_foreach
- prefer_generic_function_type_aliases
- prefer_initializing_formals
- prefer_is_empty
- prefer_is_not_empty
- prefer_iterable_whereType
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- recursive_getters
- slash_for_doc_comments
- sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
- test_types_in_equals
- throw_in_finally
- type_init_formals
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- unnecessary_this
- unrelated_type_equality_checks
- use_rethrow_when_possible
- valid_regexps
102 changes: 102 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
analyzer:
strong-mode:
implicit-dynamic: false
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
exclude:
- '.idea/**'
- 'android/**'
- 'assets/**'
- 'build/**'
- 'ios/**'
- 'res/**'
- 'example/**'

linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
- avoid_as
- avoid_empty_else
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_slow_async_io
- avoid_types_as_parameter_names
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_final_locals
- prefer_foreach
- prefer_generic_function_type_aliases
- prefer_initializing_formals
- prefer_is_empty
- prefer_is_not_empty
- prefer_iterable_whereType
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- recursive_getters
- slash_for_doc_comments
- sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
- test_types_in_equals
- throw_in_finally
- type_init_formals
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- unnecessary_this
- unrelated_type_equality_checks
- use_rethrow_when_possible
- valid_regexps
9 changes: 5 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import 'package:flutter/material.dart';

import 'screens/main.screen.dart';

void main() => runApp(new App());
void main() => runApp(App());

class App extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'QR code demo',
theme: new ThemeData(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: new MainScreen(),
home: MainScreen(),
debugShowCheckedModeBanner: false,
);
}
}
70 changes: 37 additions & 33 deletions example/lib/screens/main.screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,64 @@ import 'package:qr_flutter/qr_flutter.dart';

class MainScreen extends StatefulWidget {
@override
_MainScreenState createState() => new _MainScreenState();
_MainScreenState createState() => _MainScreenState();
}

class _MainScreenState extends State<MainScreen> {
static const double _topSectionTopPadding = 50.0;
static const double _topSectionBottomPadding = 20.0;
static const double _topSectionHeight = 50.0;

String _dataString = "Hello from this QR code!";
String _dataString = 'Hello from this QR code!';
String _inputErrorText;
final TextEditingController _textController = new TextEditingController();
final TextEditingController _textController = TextEditingController();

@override
Widget build(BuildContext context) {
return new Scaffold(
return Scaffold(
body: _contentWidget(),
resizeToAvoidBottomPadding: true,
);
}

@override
didUpdateWidget(Widget oldWidget) {
void didUpdateWidget(MainScreen oldWidget) {
super.didUpdateWidget(oldWidget);
setState(() {});
}

_contentWidget() {
final bodyHeight = MediaQuery.of(context).size.height -
MediaQuery.of(context).viewInsets.bottom;
return new Container(
Widget _contentWidget() {
return Container(
color: const Color(0xFFFFFFFF),
child: new Column(
child: Column(
children: <Widget>[
new Padding(
Padding(
padding: const EdgeInsets.only(
top: _topSectionTopPadding,
left: 20.0,
right: 10.0,
left: 30.0,
right: 20.0,
bottom: _topSectionBottomPadding,
),
child: new Container(
child: Container(
height: _topSectionHeight,
child: new Row(
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new Expanded(
child: new TextField(
Expanded(
child: TextField(
autofocus: true,
controller: _textController,
decoration: new InputDecoration(
hintText: "Enter a custom message",
decoration: InputDecoration(
hintText: 'Enter a custom message',
errorText: _inputErrorText,
),
),
),
new Padding(
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: new FlatButton(
child: new Text("SUBMIT"),
child: FlatButton(
child: const Text('SUBMIT'),
onPressed: () {
setState(() {
_dataString = _textController.text;
Expand All @@ -74,17 +73,22 @@ class _MainScreenState extends State<MainScreen> {
),
),
),
new Expanded(
child: new Center(
child: new QrImage(
data: _dataString,
onError: (ex) {
print("[QR] ERROR - $ex");
setState(() {
_inputErrorText =
"Error! Maybe your input value is too long?";
});
},
Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.all(25.0),
child: QrImage(
data: _dataString,
gapless: false,
foregroundColor: const Color(0xFF111111),
onError: (dynamic ex) {
print('[QR] ERROR - $ex');
setState(() {
_inputErrorText =
'Error! Maybe your input value is too long?';
});
},
),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/qr_flutter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* QR.Flutter
* Copyright (c) 2018 the QR.Flutter authors.
* Copyright (c) 2019 the QR.Flutter authors.
* See LICENSE for distribution and usage details.
*/
export 'src/qr_image.dart';
Expand Down
Loading

0 comments on commit 65db71e

Please sign in to comment.