diff --git a/annotation/CHANGELOG.md b/annotation/CHANGELOG.md index acb2c0c..a1e4ab0 100644 --- a/annotation/CHANGELOG.md +++ b/annotation/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.0.2] - November 2nd, 2023 + +* Updated [flutter_lints](https://pub.dev/packages/flutter_lints) to `3.0.0` + + ## [1.0.1+1] - August 29, 2023 * Automated dependency updates diff --git a/annotation/analysis_options.yaml b/annotation/analysis_options.yaml new file mode 100644 index 0000000..cc6f1cb --- /dev/null +++ b/annotation/analysis_options.yaml @@ -0,0 +1,21 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + - always_declare_return_types + - avoid_equals_and_hash_code_on_mutable_classes + - avoid_escaping_inner_quotes + - avoid_slow_async_io + - cancel_subscriptions + - close_sinks + - directives_ordering + - empty_constructor_bodies + - omit_local_variable_types + - prefer_final_locals + - prefer_single_quotes + - sort_child_properties_last + - sort_constructors_first + - sort_pub_dependencies + - sort_unnamed_constructors_first + - unawaited_futures + - use_full_hex_values_for_flutter_colors diff --git a/annotation/pubspec.yaml b/annotation/pubspec.yaml index 1bed552..ba38b4a 100644 --- a/annotation/pubspec.yaml +++ b/annotation/pubspec.yaml @@ -1,21 +1,21 @@ name: 'json_theme_annotation' description: 'Simple package holding the annotations needed by the JsonTheme code generator.' homepage: 'https://github.com/peiffer-innovations/json_theme' -version: '1.0.1+1' +version: '1.0.2' -environment: +environment: sdk: '>=3.0.0 <4.0.0' -analyzer: - exclude: +analyzer: + exclude: - 'lib/generated/**' - 'lib/**/*.g.dart' - -dev_dependencies: +dev_dependencies: + flutter_lints: '^3.0.0' test: '^1.24.6' -ignore_updates: +ignore_updates: - 'archive' - 'async' - 'boolean_selector' diff --git a/codegen/CHANGELOG.md b/codegen/CHANGELOG.md index da130dc..b4a773e 100644 --- a/codegen/CHANGELOG.md +++ b/codegen/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.1.2] - November 2nd, 2023 + +* Updated [flutter_lints](https://pub.dev/packages/flutter_lints) to `3.0.0` + + ## [1.1.1] - September 3rd, 2023 * Dependency updates diff --git a/codegen/analysis_options.yaml b/codegen/analysis_options.yaml new file mode 100644 index 0000000..cc6f1cb --- /dev/null +++ b/codegen/analysis_options.yaml @@ -0,0 +1,21 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + - always_declare_return_types + - avoid_equals_and_hash_code_on_mutable_classes + - avoid_escaping_inner_quotes + - avoid_slow_async_io + - cancel_subscriptions + - close_sinks + - directives_ordering + - empty_constructor_bodies + - omit_local_variable_types + - prefer_final_locals + - prefer_single_quotes + - sort_child_properties_last + - sort_constructors_first + - sort_pub_dependencies + - sort_unnamed_constructors_first + - unawaited_futures + - use_full_hex_values_for_flutter_colors diff --git a/codegen/pubspec.yaml b/codegen/pubspec.yaml index 3301c1f..69ffca1 100644 --- a/codegen/pubspec.yaml +++ b/codegen/pubspec.yaml @@ -1,7 +1,7 @@ name: 'json_theme_codegen' description: 'A library to generate the mapping of decoders to the class names they decode' homepage: 'https://github.com/peiffer-innovations/json_theme' -version: '1.1.1' +version: '1.1.2' environment: sdk: '>=3.0.0 <4.0.0' @@ -21,6 +21,7 @@ dependencies: source_gen: '^1.4.0' dev_dependencies: + flutter_lints: '^3.0.0' test: '^1.24.6' dependency_overrides: diff --git a/json_theme/CHANGELOG.md b/json_theme/CHANGELOG.md index 2d3f33e..93c065b 100644 --- a/json_theme/CHANGELOG.md +++ b/json_theme/CHANGELOG.md @@ -1,3 +1,8 @@ +## [6.3.1] - November 2nd, 2023 + +* Updated [flutter_lints](https://pub.dev/packages/flutter_lints) to `3.0.0` + + ## [6.3.0] - September 27th, 2023 * Added codecs for: diff --git a/json_theme/example/lib/main.dart b/json_theme/example/lib/main.dart index 315a91d..1ec2e63 100644 --- a/json_theme/example/lib/main.dart +++ b/json_theme/example/lib/main.dart @@ -12,8 +12,8 @@ void main() { class MyApp extends StatelessWidget { const MyApp({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context) { @@ -23,11 +23,16 @@ class MyApp extends StatelessWidget { } } -class RootPage extends StatelessWidget { +class RootPage extends StatefulWidget { const RootPage({ - Key? key, - }) : super(key: key); + super.key, + }); + @override + State createState() => _RootPageState(); +} + +class _RootPageState extends State { static const _themes = [ 'default', 'big_red', @@ -44,13 +49,15 @@ class RootPage extends StatelessWidget { ) ?? ThemeData(); - await Navigator.of(context).push( - MaterialPageRoute( - builder: (BuildContext context) => ThemePage( - theme: theme, + if (mounted) { + await Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) => ThemePage( + theme: theme, + ), ), - ), - ); + ); + } } @override diff --git a/json_theme/example/lib/src/example_form.dart b/json_theme/example/lib/src/example_form.dart index 36a285a..62fdfb3 100644 --- a/json_theme/example/lib/src/example_form.dart +++ b/json_theme/example/lib/src/example_form.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:form_validation/form_validation.dart'; class ExampleForm extends StatefulWidget { - ExampleForm({ - Key? key, - }) : super(key: key); + const ExampleForm({ + super.key, + }); @override - _ExampleFormState createState() => _ExampleFormState(); + State createState() => _ExampleFormState(); } class _ExampleFormState extends State { @@ -511,7 +511,7 @@ class _ExampleFormState extends State { } List _createCountryList() { - final str = '''Afghanistan + const str = '''Afghanistan Albania Algeria Andorra diff --git a/json_theme/example/lib/src/theme_page.dart b/json_theme/example/lib/src/theme_page.dart index be7ebcc..de267f7 100644 --- a/json_theme/example/lib/src/theme_page.dart +++ b/json_theme/example/lib/src/theme_page.dart @@ -3,10 +3,9 @@ import 'package:flutter/material.dart'; class ThemePage extends StatelessWidget { ThemePage({ - Key? key, + super.key, ThemeData? theme, - }) : theme = theme ?? ThemeData(), - super(key: key); + }) : theme = theme ?? ThemeData(); final ThemeData theme; @@ -19,7 +18,7 @@ class ThemePage extends StatelessWidget { appBar: AppBar( title: const Text('Themed Page'), ), - body: SingleChildScrollView( + body: const SingleChildScrollView( child: ExampleForm(), ), ), diff --git a/json_theme/example/pubspec.yaml b/json_theme/example/pubspec.yaml index 118a828..ee6f398 100644 --- a/json_theme/example/pubspec.yaml +++ b/json_theme/example/pubspec.yaml @@ -3,50 +3,42 @@ description: 'Example application for the JSON Theme' publish_to: 'none' version: '1.0.0+36' -environment: +environment: sdk: '>=3.0.0 <4.0.0' -dependencies: - flutter: +dependencies: + flutter: sdk: 'flutter' form_validation: '^3.0.2+2' google_fonts: '^5.1.0' intl: '^0.18.1' - json_theme: + json_theme: path: '../' meta: '^1.9.1' -dev_dependencies: - flutter_test: +dev_dependencies: + flutter_lints: '^3.0.0' + flutter_test: sdk: 'flutter' - -flutter: +flutter: uses-material-design: true - assets: + assets: - 'assets/themes/' - fonts: - - - family: 'lato' - fonts: - - - asset: 'assets/fonts/Lato-Regular.ttf' - - - - family: 'metal' - fonts: - - - asset: 'assets/fonts/MetalMania-Regular.ttf' - - - - family: 'MaterialIcons' - fonts: - - - asset: 'assets/fonts/MaterialIcons-Regular.ttf' + fonts: + - family: 'lato' + fonts: + - asset: 'assets/fonts/Lato-Regular.ttf' + - family: 'metal' + fonts: + - asset: 'assets/fonts/MetalMania-Regular.ttf' + - family: 'MaterialIcons' + fonts: + - asset: 'assets/fonts/MaterialIcons-Regular.ttf' -ignore_updates: +ignore_updates: - 'archive' - 'async' - 'boolean_selector' diff --git a/json_theme/pubspec.yaml b/json_theme/pubspec.yaml index a2c7c40..aaeed90 100644 --- a/json_theme/pubspec.yaml +++ b/json_theme/pubspec.yaml @@ -1,7 +1,7 @@ name: 'json_theme' description: 'A library to dynamically generate a ThemeData object from a JSON file or dynamic map object' homepage: 'https://github.com/peiffer-innovations/json_theme' -version: '6.3.0' +version: '6.3.1' environment: sdk: '>=3.0.0 <4.0.0' @@ -25,7 +25,7 @@ dev_dependencies: build: '^2.4.1' build_runner: '^2.4.6' code_builder: '^4.7.0' - flutter_lints: '^2.0.2' + flutter_lints: '^3.0.0' flutter_test: sdk: 'flutter' json_theme_codegen: '^1.1.0' diff --git a/json_theme/test/json_theme_test.dart b/json_theme/test/json_theme_test.dart index aef2fb2..df76af7 100644 --- a/json_theme/test/json_theme_test.dart +++ b/json_theme/test/json_theme_test.dart @@ -5107,6 +5107,17 @@ void main() { expect(ThemeDecoder.decodeMaterialStatePropertyBool(null), null); expect(ThemeEncoder.encodeMaterialStatePropertyBool(null), null); + final stateMap = { + MaterialState.disabled: 'disabled', + MaterialState.dragged: 'dragged', + MaterialState.error: 'error', + MaterialState.focused: 'focused', + MaterialState.hovered: 'hovered', + MaterialState.pressed: 'pressed', + MaterialState.scrolledUnder: 'scrolledUnder', + MaterialState.selected: 'selected', + }; + final states = { 'disabled': MaterialState.disabled, 'dragged': MaterialState.dragged, @@ -5146,12 +5157,12 @@ void main() { } bool? func(Set states) => - states.isEmpty ? null : values[states.first]; + states.isEmpty ? null : values[stateMap[states.first]!]; final prop = MaterialStateProperty.resolveWith(func); final decoded = ThemeDecoder.decodeMaterialStatePropertyBool(prop); for (var entry in states.entries) { - final value = values[entry.value]; + final value = values[stateMap[entry.value]!]; expect(decoded!.resolve({entry.value}), value); @@ -5259,6 +5270,16 @@ void main() { expect(ThemeDecoder.decodeMaterialStatePropertyColor(null), null); expect(ThemeEncoder.encodeMaterialStatePropertyColor(null), null); + final stateMap = { + MaterialState.disabled: 'disabled', + MaterialState.dragged: 'dragged', + MaterialState.error: 'error', + MaterialState.focused: 'focused', + MaterialState.hovered: 'hovered', + MaterialState.pressed: 'pressed', + MaterialState.scrolledUnder: 'scrolledUnder', + MaterialState.selected: 'selected', + }; final states = { 'disabled': MaterialState.disabled, 'dragged': MaterialState.dragged, @@ -5298,13 +5319,14 @@ void main() { expect(encoded![stateKey], colorStr); } - Color? func(Set states) => - states.isEmpty ? null : ThemeDecoder.decodeColor(colors[states.first]); + Color? func(Set states) => states.isEmpty + ? null + : ThemeDecoder.decodeColor(colors[stateMap[states.first]]); final prop = MaterialStateProperty.resolveWith(func); final decoded = ThemeDecoder.decodeMaterialStatePropertyColor(prop); for (var entry in states.entries) { - final colorStr = colors[entry.value]; + final colorStr = colors[stateMap[entry.value]]; final color = ThemeDecoder.decodeColor(colorStr); expect(decoded!.resolve({entry.value}), color); @@ -5347,6 +5369,16 @@ void main() { test('MaterialStatePropertyDouble', () { expect(ThemeDecoder.decodeMaterialStatePropertyDouble(null), null); expect(ThemeEncoder.encodeMaterialStatePropertyDouble(null), null); + final stateMap = { + MaterialState.disabled: 'disabled', + MaterialState.dragged: 'dragged', + MaterialState.error: 'error', + MaterialState.focused: 'focused', + MaterialState.hovered: 'hovered', + MaterialState.pressed: 'pressed', + MaterialState.scrolledUnder: 'scrolledUnder', + MaterialState.selected: 'selected', + }; final states = { 'disabled': MaterialState.disabled, @@ -5388,12 +5420,12 @@ void main() { } double? func(Set states) => - states.isEmpty ? null : values[states.first]; + states.isEmpty ? null : values[stateMap[states.first]]; final prop = MaterialStateProperty.resolveWith(func); final decoded = ThemeDecoder.decodeMaterialStatePropertyDouble(prop); for (var entry in states.entries) { - final value = values[entry.value]; + final value = values[stateMap[entry.value]]; expect(decoded!.resolve({entry.value}), value); @@ -5594,6 +5626,16 @@ void main() { test('MaterialStatePropertyMouseCursor', () { expect(ThemeDecoder.decodeMaterialStatePropertyColor(null), null); expect(ThemeEncoder.encodeMaterialStatePropertyColor(null), null); + final stateMap = { + MaterialState.disabled: 'disabled', + MaterialState.dragged: 'dragged', + MaterialState.error: 'error', + MaterialState.focused: 'focused', + MaterialState.hovered: 'hovered', + MaterialState.pressed: 'pressed', + MaterialState.scrolledUnder: 'scrolledUnder', + MaterialState.selected: 'selected', + }; final states = { 'disabled': MaterialState.disabled, @@ -5637,13 +5679,13 @@ void main() { MouseCursor? func(Set states) => states.isEmpty ? null - : ThemeDecoder.decodeMouseCursor(cursors[states.first]); + : ThemeDecoder.decodeMouseCursor(cursors[stateMap[states.first]]); final prop = MaterialStateProperty.resolveWith(func); final decoded = ThemeDecoder.decodeMaterialStatePropertyMouseCursor(prop); for (var entry in states.entries) { - final cursorStr = cursors[entry.value]; - final cursor = ThemeDecoder.decodeColor(cursorStr); + final cursorStr = cursors[stateMap[entry.value]]; + final cursor = ThemeDecoder.decodeMouseCursor(cursorStr); expect(decoded!.resolve({entry.value}), cursor);