From 398b6cd014dfeb0de8632c443caa2e98cded2033 Mon Sep 17 00:00:00 2001 From: Job Guldemeester Date: Fri, 28 Mar 2025 09:58:59 +0100 Subject: [PATCH 1/6] :arrow_up: Updated dependencies --- example/.gitignore | 2 + .../xcshareddata/xcschemes/Runner.xcscheme | 1 + .../profile/data/model/api_user_response.dart | 2 +- example/lib/profile/data/model/location.dart | 2 +- example/lib/profile/data/model/name.dart | 2 +- example/lib/profile/data/model/picture.dart | 2 +- example/lib/profile/data/model/street.dart | 2 +- example/lib/profile/data/model/user.dart | 2 +- example/lib/profile/data/user_service.dart | 4 +- .../presentation/cubit/user_state.dart | 2 +- example/pubspec.lock | 166 +++++++++--------- example/pubspec.yaml | 30 ++-- lib/chopper/color_converter.dart | 3 +- lib/chopper/datetime_converter.dart | 2 +- lib/common/result/result.dart | 40 ++--- pubspec.lock | 110 ++++++------ pubspec.yaml | 18 +- test/common/result/try_call_test.dart | 34 ++-- 18 files changed, 202 insertions(+), 222 deletions(-) diff --git a/example/.gitignore b/example/.gitignore index 29a3a50..79c113f 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -5,9 +5,11 @@ *.swp .DS_Store .atom/ +.build/ .buildlog/ .history .svn/ +.swiftpm/ migrate_working_dir/ # IntelliJ related diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 8e3ca5d..15cada4 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -59,6 +59,7 @@ ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" + enableGPUValidationMode = "1" allowLocationSimulation = "YES"> diff --git a/example/lib/profile/data/model/api_user_response.dart b/example/lib/profile/data/model/api_user_response.dart index 545fbfc..2c46b4d 100644 --- a/example/lib/profile/data/model/api_user_response.dart +++ b/example/lib/profile/data/model/api_user_response.dart @@ -6,7 +6,7 @@ part 'api_user_response.freezed.dart'; part 'api_user_response.g.dart'; @freezed -class ApiUserResponse with _$ApiUserResponse { +sealed class ApiUserResponse with _$ApiUserResponse { const factory ApiUserResponse({ required List results, }) = _ApiUserResponse; diff --git a/example/lib/profile/data/model/location.dart b/example/lib/profile/data/model/location.dart index 004cbbd..ab6f287 100644 --- a/example/lib/profile/data/model/location.dart +++ b/example/lib/profile/data/model/location.dart @@ -6,7 +6,7 @@ part 'location.freezed.dart'; part 'location.g.dart'; @freezed -class Location with _$Location { +sealed class Location with _$Location { const factory Location({ required Street street, required String city, diff --git a/example/lib/profile/data/model/name.dart b/example/lib/profile/data/model/name.dart index 5065521..4f22a6a 100644 --- a/example/lib/profile/data/model/name.dart +++ b/example/lib/profile/data/model/name.dart @@ -4,7 +4,7 @@ part 'name.freezed.dart'; part 'name.g.dart'; @freezed -class Name with _$Name { +sealed class Name with _$Name { const factory Name({ required String title, required String first, diff --git a/example/lib/profile/data/model/picture.dart b/example/lib/profile/data/model/picture.dart index 2e81872..3614580 100644 --- a/example/lib/profile/data/model/picture.dart +++ b/example/lib/profile/data/model/picture.dart @@ -4,7 +4,7 @@ part 'picture.freezed.dart'; part 'picture.g.dart'; @freezed -class Picture with _$Picture { +sealed class Picture with _$Picture { const factory Picture({ required String large, required String medium, diff --git a/example/lib/profile/data/model/street.dart b/example/lib/profile/data/model/street.dart index 2a50464..77aa675 100644 --- a/example/lib/profile/data/model/street.dart +++ b/example/lib/profile/data/model/street.dart @@ -4,7 +4,7 @@ part 'street.freezed.dart'; part 'street.g.dart'; @freezed -class Street with _$Street { +sealed class Street with _$Street { const factory Street({ required int number, required String name, diff --git a/example/lib/profile/data/model/user.dart b/example/lib/profile/data/model/user.dart index a4afd38..520c2b3 100644 --- a/example/lib/profile/data/model/user.dart +++ b/example/lib/profile/data/model/user.dart @@ -8,7 +8,7 @@ part 'user.freezed.dart'; part 'user.g.dart'; @freezed -class User with _$User { +sealed class User with _$User { const factory User({ required String gender, required Name name, diff --git a/example/lib/profile/data/user_service.dart b/example/lib/profile/data/user_service.dart index a22194b..510241b 100644 --- a/example/lib/profile/data/user_service.dart +++ b/example/lib/profile/data/user_service.dart @@ -9,10 +9,10 @@ part 'user_service.chopper.dart'; @ChopperApi(baseUrl: 'https://randomuser.me/api/') @singleton abstract class UserService extends ChopperService { - @Get() + @GET() Future getRandomUser(); - @Get() + @GET() Future getRandomUserFails() { throw CheckedFromJsonException({}, null, '', ''); } diff --git a/example/lib/profile/presentation/cubit/user_state.dart b/example/lib/profile/presentation/cubit/user_state.dart index d66b220..1e7fca2 100644 --- a/example/lib/profile/presentation/cubit/user_state.dart +++ b/example/lib/profile/presentation/cubit/user_state.dart @@ -1,7 +1,7 @@ part of 'user_cubit.dart'; @freezed -class UserState with _$UserState { +sealed class UserState with _$UserState { const factory UserState({ User? user, }) = _UserState; diff --git a/example/pubspec.lock b/example/pubspec.lock index f520e5e..758d8c6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -34,10 +34,10 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.12.0" bloc: dependency: transitive description: @@ -58,18 +58,18 @@ packages: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" build: dependency: transitive description: name: build - sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0 url: "https://pub.dev" source: hosted - version: "2.4.1" + version: "2.4.2" build_config: dependency: transitive description: @@ -90,26 +90,26 @@ packages: dependency: transitive description: name: build_resolvers - sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + sha256: b9e4fda21d846e192628e7a4f6deda6888c36b5b69ba02ff291a01fd529140f0 url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.4.4" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d" + sha256: "058fe9dce1de7d69c4b84fada934df3e0153dd000758c4d65964d0166779aa99" url: "https://pub.dev" source: hosted - version: "2.4.13" + version: "2.4.15" build_runner_core: dependency: transitive description: name: build_runner_core - sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0 + sha256: "22e3aa1c80e0ada3722fe5b63fd43d9c8990759d0a2cf489c8c5d7b2bdebc021" url: "https://pub.dev" source: hosted - version: "7.3.2" + version: "8.0.0" built_collection: dependency: transitive description: @@ -130,10 +130,10 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" checked_yaml: dependency: transitive description: @@ -146,42 +146,42 @@ packages: dependency: "direct main" description: name: chopper - sha256: "40899b729fb6d8969d967264b189efaf2452bc3ccf6ed0782d00f1d8a6161c31" + sha256: "18928a74069cf1c257e657809c1b84b0304d8e32a6fc446dd2bbb28657e0358a" url: "https://pub.dev" source: hosted - version: "8.0.3" + version: "8.1.0" chopper_generator: dependency: "direct dev" description: name: chopper_generator - sha256: de438569cba1e2a2888e8d91e3c2ac60106574eea7f36823ed0334e96146328a + sha256: "2cb23febc9ac9bbc9288b4703e60f3edc8e301a2ef5057d0c22369eab7313c6d" url: "https://pub.dev" source: hosted - version: "8.0.3" + version: "8.1.0" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" code_builder: dependency: transitive description: name: code_builder - sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 + sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" url: "https://pub.dev" source: hosted - version: "4.10.0" + version: "4.10.1" collection: dependency: "direct main" description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.19.1" convert: dependency: transitive description: @@ -202,17 +202,17 @@ packages: dependency: transitive description: name: dart_style - sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" + sha256: "27eb0ae77836989a3bc541ce55595e8ceee0992807f14511552a898ddd0d88ac" url: "https://pub.dev" source: hosted - version: "2.3.7" + version: "3.0.1" dcc_toolkit: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.0.10" + version: "0.0.11" equatable: dependency: transitive description: @@ -225,10 +225,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" file: dependency: transitive description: @@ -254,18 +254,18 @@ packages: dependency: "direct main" description: name: flutter_bloc - sha256: "153856bdaac302bbdc58a1d1403d50c40557254aa05eaeed40515d88a25a526b" + sha256: "1046d719fbdf230330d3443187cc33cc11963d15c9089f6cc56faa42a4c5f0cc" url: "https://pub.dev" source: hosted - version: "9.0.0" + version: "9.1.0" flutter_lints: dependency: "direct dev" description: name: flutter_lints - sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c" + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "5.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -275,18 +275,18 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "44c19278dd9d89292cf46e97dc0c1e52ce03275f40a97c5a348e802a924bf40e" + sha256: "7ed2ddaa47524976d5f2aa91432a79da36a76969edd84170777ac5bea82d797c" url: "https://pub.dev" source: hosted - version: "2.5.7" + version: "3.0.4" freezed_annotation: dependency: "direct main" description: name: freezed_annotation - sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + sha256: c87ff004c8aa6af2d531668b46a4ea379f7191dc6dfa066acd53d506da6e044b url: "https://pub.dev" source: hosted - version: "2.4.4" + version: "3.0.0" frontend_server_client: dependency: transitive description: @@ -299,10 +299,10 @@ packages: dependency: "direct main" description: name: get_it - sha256: d85128a5dae4ea777324730dc65edd9c9f43155c109d5cc0a69cab74139fbac1 + sha256: f126a3e286b7f5b578bf436d5592968706c4c1de28a228b870ce375d9f743103 url: "https://pub.dev" source: hosted - version: "7.7.0" + version: "8.0.3" glob: dependency: transitive description: @@ -323,10 +323,10 @@ packages: dependency: transitive description: name: http - sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.3.0" http_multi_server: dependency: transitive description: @@ -355,18 +355,18 @@ packages: dependency: "direct dev" description: name: injectable_generator - sha256: af403d76c7b18b4217335e0075e950cd0579fd7f8d7bd47ee7c85ada31680ba1 + sha256: b04673a4c88b3a848c0c77bf58b8309f9b9e064d9fe1df5450c8ee1675eaea1a url: "https://pub.dev" source: hosted - version: "2.6.2" + version: "2.7.0" intl: dependency: transitive description: name: intl - sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" url: "https://pub.dev" source: hosted - version: "0.19.0" + version: "0.20.2" io: dependency: transitive description: @@ -395,26 +395,26 @@ packages: dependency: "direct dev" description: name: json_serializable - sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b + sha256: "81f04dee10969f89f604e1249382d46b97a1ccad53872875369622b5bfc9e58a" url: "https://pub.dev" source: hosted - version: "6.8.0" + version: "6.9.4" leak_tracker: dependency: transitive description: name: leak_tracker - sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.7" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.0.9" leak_tracker_testing: dependency: transitive description: @@ -427,10 +427,10 @@ packages: dependency: transitive description: name: lints - sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "5.1.1" logging: dependency: transitive description: @@ -451,10 +451,10 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" material_color_utilities: dependency: transitive description: @@ -467,10 +467,10 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.0" mime: dependency: transitive description: @@ -499,10 +499,10 @@ packages: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" pool: dependency: transitive description: @@ -539,10 +539,10 @@ packages: dependency: transitive description: name: qs_dart - sha256: be73d060d29c0716ded88380ba32e87ce8105f0ba234edb3edefa0d74d47d64b + sha256: c775dbe663cd59365050220b3499dee259b72ad6b352a3e087a15bd77e161b74 url: "https://pub.dev" source: hosted - version: "1.2.4" + version: "1.3.3+1" recase: dependency: transitive description: @@ -584,42 +584,42 @@ packages: dependency: transitive description: name: source_gen - sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b" url: "https://pub.dev" source: hosted - version: "1.5.0" + version: "2.0.0" source_helper: dependency: transitive description: name: source_helper - sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd" + sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c" url: "https://pub.dev" source: hosted - version: "1.3.4" + version: "1.3.5" source_span: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.10.1" stack_trace: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" stream_transform: dependency: transitive description: @@ -632,26 +632,26 @@ packages: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" test_api: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.4" timing: dependency: transitive description: @@ -680,10 +680,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "14.3.0" + version: "14.3.1" watcher: dependency: transitive description: @@ -696,10 +696,10 @@ packages: dependency: transitive description: name: weak_map - sha256: "95ca338f0cdf5f0022cc283dfa4d97f6f6b03752f67eca85ebe6d7a679ffe3ed" + sha256: "5f8e5d5ce57dc624db5fae814dd689ccae1f17f92b426e52f0a7cbe7f6f4ab97" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "4.0.1" web: dependency: transitive description: @@ -733,5 +733,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.6.0 <4.0.0" - flutter: ">=3.27.1" + dart: ">=3.7.0 <4.0.0" + flutter: ">=3.29.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 3402044..b871b5b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -5,31 +5,31 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ^3.5.1 + sdk: ^3.7.0 dependencies: - bloc_presentation: ^1.0.0 - chopper: ^8.0.2 - collection: ^1.18.0 + bloc_presentation: ^1.1.0 + chopper: ^8.1.0 + collection: ^1.19.1 dcc_toolkit: path: ../ flutter: sdk: flutter - flutter_bloc: ^9.0.0 - freezed_annotation: ^2.2.0 - get_it: ^7.7.0 - injectable: ^2.1.0 - json_annotation: ^4.7.0 + flutter_bloc: ^9.1.0 + freezed_annotation: ^3.0.0 + get_it: ^8.0.3 + injectable: ^2.5.0 + json_annotation: ^4.9.0 dev_dependencies: - build_runner: ^2.3.3 - chopper_generator: ^8.0.2 + build_runner: ^2.4.15 + chopper_generator: ^8.1.0 flutter_test: sdk: flutter - flutter_lints: ^4.0.0 - freezed: ^2.2.0 - injectable_generator: ^2.1.4 - json_serializable: ^6.5.3 + flutter_lints: ^5.0.0 + freezed: ^3.0.4 + injectable_generator: ^2.7.0 + json_serializable: ^6.9.4 flutter: uses-material-design: true diff --git a/lib/chopper/color_converter.dart b/lib/chopper/color_converter.dart index 669391d..8acf6e7 100644 --- a/lib/chopper/color_converter.dart +++ b/lib/chopper/color_converter.dart @@ -1,6 +1,7 @@ import 'dart:ui'; -import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:json_annotation/json_annotation.dart'; + /// A class that implements JsonConverter to convert Color objects to and from JSON. class ColorConverter implements JsonConverter { diff --git a/lib/chopper/datetime_converter.dart b/lib/chopper/datetime_converter.dart index 521d594..43fdd3a 100644 --- a/lib/chopper/datetime_converter.dart +++ b/lib/chopper/datetime_converter.dart @@ -1,5 +1,5 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:intl/intl.dart'; +import 'package:json_annotation/json_annotation.dart'; enum _DateFormats { yyyyMMdd, diff --git a/lib/common/result/result.dart b/lib/common/result/result.dart index 652b677..85e0ba4 100644 --- a/lib/common/result/result.dart +++ b/lib/common/result/result.dart @@ -2,8 +2,9 @@ import 'dart:async'; import 'package:chopper/chopper.dart'; import 'package:dcc_toolkit/chopper/base_error.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:flutter/foundation.dart'; import 'package:http/http.dart'; +import 'package:json_annotation/json_annotation.dart'; /// Result class to handle success and failure states. @immutable @@ -16,15 +17,15 @@ sealed class Result { /// Returns the value if [Result] is [Success] or null otherwise. T? get getOrNull => switch (this) { - Success(value: final value) => value, - _ => null, - }; + Success(value: final value) => value, + _ => null, + }; /// Returns the exception if [Result] is [Failure] or null otherwise. Object? get errorOrNull => switch (this) { - Failure(error: final error) => error, - _ => null, - }; + Failure(error: final error) => error, + _ => null, + }; /// Returns true if [Result] is [Success]. bool get isSuccess => this is Success; @@ -56,10 +57,7 @@ sealed class Result { /// Executes the given API call [fn]. When the call succeeds, [Result.success] is returned with the response. /// When the call fails the optional [onError] is executed and the exceptions are handled. /// If there is no [onError] provided, an error of type [BaseError] is returned in [Result.failure]. -Future> tryCall( - FutureOr Function() fn, { - Future> Function(Exception error)? onError, -}) async { +Future> tryCall(FutureOr Function() fn, {Future> Function(Exception error)? onError}) async { try { return Result.success(await fn()); } on Exception catch (e) { @@ -67,12 +65,10 @@ Future> tryCall( return onError(e); } return switch (e) { - ChopperHttpException() => Result.failure( - switch (e.response.statusCode) { - 401 => const AuthenticationFailedError(), - _ => const ServerError(), - }, - ), + ChopperHttpException() => Result.failure(switch (e.response.statusCode) { + 401 => const AuthenticationFailedError(), + _ => const ServerError(), + },), ClientException() => Result.failure(const NoInternetError()), CheckedFromJsonException() => Result.failure(const ServerError()), _ => Result.failure(const UnknownError()), @@ -91,10 +87,7 @@ final class Success extends Result { @override bool operator ==(Object other) { - return identical(this, other) || - other is Success && - runtimeType == other.runtimeType && - value == other.value; + return identical(this, other) || other is Success && runtimeType == other.runtimeType && value == other.value; } @override @@ -112,10 +105,7 @@ final class Failure extends Result { @override bool operator ==(Object other) { - return identical(this, other) || - other is Failure && - runtimeType == other.runtimeType && - other.error == error; + return identical(this, other) || other is Failure && runtimeType == other.runtimeType && other.error == error; } @override diff --git a/pubspec.lock b/pubspec.lock index 60c4b48..d72bf14 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -34,10 +34,10 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.12.0" bloc: dependency: transitive description: @@ -58,42 +58,42 @@ packages: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" chopper: dependency: "direct main" description: name: chopper - sha256: "8b25abf4dc034b4a81c23a519691eca6bd16b70782969f95344547d1c4faf3e3" + sha256: "18928a74069cf1c257e657809c1b84b0304d8e32a6fc446dd2bbb28657e0358a" url: "https://pub.dev" source: hosted - version: "8.0.4" + version: "8.1.0" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" collection: dependency: "direct main" description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.19.1" convert: dependency: transitive description: @@ -130,10 +130,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" file: dependency: transitive description: @@ -151,23 +151,15 @@ packages: dependency: "direct main" description: name: flutter_bloc - sha256: "153856bdaac302bbdc58a1d1403d50c40557254aa05eaeed40515d88a25a526b" + sha256: "1046d719fbdf230330d3443187cc33cc11963d15c9089f6cc56faa42a4c5f0cc" url: "https://pub.dev" source: hosted - version: "9.0.0" + version: "9.1.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" - freezed_annotation: - dependency: "direct main" - description: - name: freezed_annotation - sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 - url: "https://pub.dev" - source: hosted - version: "2.4.4" frontend_server_client: dependency: transitive description: @@ -188,10 +180,10 @@ packages: dependency: "direct main" description: name: http - sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.3.0" http_multi_server: dependency: transitive description: @@ -212,10 +204,10 @@ packages: dependency: "direct main" description: name: intl - sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" url: "https://pub.dev" source: hosted - version: "0.19.0" + version: "0.20.2" io: dependency: transitive description: @@ -233,7 +225,7 @@ packages: source: hosted version: "0.7.1" json_annotation: - dependency: transitive + dependency: "direct main" description: name: json_annotation sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" @@ -244,18 +236,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.7" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.0.9" leak_tracker_testing: dependency: transitive description: @@ -284,10 +276,10 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" material_color_utilities: dependency: transitive description: @@ -300,10 +292,10 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.0" mime: dependency: transitive description: @@ -356,10 +348,10 @@ packages: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" pool: dependency: transitive description: @@ -457,66 +449,66 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.10.1" stack_trace: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" string_scanner: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" test: dependency: transitive description: name: test - sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f" + sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" url: "https://pub.dev" source: hosted - version: "1.25.8" + version: "1.25.15" test_api: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.4" test_core: dependency: transitive description: name: test_core - sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d" + sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.8" typed_data: dependency: transitive description: @@ -545,10 +537,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "14.3.0" + version: "14.3.1" watcher: dependency: transitive description: @@ -606,5 +598,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.6.0 <4.0.0" - flutter: ">=3.27.1" + dart: ">=3.7.0 <4.0.0" + flutter: ">=3.29.0" diff --git a/pubspec.yaml b/pubspec.yaml index dbb96dc..9be8927 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,19 +5,19 @@ homepage: https://dutchcodingcompany.com repository: https://github.com/DutchCodingCompany/dcc_toolkit environment: - sdk: ">=3.6.0 <4.0.0" - flutter: ">=3.27.1" + sdk: ">=3.7.0 <4.0.0" + flutter: ">=3.29.0" dependencies: - bloc_presentation: ^1.0.1 - chopper: ^8.0.1+1 - collection: ^1.18.0 + bloc_presentation: ^1.1.0 + chopper: ^8.1.0 + collection: ^1.19.1 flutter: sdk: flutter - flutter_bloc: ^9.0.0 - freezed_annotation: ^2.4.4 - http: ^1.2.2 - intl: ^0.19.0 + flutter_bloc: ^9.1.0 + http: ^1.3.0 + intl: ^0.20.2 + json_annotation: ^4.9.0 logging: ^1.3.0 dev_dependencies: diff --git a/test/common/result/try_call_test.dart b/test/common/result/try_call_test.dart index 5795393..539f9b2 100644 --- a/test/common/result/try_call_test.dart +++ b/test/common/result/try_call_test.dart @@ -2,9 +2,9 @@ import 'package:chopper/chopper.dart' as c; import 'package:dcc_toolkit/chopper/base_error.dart'; import 'package:dcc_toolkit/common/result/result.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:http/http.dart' as http; import 'package:http/http.dart'; +import 'package:json_annotation/json_annotation.dart'; import 'package:parameterized_test/parameterized_test.dart'; void main() { @@ -68,27 +68,21 @@ void main() { expect(await result6, Result.failure(const UnknownError())); }); - parameterizedTest('Different exceptions result in different errors', [ - [Exception('woepsie'), const UnknownError()], - [const FormatException('woepsie'), const UnknownError()], + parameterizedTest( + 'Different exceptions result in different errors', [ - c.ChopperHttpException( - c.Response(http.Response('woepsie', 401), 'woepsie'), - ), - const AuthenticationFailedError(), + [Exception('woepsie'), const UnknownError()], + [const FormatException('woepsie'), const UnknownError()], + [c.ChopperHttpException(c.Response(http.Response('woepsie', 401), 'woepsie')), const AuthenticationFailedError()], + [c.ChopperHttpException(c.Response(http.Response('woepsie', 500), 'woepsie')), const ServerError()], + [ClientException('woepsie'), const NoInternetError()], + [CheckedFromJsonException({}, null, 'woepsie', null), const ServerError()], ], - [ - c.ChopperHttpException( - c.Response(http.Response('woepsie', 500), 'woepsie'), - ), - const ServerError(), - ], - [ClientException('woepsie'), const NoInternetError()], - [CheckedFromJsonException({}, null, 'woepsie', null), const ServerError()], - ], (Exception exception, BaseError expectedError) async { - final result = await tryCall(() async => throw exception); - expect(result, Result.failure(expectedError)); - }); + (Exception exception, BaseError expectedError) async { + final result = await tryCall(() async => throw exception); + expect(result, Result.failure(expectedError)); + }, + ); } int getResult5() { From cbc86d7d88c1812a020a90a298204c5fd1f7c72a Mon Sep 17 00:00:00 2001 From: Job Guldemeester Date: Fri, 28 Mar 2025 10:09:49 +0100 Subject: [PATCH 2/6] :sparkles: Added test util and bool typedef --- lib/common/type_defs.dart | 5 +++++ lib/dcc_toolkit.dart | 3 +++ lib/test_util/devices_sizes.dart | 22 +++++++++++++++++++ lib/test_util/presentation_event_catcher.dart | 8 +++++++ 4 files changed, 38 insertions(+) create mode 100644 lib/common/type_defs.dart create mode 100644 lib/test_util/devices_sizes.dart create mode 100644 lib/test_util/presentation_event_catcher.dart diff --git a/lib/common/type_defs.dart b/lib/common/type_defs.dart new file mode 100644 index 0000000..d42f800 --- /dev/null +++ b/lib/common/type_defs.dart @@ -0,0 +1,5 @@ +// Single bool function is clear enough. +// ignore_for_file: avoid_positional_boolean_parameters + +/// Single bool function is clear enough. +typedef SingleBoolFunc = void Function(bool); diff --git a/lib/dcc_toolkit.dart b/lib/dcc_toolkit.dart index d9c05e0..cc02ba1 100644 --- a/lib/dcc_toolkit.dart +++ b/lib/dcc_toolkit.dart @@ -5,5 +5,8 @@ export 'common/extensions/color.dart'; export 'common/extensions/iterable.dart'; export 'common/extensions/text_theme.dart'; export 'common/result/result.dart'; +export 'common/type_defs.dart'; export 'logger/bolt_logger.dart'; export 'style/style.dart'; +export 'test_util/devices_sizes.dart'; +export 'test_util/presentation_event_catcher.dart'; diff --git a/lib/test_util/devices_sizes.dart b/lib/test_util/devices_sizes.dart new file mode 100644 index 0000000..8f4d9e7 --- /dev/null +++ b/lib/test_util/devices_sizes.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; + +/// Device sizes for testing. +class DeviceSizes { + /// iPhone 11 screen size. + static const BoxConstraints iphone11 = BoxConstraints(minWidth: 414, maxWidth: 414, minHeight: 896, maxHeight: 896); + + /// Create a square [BoxConstraints] with the given [size]. + static BoxConstraints square(double size) => + BoxConstraints(minWidth: size, maxWidth: size, minHeight: size, maxHeight: size); + + /// Create [BoxConstraints] from the given [size]. + static BoxConstraints fromSize(Size size) => + BoxConstraints(minWidth: size.width, maxWidth: size.width, minHeight: size.height, maxHeight: size.height); +} + +/// Extension for [BoxConstraints] to copy the size. +extension BoxConstraintsX on BoxConstraints { + /// Copy the size of the [BoxConstraints] with the given [width] and [height]. + BoxConstraints copySize({double? width, double? height}) => + copyWith(minWidth: width, maxWidth: width, minHeight: height, maxHeight: height); +} diff --git a/lib/test_util/presentation_event_catcher.dart b/lib/test_util/presentation_event_catcher.dart new file mode 100644 index 0000000..9c05b13 --- /dev/null +++ b/lib/test_util/presentation_event_catcher.dart @@ -0,0 +1,8 @@ +import 'package:bloc_presentation/bloc_presentation.dart'; + +/// Catch events from a [BlocPresentationMixin] and add them to a list. +C catchEventIn, S, E>(C cubit, List events) { + cubit.presentation.listen(events.add); + + return cubit; +} From 6fea28cc06045d670c2333a88373d9f37e810ee6 Mon Sep 17 00:00:00 2001 From: Job Guldemeester Date: Fri, 28 Mar 2025 10:14:59 +0100 Subject: [PATCH 3/6] :art: Reformatted code --- analysis_options.yaml | 4 + example/lib/core/modules/chopper_module.dart | 14 +- example/lib/main.dart | 34 ++- .../profile/data/model/api_user_response.dart | 5 +- example/lib/profile/data/model/street.dart | 5 +- .../presentation/cubit/user_state.dart | 4 +- .../lib/profile/presentation/user_page.dart | 22 +- lib/chopper/color_converter.dart | 1 - lib/chopper/datetime_converter.dart | 4 +- lib/chopper/json_serializable_converter.dart | 22 +- lib/common/extensions/build_context.dart | 5 +- lib/common/extensions/text_theme.dart | 15 +- lib/common/result/result.dart | 2 +- lib/common/run_app_bootstrap.dart | 22 +- lib/logger/bolt_logger.dart | 12 +- lib/logger/charges/debug_console_charge.dart | 7 +- lib/logger/charges/file_charge.dart | 6 +- lib/logger/extensions/stacktrace.dart | 6 +- lib/logger/extensions/zap_extension.dart | 12 +- lib/logger/log_record_formatter.dart | 3 +- lib/logger/ui/bolt_logger_view.dart | 9 +- .../interface/color_group_interface.dart | 5 +- .../interface/surface_group_interface.dart | 5 +- lib/style/kleurplaat/color_group.dart | 16 +- lib/style/kleurplaat/katjas_kleurplaat.dart | 79 +++--- lib/style/kleurplaat/surface_group.dart | 9 +- .../text_style/text_style_color_group.dart | 6 +- .../text_style/text_style_decorator.dart | 263 +++++------------- .../text_style/text_themes_decorator.dart | 125 +++------ lib/ui/blocful_widget.dart | 33 +-- test/chopper/color_converter_test.dart | 50 ++-- .../json_serializable_converter_test.dart | 34 +-- test/common/extensions/iterable_test.dart | 37 +-- test/common/result/result_test.dart | 22 +- test/logger/bolt_logger_test.dart | 110 +++----- test/logger/memory_charge_test.dart | 8 +- 36 files changed, 356 insertions(+), 660 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 7c23e3d..bdcf72c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,8 +1,12 @@ include: package:very_good_analysis/analysis_options.yaml +formatter: + page_width: 120 + linter: rules: lines_longer_than_80_chars: false + require_trailing_commas: false analyzer: errors: missing_return: error diff --git a/example/lib/core/modules/chopper_module.dart b/example/lib/core/modules/chopper_module.dart index 9dce6d1..fde86c3 100644 --- a/example/lib/core/modules/chopper_module.dart +++ b/example/lib/core/modules/chopper_module.dart @@ -9,14 +9,12 @@ import 'package:injectable/injectable.dart'; abstract class ChopperModule { @lazySingleton ChopperClient chopper() => ChopperClient( - converter: const JsonSerializableConverter(_factories), - interceptors: [ - // We want to disable logging in release mode because it could leak sensitive information - if (kDebugMode) ...[ - HttpLoggingInterceptor(), - ], - ], - ); + converter: const JsonSerializableConverter(_factories), + interceptors: [ + // We want to disable logging in release mode because it could leak sensitive information + if (kDebugMode) ...[HttpLoggingInterceptor()], + ], + ); } const _factories = { diff --git a/example/lib/main.dart b/example/lib/main.dart index 807fbc9..42ec05f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -34,25 +34,31 @@ class MyHomePage extends StatelessWidget { child: Column( children: [ ElevatedButton( - onPressed: () => Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => UserPage( - onCreateCubit: (context) => - getIt()..getRandomUser(), + onPressed: + () => Navigator.of(context).push( + MaterialPageRoute( + builder: + (context) => UserPage( + onCreateCubit: + (context) => + getIt()..getRandomUser(), + ), + ), ), - ), - ), child: const Text('Get user succesfully'), ), ElevatedButton( - onPressed: () => Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => UserPage( - onCreateCubit: (context) => - getIt()..getRandomUserFails(), + onPressed: + () => Navigator.of(context).push( + MaterialPageRoute( + builder: + (context) => UserPage( + onCreateCubit: + (context) => + getIt()..getRandomUserFails(), + ), + ), ), - ), - ), child: const Text('Get user fails'), ), ], diff --git a/example/lib/profile/data/model/api_user_response.dart b/example/lib/profile/data/model/api_user_response.dart index 2c46b4d..105ebdf 100644 --- a/example/lib/profile/data/model/api_user_response.dart +++ b/example/lib/profile/data/model/api_user_response.dart @@ -7,9 +7,8 @@ part 'api_user_response.g.dart'; @freezed sealed class ApiUserResponse with _$ApiUserResponse { - const factory ApiUserResponse({ - required List results, - }) = _ApiUserResponse; + const factory ApiUserResponse({required List results}) = + _ApiUserResponse; factory ApiUserResponse.fromJson(Map json) => _$ApiUserResponseFromJson(json); diff --git a/example/lib/profile/data/model/street.dart b/example/lib/profile/data/model/street.dart index 77aa675..b31f642 100644 --- a/example/lib/profile/data/model/street.dart +++ b/example/lib/profile/data/model/street.dart @@ -5,10 +5,7 @@ part 'street.g.dart'; @freezed sealed class Street with _$Street { - const factory Street({ - required int number, - required String name, - }) = _Street; + const factory Street({required int number, required String name}) = _Street; factory Street.fromJson(Map json) => _$StreetFromJson(json); } diff --git a/example/lib/profile/presentation/cubit/user_state.dart b/example/lib/profile/presentation/cubit/user_state.dart index 1e7fca2..f758b33 100644 --- a/example/lib/profile/presentation/cubit/user_state.dart +++ b/example/lib/profile/presentation/cubit/user_state.dart @@ -2,7 +2,5 @@ part of 'user_cubit.dart'; @freezed sealed class UserState with _$UserState { - const factory UserState({ - User? user, - }) = _UserState; + const factory UserState({User? user}) = _UserState; } diff --git a/example/lib/profile/presentation/user_page.dart b/example/lib/profile/presentation/user_page.dart index 9c36738..45bd215 100644 --- a/example/lib/profile/presentation/user_page.dart +++ b/example/lib/profile/presentation/user_page.dart @@ -5,14 +5,15 @@ import 'package:flutter/material.dart'; class UserPage extends BlocfulWidget { const UserPage({required this.onCreateCubit, super.key}) - : super(onCreateBloc: onCreateCubit); + : super(onCreateBloc: onCreateCubit); final UserCubit Function(BuildContext)? onCreateCubit; @override void onPresentationEvent(BuildContext context, UserEvent event) { - ScaffoldMessenger.of(context) - .showSnackBar(SnackBar(content: Text(event.reason))); + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(event.reason))); } @override @@ -20,13 +21,14 @@ class UserPage extends BlocfulWidget { return Scaffold( body: SafeArea( child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(state.user?.email ?? ''), - Text(state.user?.phone ?? ''), - ], - )), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(state.user?.email ?? ''), + Text(state.user?.phone ?? ''), + ], + ), + ), ), ); } diff --git a/lib/chopper/color_converter.dart b/lib/chopper/color_converter.dart index 8acf6e7..ebc7325 100644 --- a/lib/chopper/color_converter.dart +++ b/lib/chopper/color_converter.dart @@ -2,7 +2,6 @@ import 'dart:ui'; import 'package:json_annotation/json_annotation.dart'; - /// A class that implements JsonConverter to convert Color objects to and from JSON. class ColorConverter implements JsonConverter { /// A class that implements JsonConverter to convert Color objects to and from JSON. diff --git a/lib/chopper/datetime_converter.dart b/lib/chopper/datetime_converter.dart index 43fdd3a..0b57c9c 100644 --- a/lib/chopper/datetime_converter.dart +++ b/lib/chopper/datetime_converter.dart @@ -3,8 +3,8 @@ import 'package:json_annotation/json_annotation.dart'; enum _DateFormats { yyyyMMdd, -// Name contains the exact pattern for date formatting. -//ignore: constant_identifier_names + // Name contains the exact pattern for date formatting. + //ignore: constant_identifier_names HHmm, } diff --git a/lib/chopper/json_serializable_converter.dart b/lib/chopper/json_serializable_converter.dart index e6b8921..d3b8f6d 100644 --- a/lib/chopper/json_serializable_converter.dart +++ b/lib/chopper/json_serializable_converter.dart @@ -26,24 +26,16 @@ class JsonSerializableConverter extends JsonConverter { T _decodeMap(Map values) { final jsonFactory = factories[T]; if (jsonFactory == null) { - throw JsonUnsupportedObjectError( - T, - cause: - 'No fromJson was registered for JsonSerializableConverter for $T', - ); + throw JsonUnsupportedObjectError(T, cause: 'No fromJson was registered for JsonSerializableConverter for $T'); } if (jsonFactory is! JsonFactory) { - throw JsonUnsupportedObjectError( - T, - cause: 'fromJson type does not match $T', - ); + throw JsonUnsupportedObjectError(T, cause: 'fromJson type does not match $T'); } return jsonFactory(values); } - List _decodeList(Iterable values) => - values.nonNulls.map((v) => _decode(v) as T).toList(); + List _decodeList(Iterable values) => values.nonNulls.map((v) => _decode(v) as T).toList(); dynamic _decode(dynamic entity) { if (entity is Iterable) return _decodeList(entity as List); @@ -54,13 +46,9 @@ class JsonSerializableConverter extends JsonConverter { } @override - FutureOr> convertResponse( - Response response, - ) async { + FutureOr> convertResponse(Response response) async { final jsonRes = await super.convertResponse(response); - return jsonRes.copyWith( - body: _decode(jsonRes.body) as BodyType, - ); + return jsonRes.copyWith(body: _decode(jsonRes.body) as BodyType); } } diff --git a/lib/common/extensions/build_context.dart b/lib/common/extensions/build_context.dart index 3f31acd..680f5d4 100644 --- a/lib/common/extensions/build_context.dart +++ b/lib/common/extensions/build_context.dart @@ -14,10 +14,7 @@ extension ThemingExtensions on BuildContext { TextTheme get textThemes => theme.textTheme; /// Get [TextThemesDecorator] from [BuildContext]. - TextThemesDecorator get textThemesDecorator => TextThemesDecorator( - textThemes, - katjasKleurPlaat, - ); + TextThemesDecorator get textThemesDecorator => TextThemesDecorator(textThemes, katjasKleurPlaat); /// Get [KatjasKleurplaat] from [BuildContext]. KatjasKleurplaat get katjasKleurPlaat => theme.extension()!; diff --git a/lib/common/extensions/text_theme.dart b/lib/common/extensions/text_theme.dart index 67df88b..dced47b 100644 --- a/lib/common/extensions/text_theme.dart +++ b/lib/common/extensions/text_theme.dart @@ -3,20 +3,11 @@ import 'package:flutter/material.dart'; /// LinkStyle extension for [TextTheme]. extension LinkStyle on TextTheme { /// Link style for small text. - TextStyle get linkSmall => bodySmall!.copyWith( - fontWeight: FontWeight.bold, - decoration: TextDecoration.underline, - ); + TextStyle get linkSmall => bodySmall!.copyWith(fontWeight: FontWeight.bold, decoration: TextDecoration.underline); /// Link style for medium text. - TextStyle get linkMedium => bodyMedium!.copyWith( - fontWeight: FontWeight.bold, - decoration: TextDecoration.underline, - ); + TextStyle get linkMedium => bodyMedium!.copyWith(fontWeight: FontWeight.bold, decoration: TextDecoration.underline); /// Link style for large text. - TextStyle get linkLarge => bodyLarge!.copyWith( - fontWeight: FontWeight.bold, - decoration: TextDecoration.underline, - ); + TextStyle get linkLarge => bodyLarge!.copyWith(fontWeight: FontWeight.bold, decoration: TextDecoration.underline); } diff --git a/lib/common/result/result.dart b/lib/common/result/result.dart index 85e0ba4..889a1a8 100644 --- a/lib/common/result/result.dart +++ b/lib/common/result/result.dart @@ -68,7 +68,7 @@ Future> tryCall(FutureOr Function() fn, {Future> Funct ChopperHttpException() => Result.failure(switch (e.response.statusCode) { 401 => const AuthenticationFailedError(), _ => const ServerError(), - },), + }), ClientException() => Result.failure(const NoInternetError()), CheckedFromJsonException() => Result.failure(const ServerError()), _ => Result.failure(const UnknownError()), diff --git a/lib/common/run_app_bootstrap.dart b/lib/common/run_app_bootstrap.dart index 7984894..8bf116a 100644 --- a/lib/common/run_app_bootstrap.dart +++ b/lib/common/run_app_bootstrap.dart @@ -8,23 +8,17 @@ typedef OnError = void Function(Object error, StackTrace? stackTrace); /// Run a Flutter app with a bootstrap that catches errors. /// By default [onError] will use BoltLogger to log the error. -Future runAppBootstrap( - Future Function() builder, { - OnError? onError, -}) async { - final errorLogger = onError ?? +Future runAppBootstrap(Future Function() builder, {OnError? onError}) async { + final errorLogger = + onError ?? (exception, stackTrace) { BoltLogger.shock([exception, stackTrace]); }; - await runZonedGuarded( - () async { - WidgetsFlutterBinding.ensureInitialized(); - FlutterError.onError = - (details) => errorLogger(details.exception, details.stack); + await runZonedGuarded(() async { + WidgetsFlutterBinding.ensureInitialized(); + FlutterError.onError = (details) => errorLogger(details.exception, details.stack); - runApp(await builder()); - }, - errorLogger, - ); + runApp(await builder()); + }, errorLogger); } diff --git a/lib/logger/bolt_logger.dart b/lib/logger/bolt_logger.dart index 2662795..086ebab 100644 --- a/lib/logger/bolt_logger.dart +++ b/lib/logger/bolt_logger.dart @@ -85,11 +85,7 @@ class BoltLogger { /// ``` /// /// {@endtemplate} - static void zap( - Object? message, { - String? tag, - Level level = Level.INFO, - }) { + static void zap(Object? message, {String? tag, Level level = Level.INFO}) { Object? msg; Object? error; StackTrace? stacktrace; @@ -128,11 +124,7 @@ class BoltLogger { /// {@macro zap} /// /// {@endtemplate} - static void shock( - Object? message, { - String? tag, - Level level = Level.SEVERE, - }) { + static void shock(Object? message, {String? tag, Level level = Level.SEVERE}) { zap(message, tag: tag, level: level); } } diff --git a/lib/logger/charges/debug_console_charge.dart b/lib/logger/charges/debug_console_charge.dart index 46adf1c..fb4ac0a 100644 --- a/lib/logger/charges/debug_console_charge.dart +++ b/lib/logger/charges/debug_console_charge.dart @@ -22,14 +22,13 @@ class DebugConsoleCharge implements BoltCharge { } List _paintLines(ZapEvent event) { - final shouldPaint = supportsAnsiEscapes && + final shouldPaint = + supportsAnsiEscapes && (event.origin.level.value >= Level.SEVERE.value || event.origin.stackTrace != null || event.origin.error != null); - return shouldPaint - ? event.lines.map((line) => '$_red$line$_reset').toList() - : event.lines; + return shouldPaint ? event.lines.map((line) => '$_red$line$_reset').toList() : event.lines; } @override diff --git a/lib/logger/charges/file_charge.dart b/lib/logger/charges/file_charge.dart index 1ac8471..0849e23 100644 --- a/lib/logger/charges/file_charge.dart +++ b/lib/logger/charges/file_charge.dart @@ -14,11 +14,7 @@ import 'package:intl/intl.dart'; /// {@endtemplate} class FileCharge implements BoltCharge { /// {@macro file_charge} - FileCharge( - this.path, { - this.bufferSize = 1000, - this.writeDelay = const Duration(seconds: 5), - }) { + FileCharge(this.path, {this.bufferSize = 1000, this.writeDelay = const Duration(seconds: 5)}) { final fileName = '${DateFormat('yyyy-MM-dd').format(DateTime.now())}.log'; _file = File('$path/$fileName'); diff --git a/lib/logger/extensions/stacktrace.dart b/lib/logger/extensions/stacktrace.dart index 664acf7..974a6e1 100644 --- a/lib/logger/extensions/stacktrace.dart +++ b/lib/logger/extensions/stacktrace.dart @@ -3,11 +3,7 @@ extension ZapStackTraceExtension on StackTrace { /// Strike the [StackTrace] which will format it so that it's easier to read. String get strike => toString() .split('\n') - .map( - (e) => e.isNotEmpty && e.startsWith('#') - ? e.replaceAll(RegExp(r'\s\s+'), ' ') - : null, - ) + .map((e) => e.isNotEmpty && e.startsWith('#') ? e.replaceAll(RegExp(r'\s\s+'), ' ') : null) .whereType() .join('\n'); } diff --git a/lib/logger/extensions/zap_extension.dart b/lib/logger/extensions/zap_extension.dart index cb0d369..db12c02 100644 --- a/lib/logger/extensions/zap_extension.dart +++ b/lib/logger/extensions/zap_extension.dart @@ -4,22 +4,14 @@ import 'package:logging/logging.dart'; /// Extension to zap messages. extension ZapExtension on Object { /// {@macro zap} - void zap( - Object? message, { - String? tag, - Level level = Level.INFO, - }) { + void zap(Object? message, {String? tag, Level level = Level.INFO}) { // We actually want to know to runtimeType of the object // ignore: no_runtimeType_toString BoltLogger.zap(message, tag: tag ?? runtimeType.toString(), level: level); } /// {@macro shock} - void shock( - Object? message, { - String? tag, - Level level = Level.SEVERE, - }) { + void shock(Object? message, {String? tag, Level level = Level.SEVERE}) { // We actually want to know to runtimeType of the object //ignore: no_runtimeType_toString BoltLogger.shock(message, tag: tag ?? runtimeType.toString(), level: level); diff --git a/lib/logger/log_record_formatter.dart b/lib/logger/log_record_formatter.dart index 6b822fd..a2eb4dd 100644 --- a/lib/logger/log_record_formatter.dart +++ b/lib/logger/log_record_formatter.dart @@ -36,8 +36,7 @@ class LogRecordFormatter { return record.error.toString().split('\n').map((e) => e.trim()).toList(); } - List _formatStacktrace(LogRecord record) => - record.stackTrace?.strike.split('\n') ?? []; + List _formatStacktrace(LogRecord record) => record.stackTrace?.strike.split('\n') ?? []; String _prefix(LogRecord record) { final tag = record.loggerName; diff --git a/lib/logger/ui/bolt_logger_view.dart b/lib/logger/ui/bolt_logger_view.dart index 32c6562..210b6ff 100644 --- a/lib/logger/ui/bolt_logger_view.dart +++ b/lib/logger/ui/bolt_logger_view.dart @@ -37,14 +37,7 @@ class _BoltLoggerViewState extends State { itemBuilder: (context, index) { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: charge.items[index].lines - .map( - (e) => Text( - e, - style: const TextStyle(fontSize: 10), - ), - ) - .toList(), + children: charge.items[index].lines.map((e) => Text(e, style: const TextStyle(fontSize: 10))).toList(), ); }, ); diff --git a/lib/style/interface/color_group_interface.dart b/lib/style/interface/color_group_interface.dart index 6dc45c4..32aafc4 100644 --- a/lib/style/interface/color_group_interface.dart +++ b/lib/style/interface/color_group_interface.dart @@ -20,8 +20,5 @@ abstract interface class ColorGroupInterface { T? get onColorSubtle; /// Linearly interpolate with another object. - ColorGroupInterface lerp( - covariant ColorGroupInterface? other, - double t, - ); + ColorGroupInterface lerp(covariant ColorGroupInterface? other, double t); } diff --git a/lib/style/interface/surface_group_interface.dart b/lib/style/interface/surface_group_interface.dart index c8864db..5387157 100644 --- a/lib/style/interface/surface_group_interface.dart +++ b/lib/style/interface/surface_group_interface.dart @@ -60,8 +60,5 @@ abstract interface class SurfaceGroupInterface { T get link; /// Linearly interpolate with another object. - SurfaceGroupInterface lerp( - covariant SurfaceGroupInterface? other, - double t, - ); + SurfaceGroupInterface lerp(covariant SurfaceGroupInterface? other, double t); } diff --git a/lib/style/kleurplaat/color_group.dart b/lib/style/kleurplaat/color_group.dart index d79d668..a1e7ea3 100644 --- a/lib/style/kleurplaat/color_group.dart +++ b/lib/style/kleurplaat/color_group.dart @@ -5,11 +5,7 @@ import 'package:dcc_toolkit/style/interface/color_group_interface.dart'; /// {@macro color_group} class ColorGroup implements ColorGroupInterface { /// {@macro color_group} - const ColorGroup({ - required this.color, - required this.onColorContrast, - this.onColorSubtle, - }); + const ColorGroup({required this.color, required this.onColorContrast, this.onColorSubtle}); @override final Color color; @@ -28,11 +24,11 @@ class ColorGroup implements ColorGroupInterface { return ColorGroup( color: Color.lerp(color, other.color, t) ?? color, - onColorContrast: Color.lerp(onColorContrast, other.onColorContrast, t) ?? - onColorContrast, - onColorSubtle: onColorSubtle == null || other.onColorSubtle == null - ? null - : Color.lerp(onColorSubtle, other.onColorSubtle, t), + onColorContrast: Color.lerp(onColorContrast, other.onColorContrast, t) ?? onColorContrast, + onColorSubtle: + onColorSubtle == null || other.onColorSubtle == null + ? null + : Color.lerp(onColorSubtle, other.onColorSubtle, t), ); } } diff --git a/lib/style/kleurplaat/katjas_kleurplaat.dart b/lib/style/kleurplaat/katjas_kleurplaat.dart index bf77669..197ea62 100644 --- a/lib/style/kleurplaat/katjas_kleurplaat.dart +++ b/lib/style/kleurplaat/katjas_kleurplaat.dart @@ -4,8 +4,7 @@ import 'package:dcc_toolkit/style/kleurplaat/surface_group.dart'; import 'package:flutter/material.dart'; /// {@macro kleurplaat} -class KatjasKleurplaat extends ThemeExtension - implements KleurplaatInterface { +class KatjasKleurplaat extends ThemeExtension implements KleurplaatInterface { /// {@macro kleurplaat} const KatjasKleurplaat({ required this.primary, @@ -82,23 +81,22 @@ class KatjasKleurplaat extends ThemeExtension ColorGroup? successFill, SurfaceGroup? surface, SurfaceGroup? surfaceInverse, - }) => - KatjasKleurplaat( - primary: primary ?? this.primary, - primaryFill: primaryFill ?? this.primaryFill, - secondary: secondary ?? this.secondary, - secondaryFill: secondaryFill ?? this.secondaryFill, - tertiary: tertiary ?? this.tertiary, - tertiaryFill: tertiaryFill ?? this.tertiaryFill, - content: content ?? this.content, - contentFill: contentFill ?? this.contentFill, - error: error ?? this.error, - errorFill: errorFill ?? this.errorFill, - success: success ?? this.success, - successFill: successFill ?? this.successFill, - surface: surface ?? this.surface, - surfaceInverse: surfaceInverse ?? this.surfaceInverse, - ); + }) => KatjasKleurplaat( + primary: primary ?? this.primary, + primaryFill: primaryFill ?? this.primaryFill, + secondary: secondary ?? this.secondary, + secondaryFill: secondaryFill ?? this.secondaryFill, + tertiary: tertiary ?? this.tertiary, + tertiaryFill: tertiaryFill ?? this.tertiaryFill, + content: content ?? this.content, + contentFill: contentFill ?? this.contentFill, + error: error ?? this.error, + errorFill: errorFill ?? this.errorFill, + success: success ?? this.success, + successFill: successFill ?? this.successFill, + surface: surface ?? this.surface, + surfaceInverse: surfaceInverse ?? this.surfaceInverse, + ); @override KatjasKleurplaat lerp(KatjasKleurplaat? other, double t) { @@ -123,26 +121,25 @@ class KatjasKleurplaat extends ThemeExtension } /// Converts the [KatjasKleurplaat] to a [ColorScheme]. - ColorScheme toColorScheme({Brightness brightness = Brightness.light}) => - ColorScheme( - brightness: brightness, - primary: primary.color, - primaryContainer: primary.color, - onPrimary: primary.onColorContrast, - onPrimaryContainer: primary.onColorContrast, - secondary: content.color, - secondaryContainer: content.color, - secondaryFixed: secondary?.color, - secondaryFixedDim: secondaryFill?.color, - tertiaryFixed: tertiary?.color, - tertiaryFixedDim: tertiaryFill?.color, - onSecondary: content.onColorContrast, - onSecondaryContainer: content.onColorContrast, - tertiary: error.color, - onTertiary: error.onColorContrast, - error: error.color, - onError: error.onColorContrast, - surface: surface.color, - onSurface: surface.onColorContrast, - ); + ColorScheme toColorScheme({Brightness brightness = Brightness.light}) => ColorScheme( + brightness: brightness, + primary: primary.color, + primaryContainer: primary.color, + onPrimary: primary.onColorContrast, + onPrimaryContainer: primary.onColorContrast, + secondary: content.color, + secondaryContainer: content.color, + secondaryFixed: secondary?.color, + secondaryFixedDim: secondaryFill?.color, + tertiaryFixed: tertiary?.color, + tertiaryFixedDim: tertiaryFill?.color, + onSecondary: content.onColorContrast, + onSecondaryContainer: content.onColorContrast, + tertiary: error.color, + onTertiary: error.onColorContrast, + error: error.color, + onError: error.onColorContrast, + surface: surface.color, + onSurface: surface.onColorContrast, + ); } diff --git a/lib/style/kleurplaat/surface_group.dart b/lib/style/kleurplaat/surface_group.dart index b1a40ea..9249b5d 100644 --- a/lib/style/kleurplaat/surface_group.dart +++ b/lib/style/kleurplaat/surface_group.dart @@ -59,17 +59,14 @@ class SurfaceGroup implements SurfaceGroupInterface { return SurfaceGroup( color: Color.lerp(color, other.color, t)!, onColorContrast: Color.lerp(onColorContrast, other.onColorContrast, t)!, - onColorContrastDim: - Color.lerp(onColorContrastDim, other.onColorContrastDim, t)!, + onColorContrastDim: Color.lerp(onColorContrastDim, other.onColorContrastDim, t)!, onColorSubtle: Color.lerp(onColorSubtle, other.onColorSubtle, t)!, - onColorSubtleDim: - Color.lerp(onColorSubtleDim, other.onColorSubtleDim, t)!, + onColorSubtleDim: Color.lerp(onColorSubtleDim, other.onColorSubtleDim, t)!, containerLowest: Color.lerp(containerLowest, other.containerLowest, t)!, containerLow: Color.lerp(containerLow, other.containerLow, t)!, container: Color.lerp(container, other.container, t)!, containerHigh: Color.lerp(containerHigh, other.containerHigh, t)!, - containerHighest: - Color.lerp(containerHighest, other.containerHighest, t)!, + containerHighest: Color.lerp(containerHighest, other.containerHighest, t)!, link: Color.lerp(link, other.link, t)!, ); } diff --git a/lib/style/text_style/text_style_color_group.dart b/lib/style/text_style/text_style_color_group.dart index 4079ccb..a60439a 100644 --- a/lib/style/text_style/text_style_color_group.dart +++ b/lib/style/text_style/text_style_color_group.dart @@ -4,11 +4,7 @@ import 'package:flutter/material.dart'; /// {@macro color_group} class TextStyleColorGroup implements ColorGroupInterface { /// {@macro color_group} - const TextStyleColorGroup({ - required this.color, - required this.onColorContrast, - this.onColorSubtle, - }); + const TextStyleColorGroup({required this.color, required this.onColorContrast, this.onColorSubtle}); @override final TextStyle color; diff --git a/lib/style/text_style/text_style_decorator.dart b/lib/style/text_style/text_style_decorator.dart index b34a1f3..c140e39 100644 --- a/lib/style/text_style/text_style_decorator.dart +++ b/lib/style/text_style/text_style_decorator.dart @@ -11,244 +11,125 @@ import 'package:flutter/material.dart'; /// {@endtemplate} class TextStyleDecorator implements KleurplaatInterface { /// {@macro text_style_decorator} - const TextStyleDecorator( - this._textStyle, - this._kleurplaat, - ); + const TextStyleDecorator(this._textStyle, this._kleurplaat); final TextStyle _textStyle; final KatjasKleurplaat _kleurplaat; @override ColorGroupInterface get content => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.content.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.content.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.content.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.content.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.content.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.content.onColorSubtle), + ); @override ColorGroupInterface get contentFill => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.contentFill.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.contentFill.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.contentFill.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.contentFill.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.contentFill.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.contentFill.onColorSubtle), + ); @override ColorGroupInterface get error => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.error.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.error.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.error.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.error.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.error.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.error.onColorSubtle), + ); @override ColorGroupInterface get errorFill => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.errorFill.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.errorFill.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.errorFill.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.errorFill.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.errorFill.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.errorFill.onColorSubtle), + ); @override ColorGroupInterface get primary => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.primary.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.primary.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.primary.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.primary.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.primary.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.primary.onColorSubtle), + ); @override ColorGroupInterface get primaryFill => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.primaryFill.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.primaryFill.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.primaryFill.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.primaryFill.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.primaryFill.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.primaryFill.onColorSubtle), + ); @override ColorGroupInterface get secondary => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.secondary?.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.secondary?.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.secondary?.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.secondary?.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.secondary?.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.secondary?.onColorSubtle), + ); @override ColorGroupInterface get secondaryFill => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.secondaryFill?.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.secondaryFill?.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.secondaryFill?.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.secondaryFill?.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.secondaryFill?.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.secondaryFill?.onColorSubtle), + ); @override ColorGroupInterface get tertiary => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.tertiary?.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.tertiary?.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.tertiary?.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.tertiary?.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.tertiary?.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.tertiary?.onColorSubtle), + ); @override ColorGroupInterface get tertiaryFill => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.tertiaryFill?.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.tertiaryFill?.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.tertiaryFill?.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.tertiaryFill?.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.tertiaryFill?.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.tertiaryFill?.onColorSubtle), + ); @override ColorGroupInterface get success => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.success.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.success.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.success.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.success.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.success.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.success.onColorSubtle), + ); @override ColorGroupInterface get successFill => TextStyleColorGroup( - color: _textStyle.copyWith( - color: _kleurplaat.successFill.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.successFill.onColorContrast, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.successFill.onColorSubtle, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.successFill.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.successFill.onColorContrast), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.successFill.onColorSubtle), + ); @override SurfaceGroupInterface get surface => TextStyleSurfaceGroup( - color: _textStyle.copyWith( - color: _kleurplaat.surface.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.surface.onColorContrast, - ), - onColorContrastDim: _textStyle.copyWith( - color: _kleurplaat.surface.onColorContrastDim, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.surface.onColorSubtle, - ), - onColorSubtleDim: _textStyle.copyWith( - color: _kleurplaat.surface.onColorSubtleDim, - ), - containerLowest: _textStyle.copyWith( - color: _kleurplaat.surface.containerLowest, - ), - containerLow: _textStyle.copyWith( - color: _kleurplaat.surface.containerLow, - ), - container: _textStyle.copyWith( - color: _kleurplaat.surface.container, - ), - containerHigh: _textStyle.copyWith( - color: _kleurplaat.surface.containerHigh, - ), - containerHighest: _textStyle.copyWith( - color: _kleurplaat.surface.containerHighest, - ), - link: _textStyle.copyWith( - color: _kleurplaat.surface.link, - ), - ); + color: _textStyle.copyWith(color: _kleurplaat.surface.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.surface.onColorContrast), + onColorContrastDim: _textStyle.copyWith(color: _kleurplaat.surface.onColorContrastDim), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.surface.onColorSubtle), + onColorSubtleDim: _textStyle.copyWith(color: _kleurplaat.surface.onColorSubtleDim), + containerLowest: _textStyle.copyWith(color: _kleurplaat.surface.containerLowest), + containerLow: _textStyle.copyWith(color: _kleurplaat.surface.containerLow), + container: _textStyle.copyWith(color: _kleurplaat.surface.container), + containerHigh: _textStyle.copyWith(color: _kleurplaat.surface.containerHigh), + containerHighest: _textStyle.copyWith(color: _kleurplaat.surface.containerHighest), + link: _textStyle.copyWith(color: _kleurplaat.surface.link), + ); @override SurfaceGroupInterface? get surfaceInverse { if (_kleurplaat.surfaceInverse == null) return null; return TextStyleSurfaceGroup( - color: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.color, - ), - onColorContrast: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.onColorContrast, - ), - onColorContrastDim: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.onColorContrastDim, - ), - onColorSubtle: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.onColorSubtle, - ), - onColorSubtleDim: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.onColorSubtleDim, - ), - containerLowest: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.containerLowest, - ), - containerLow: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.containerLow, - ), - container: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.container, - ), - containerHigh: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.containerHigh, - ), - containerHighest: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.containerHighest, - ), - link: _textStyle.copyWith( - color: _kleurplaat.surfaceInverse!.link, - ), + color: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.color), + onColorContrast: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.onColorContrast), + onColorContrastDim: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.onColorContrastDim), + onColorSubtle: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.onColorSubtle), + onColorSubtleDim: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.onColorSubtleDim), + containerLowest: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.containerLowest), + containerLow: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.containerLow), + container: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.container), + containerHigh: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.containerHigh), + containerHighest: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.containerHighest), + link: _textStyle.copyWith(color: _kleurplaat.surfaceInverse!.link), ); } } diff --git a/lib/style/text_style/text_themes_decorator.dart b/lib/style/text_style/text_themes_decorator.dart index 01fe26b..d667c5a 100644 --- a/lib/style/text_style/text_themes_decorator.dart +++ b/lib/style/text_style/text_themes_decorator.dart @@ -9,131 +9,68 @@ import 'package:flutter/material.dart'; /// {@endtemplate} class TextThemesDecorator { /// {@macro text_themes_decorator} - const TextThemesDecorator( - this._textTheme, - this._katjasKleurplaat, - ); + const TextThemesDecorator(this._textTheme, this._katjasKleurplaat); final TextTheme _textTheme; final KatjasKleurplaat _katjasKleurplaat; /// See [TextTheme.displayLarge]. - TextStyleDecorator? get displayLarge => _textTheme.displayLarge != null - ? TextStyleDecorator( - _textTheme.displayLarge!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get displayLarge => + _textTheme.displayLarge != null ? TextStyleDecorator(_textTheme.displayLarge!, _katjasKleurplaat) : null; /// See [TextTheme.displayMedium]. - TextStyleDecorator? get displayMedium => _textTheme.displayMedium != null - ? TextStyleDecorator( - _textTheme.displayMedium!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get displayMedium => + _textTheme.displayMedium != null ? TextStyleDecorator(_textTheme.displayMedium!, _katjasKleurplaat) : null; /// See [TextTheme.displaySmall]. - TextStyleDecorator? get displaySmall => _textTheme.displaySmall != null - ? TextStyleDecorator( - _textTheme.displaySmall!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get displaySmall => + _textTheme.displaySmall != null ? TextStyleDecorator(_textTheme.displaySmall!, _katjasKleurplaat) : null; /// See [TextTheme.headlineLarge]. - TextStyleDecorator? get headlineLarge => _textTheme.headlineLarge != null - ? TextStyleDecorator( - _textTheme.headlineLarge!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get headlineLarge => + _textTheme.headlineLarge != null ? TextStyleDecorator(_textTheme.headlineLarge!, _katjasKleurplaat) : null; /// See [TextTheme.headlineMedium]. - TextStyleDecorator? get headlineMedium => _textTheme.headlineMedium != null - ? TextStyleDecorator( - _textTheme.headlineMedium!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get headlineMedium => + _textTheme.headlineMedium != null ? TextStyleDecorator(_textTheme.headlineMedium!, _katjasKleurplaat) : null; /// See [TextTheme.headlineSmall]. - TextStyleDecorator? get headlineSmall => _textTheme.headlineSmall != null - ? TextStyleDecorator( - _textTheme.headlineSmall!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get headlineSmall => + _textTheme.headlineSmall != null ? TextStyleDecorator(_textTheme.headlineSmall!, _katjasKleurplaat) : null; /// See [TextTheme.titleLarge]. - TextStyleDecorator? get titleLarge => _textTheme.titleLarge != null - ? TextStyleDecorator( - _textTheme.titleLarge!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get titleLarge => + _textTheme.titleLarge != null ? TextStyleDecorator(_textTheme.titleLarge!, _katjasKleurplaat) : null; /// See [TextTheme.titleMedium]. - TextStyleDecorator? get titleMedium => _textTheme.titleMedium != null - ? TextStyleDecorator( - _textTheme.titleMedium!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get titleMedium => + _textTheme.titleMedium != null ? TextStyleDecorator(_textTheme.titleMedium!, _katjasKleurplaat) : null; /// See [TextTheme.titleSmall]. - TextStyleDecorator? get titleSmall => _textTheme.titleSmall != null - ? TextStyleDecorator( - _textTheme.titleSmall!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get titleSmall => + _textTheme.titleSmall != null ? TextStyleDecorator(_textTheme.titleSmall!, _katjasKleurplaat) : null; /// See [TextTheme.bodyLarge]. - TextStyleDecorator? get bodyLarge => _textTheme.bodyLarge != null - ? TextStyleDecorator( - _textTheme.bodyLarge!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get bodyLarge => + _textTheme.bodyLarge != null ? TextStyleDecorator(_textTheme.bodyLarge!, _katjasKleurplaat) : null; /// See [TextTheme.bodyMedium]. - TextStyleDecorator? get bodyMedium => _textTheme.bodyMedium != null - ? TextStyleDecorator( - _textTheme.bodyMedium!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get bodyMedium => + _textTheme.bodyMedium != null ? TextStyleDecorator(_textTheme.bodyMedium!, _katjasKleurplaat) : null; /// See [TextTheme.bodySmall]. - TextStyleDecorator? get bodySmall => _textTheme.bodySmall != null - ? TextStyleDecorator( - _textTheme.bodySmall!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get bodySmall => + _textTheme.bodySmall != null ? TextStyleDecorator(_textTheme.bodySmall!, _katjasKleurplaat) : null; /// See [TextTheme.labelLarge]. - TextStyleDecorator? get labelLarge => _textTheme.labelLarge != null - ? TextStyleDecorator( - _textTheme.labelLarge!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get labelLarge => + _textTheme.labelLarge != null ? TextStyleDecorator(_textTheme.labelLarge!, _katjasKleurplaat) : null; /// See [TextTheme.labelMedium]. - TextStyleDecorator? get labelMedium => _textTheme.labelMedium != null - ? TextStyleDecorator( - _textTheme.labelMedium!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get labelMedium => + _textTheme.labelMedium != null ? TextStyleDecorator(_textTheme.labelMedium!, _katjasKleurplaat) : null; /// See [TextTheme.labelSmall]. - TextStyleDecorator? get labelSmall => _textTheme.labelSmall != null - ? TextStyleDecorator( - _textTheme.labelSmall!, - _katjasKleurplaat, - ) - : null; + TextStyleDecorator? get labelSmall => + _textTheme.labelSmall != null ? TextStyleDecorator(_textTheme.labelSmall!, _katjasKleurplaat) : null; } diff --git a/lib/ui/blocful_widget.dart b/lib/ui/blocful_widget.dart index d03ae5e..1282e37 100644 --- a/lib/ui/blocful_widget.dart +++ b/lib/ui/blocful_widget.dart @@ -21,8 +21,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; /// } /// } /// ``` -abstract class BlocfulWidget, - STATE, EVENT> extends StatelessWidget { +abstract class BlocfulWidget, STATE, EVENT> extends StatelessWidget { /// Creates a [BlocfulWidget] const BlocfulWidget({this.onCreateBloc, super.key}); @@ -33,26 +32,22 @@ abstract class BlocfulWidget, Widget build(BuildContext context) { return onCreateBloc != null ? BlocProvider( - create: onCreateBloc!, - child: BlocPresentationListener( - listener: onPresentationEvent, - child: BlocConsumer( - listener: (context, state) => - listener(context, context.read(), state), - builder: (context, state) => - builder(context, context.read(), state), - ), - ), - ) - : BlocPresentationListener( + create: onCreateBloc!, + child: BlocPresentationListener( listener: onPresentationEvent, child: BlocConsumer( - listener: (context, state) => - listener(context, context.read(), state), - builder: (context, state) => - builder(context, context.read(), state), + listener: (context, state) => listener(context, context.read(), state), + builder: (context, state) => builder(context, context.read(), state), ), - ); + ), + ) + : BlocPresentationListener( + listener: onPresentationEvent, + child: BlocConsumer( + listener: (context, state) => listener(context, context.read(), state), + builder: (context, state) => builder(context, context.read(), state), + ), + ); } /// A function that defines what UI behaviour should be triggered when an [EVENT] has taken place diff --git a/test/chopper/color_converter_test.dart b/test/chopper/color_converter_test.dart index 185f4b3..ce765fd 100644 --- a/test/chopper/color_converter_test.dart +++ b/test/chopper/color_converter_test.dart @@ -5,28 +5,36 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:parameterized_test/parameterized_test.dart'; void main() { - parameterizedTest('converts color to json value', [ - [const Color(0xFF000000), '#ff000000'], - [const Color(0xFFFF0000), '#ffff0000'], - [const Color(0xFFFFFF00), '#ffffff00'], - [const Color(0xFFFFFFFF), '#ffffffff'], - [const Color(0xF1F1F1F1), '#f1f1f1f1'], - ], (Color color, String expected) { - final result = const ColorConverter().toJson(color); + parameterizedTest( + 'converts color to json value', + [ + [const Color(0xFF000000), '#ff000000'], + [const Color(0xFFFF0000), '#ffff0000'], + [const Color(0xFFFFFF00), '#ffffff00'], + [const Color(0xFFFFFFFF), '#ffffffff'], + [const Color(0xF1F1F1F1), '#f1f1f1f1'], + ], + (Color color, String expected) { + final result = const ColorConverter().toJson(color); - expect(result, expected); - }); + expect(result, expected); + }, + ); - parameterizedTest('converts json value to color', [ - [const Color(0xFF000000), '#ff000000'], - [const Color(0xFFFF0000), '#ffff0000'], - [const Color(0xFFFFFF00), '#ffffff00'], - [const Color(0xFFFFFFFF), '#ffffffff'], - [const Color(0xF1F1F1F1), '#f1f1f1f1'], - [const Color(0xFFFFFFFF), '#ffffff'], - ], (Color expected, String json) { - final result = const ColorConverter().fromJson(json); + parameterizedTest( + 'converts json value to color', + [ + [const Color(0xFF000000), '#ff000000'], + [const Color(0xFFFF0000), '#ffff0000'], + [const Color(0xFFFFFF00), '#ffffff00'], + [const Color(0xFFFFFFFF), '#ffffffff'], + [const Color(0xF1F1F1F1), '#f1f1f1f1'], + [const Color(0xFFFFFFFF), '#ffffff'], + ], + (Color expected, String json) { + final result = const ColorConverter().fromJson(json); - expect(result, expected); - }); + expect(result, expected); + }, + ); } diff --git a/test/chopper/json_serializable_converter_test.dart b/test/chopper/json_serializable_converter_test.dart index 645136a..ee115ed 100644 --- a/test/chopper/json_serializable_converter_test.dart +++ b/test/chopper/json_serializable_converter_test.dart @@ -13,45 +13,33 @@ void main() { const converter = JsonSerializableConverter({}); - expect( - () => converter.convertResponse(response), - throwsA(isA()), - ); + expect(() => converter.convertResponse(response), throwsA(isA())); }); test('Error is thrown when wrong factory is added', () { final response = Response(baseResponse, '{"name":"John"}'); - const converter = - JsonSerializableConverter({TestModel: TestModel2.fromJson}); + const converter = JsonSerializableConverter({TestModel: TestModel2.fromJson}); - expect( - () => converter.convertResponse(response), - throwsA(isA()), - ); + expect(() => converter.convertResponse(response), throwsA(isA())); }); test('Uses model to convert json into model', () async { final response = Response(baseResponse, '{"name":"John"}'); - const converter = - JsonSerializableConverter({TestModel: TestModel.fromJson}); + const converter = JsonSerializableConverter({TestModel: TestModel.fromJson}); - final result = - await converter.convertResponse(response); + final result = await converter.convertResponse(response); expect(result.body?.name, 'John'); }); test('Uses model to convert json into List', () async { - final response = - Response(baseResponse, '[{"name":"John"},{"name":"John2"}]'); + final response = Response(baseResponse, '[{"name":"John"},{"name":"John2"}]'); - const converter = - JsonSerializableConverter({TestModel: TestModel.fromJson}); + const converter = JsonSerializableConverter({TestModel: TestModel.fromJson}); - final result = - await converter.convertResponse, TestModel>(response); + final result = await converter.convertResponse, TestModel>(response); expect(result.body?[0].name, 'John'); expect(result.body?[1].name, 'John2'); @@ -61,8 +49,7 @@ void main() { class TestModel { TestModel(this.name); - factory TestModel.fromJson(Map json) => - TestModel(json['name'] as String); + factory TestModel.fromJson(Map json) => TestModel(json['name'] as String); final String name; @@ -72,8 +59,7 @@ class TestModel { class TestModel2 { TestModel2(this.name); - factory TestModel2.fromJson(Map json) => - TestModel2(json['name'] as String); + factory TestModel2.fromJson(Map json) => TestModel2(json['name'] as String); final String name; diff --git a/test/common/extensions/iterable_test.dart b/test/common/extensions/iterable_test.dart index d95e863..e1bfa9a 100644 --- a/test/common/extensions/iterable_test.dart +++ b/test/common/extensions/iterable_test.dart @@ -3,24 +3,25 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:parameterized_test/parameterized_test.dart'; void main() { - parameterizedTest('addBetween tests', [ + parameterizedTest( + 'addBetween tests', [ - [], - [], + [[], []], + [ + [1], + [1], + ], + [ + [1, 2], + [1, 0, 2], + ], + [ + [1, 2, 3], + [1, 0, 2, 0, 3], + ], ], - [ - [1], - [1], - ], - [ - [1, 2], - [1, 0, 2], - ], - [ - [1, 2, 3], - [1, 0, 2, 0, 3], - ], - ], (List initial, List expected) { - expect(initial.addBetween(0), expected); - }); + (List initial, List expected) { + expect(initial.addBetween(0), expected); + }, + ); } diff --git a/test/common/result/result_test.dart b/test/common/result/result_test.dart index 0fecaad..8ed3163 100644 --- a/test/common/result/result_test.dart +++ b/test/common/result/result_test.dart @@ -5,15 +5,19 @@ import 'package:parameterized_test/parameterized_test.dart'; void main() { const testExceptionResult = Failure(ServerError()); - parameterizedTest('comparing 2 results should return true if equal', [ - [const Success(1), const Success(1), true], - [const Success(1), const Success(2), false], - [const Success(1), const Failure(ServerError()), false], - [testExceptionResult, testExceptionResult, true], - ], (Result result1, Result result2, bool expected) { - final actual = result1 == result2; - expect(actual, expected); - }); + parameterizedTest( + 'comparing 2 results should return true if equal', + [ + [const Success(1), const Success(1), true], + [const Success(1), const Success(2), false], + [const Success(1), const Failure(ServerError()), false], + [testExceptionResult, testExceptionResult, true], + ], + (Result result1, Result result2, bool expected) { + final actual = result1 == result2; + expect(actual, expected); + }, + ); test('getOrNull returns value for Success', () { final result = Result.success(1); diff --git a/test/logger/bolt_logger_test.dart b/test/logger/bolt_logger_test.dart index 5aecd44..f6a0bef 100644 --- a/test/logger/bolt_logger_test.dart +++ b/test/logger/bolt_logger_test.dart @@ -12,8 +12,7 @@ void main() { tearDown(() => BoltLogger.discharge()); group('charge tests', () { - test('BoltLogger without a charge only redirect log event to root Logger', - () { + test('BoltLogger without a charge only redirect log event to root Logger', () { final records = []; Logger.root.level = Level.ALL; final sub = Logger.root.onRecord.listen(records.add); @@ -39,14 +38,7 @@ void main() { BoltLogger.zap('zap'); - expect( - BoltLogger.getCharge('MemoryCharge'), - isA().having( - (e) => e.maxItems, - 'maxItems', - 1, - ), - ); + expect(BoltLogger.getCharge('MemoryCharge'), isA().having((e) => e.maxItems, 'maxItems', 1)); expect(memoryCharge1.items.length, 1); expect(memoryCharge2.items.length, 0); }); @@ -74,8 +66,7 @@ void main() { BoltLogger.charge([memoryCharge]); }); - parameterizedGroup('BoltLogger/extension function tests', [true, false], - (bool useBoltLogger) { + parameterizedGroup('BoltLogger/extension function tests', [true, false], (bool useBoltLogger) { test('zap/shock sends a message via a ZapEvent to a charge', () { if (useBoltLogger) { BoltLogger.zap('zap'); @@ -87,15 +78,9 @@ void main() { expect(memoryCharge.items.length, 2); expect(memoryCharge.items[0].origin.message, 'zap'); - expect( - memoryCharge.items[0].origin.loggerName, - useBoltLogger ? 'BoltLogger' : 'TestReferenceClass', - ); + expect(memoryCharge.items[0].origin.loggerName, useBoltLogger ? 'BoltLogger' : 'TestReferenceClass'); expect(memoryCharge.items[1].origin.message, 'shock'); - expect( - memoryCharge.items[1].origin.loggerName, - useBoltLogger ? 'BoltLogger' : 'TestReferenceClass', - ); + expect(memoryCharge.items[1].origin.loggerName, useBoltLogger ? 'BoltLogger' : 'TestReferenceClass'); expect(memoryCharge.items[1].origin.level, Level.SEVERE); }); @@ -115,30 +100,33 @@ void main() { }); parameterizedTest( - 'zap/shock sends a LogLevel via a ZapEvent to a Charge', [ - Level.ALL, - Level.CONFIG, - Level.FINE, - Level.FINER, - Level.FINEST, - Level.INFO, - Level.OFF, - Level.SEVERE, - Level.SHOUT, - Level.WARNING, - ], (Level level) { - if (useBoltLogger) { - BoltLogger.zap('zap', level: level); - BoltLogger.zap('shock', level: level); - } else { - TestReferenceClass().zapExtension('zap', level: level); - TestReferenceClass().shockExtension('shock', level: level); - } - - expect(memoryCharge.items.length, 2); - expect(memoryCharge.items[0].origin.level, level); - expect(memoryCharge.items[1].origin.level, level); - }); + 'zap/shock sends a LogLevel via a ZapEvent to a Charge', + [ + Level.ALL, + Level.CONFIG, + Level.FINE, + Level.FINER, + Level.FINEST, + Level.INFO, + Level.OFF, + Level.SEVERE, + Level.SHOUT, + Level.WARNING, + ], + (Level level) { + if (useBoltLogger) { + BoltLogger.zap('zap', level: level); + BoltLogger.zap('shock', level: level); + } else { + TestReferenceClass().zapExtension('zap', level: level); + TestReferenceClass().shockExtension('shock', level: level); + } + + expect(memoryCharge.items.length, 2); + expect(memoryCharge.items[0].origin.level, level); + expect(memoryCharge.items[1].origin.level, level); + }, + ); test('zap/shock sends Exception via a ZapEvent to a Charge', () { final exception = Exception('exception'); @@ -234,30 +222,17 @@ void main() { expect(memoryCharge.items[1].origin.stackTrace, stackTrace); }); - test( - 'zap/shock sends a List with more than 3 elements via a ZapEvent to a Charge', - () { + test('zap/shock sends a List with more than 3 elements via a ZapEvent to a Charge', () { final exception = Exception('exception'); final stackTrace = StackTrace.current; final error = Error(); if (useBoltLogger) { - expect( - () => BoltLogger.zap(['zap', exception, stackTrace, error]), - throwsAssertionError, - ); - expect( - () => BoltLogger.shock(['shock', exception, stackTrace, error]), - throwsAssertionError, - ); + expect(() => BoltLogger.zap(['zap', exception, stackTrace, error]), throwsAssertionError); + expect(() => BoltLogger.shock(['shock', exception, stackTrace, error]), throwsAssertionError); } else { + expect(() => TestReferenceClass().zapExtension(['zap', exception, stackTrace, error]), throwsAssertionError); expect( - () => TestReferenceClass() - .zapExtension(['zap', exception, stackTrace, error]), - throwsAssertionError, - ); - expect( - () => TestReferenceClass() - .shockExtension(['shock', exception, stackTrace, error]), + () => TestReferenceClass().shockExtension(['shock', exception, stackTrace, error]), throwsAssertionError, ); } @@ -267,13 +242,8 @@ void main() { } class TestReferenceClass { - void zapExtension(Object? message, {String? tag, Level level = Level.INFO}) => - zap(message, tag: tag, level: level); - - void shockExtension( - Object? message, { - String? tag, - Level level = Level.SEVERE, - }) => + void zapExtension(Object? message, {String? tag, Level level = Level.INFO}) => zap(message, tag: tag, level: level); + + void shockExtension(Object? message, {String? tag, Level level = Level.SEVERE}) => shock(message, tag: tag, level: level); } diff --git a/test/logger/memory_charge_test.dart b/test/logger/memory_charge_test.dart index 20f54b1..6787611 100644 --- a/test/logger/memory_charge_test.dart +++ b/test/logger/memory_charge_test.dart @@ -41,11 +41,5 @@ void main() { } ZapEvent _produceEvent(String input) { - return ZapEvent.fromRecord( - LogRecord( - Level.INFO, - input, - 'test', - ), - ); + return ZapEvent.fromRecord(LogRecord(Level.INFO, input, 'test')); } From 375f50ae4cc811e75207a8548a59f2a79ec68933 Mon Sep 17 00:00:00 2001 From: Job Guldemeester Date: Fri, 28 Mar 2025 10:15:27 +0100 Subject: [PATCH 4/6] :bookmark: Version bump --- CHANGELOG.md | 8 ++++++++ LICENSE | 2 +- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4bcd49..5b64c59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Changelog + +## 0.0.12 +* Updated dependencies +* Added test_util: catch presentation event helper, DeviceSizes +* Added typedef for single bool methods. +* Updated formatting + ## 0.0.11 Added optional secondary, secondaryFill, tertiary and tertiaryFill ColorGroups to the Kleurplaat diff --git a/LICENSE b/LICENSE index 59b303e..a51fb28 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Dutch Coding Company B.V. +Copyright (c) 2025 Dutch Coding Company B.V. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/pubspec.yaml b/pubspec.yaml index 9be8927..aeb3e9d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dcc_toolkit description: "Internal toolkit package used by the DCC team." -version: 0.0.11 +version: 0.0.12 homepage: https://dutchcodingcompany.com repository: https://github.com/DutchCodingCompany/dcc_toolkit From 2211f941885c66c5c8f3d2da0c287f36605d35cd Mon Sep 17 00:00:00 2001 From: Job Guldemeester Date: Fri, 28 Mar 2025 10:44:46 +0100 Subject: [PATCH 5/6] :wrench: Exported more files --- CHANGELOG.md | 1 + lib/dcc_toolkit.dart | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b64c59..f9cbba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added test_util: catch presentation event helper, DeviceSizes * Added typedef for single bool methods. * Updated formatting +* exported more files ## 0.0.11 Added optional secondary, secondaryFill, tertiary and tertiaryFill ColorGroups to the Kleurplaat diff --git a/lib/dcc_toolkit.dart b/lib/dcc_toolkit.dart index cc02ba1..18e62ac 100644 --- a/lib/dcc_toolkit.dart +++ b/lib/dcc_toolkit.dart @@ -10,3 +10,5 @@ export 'logger/bolt_logger.dart'; export 'style/style.dart'; export 'test_util/devices_sizes.dart'; export 'test_util/presentation_event_catcher.dart'; +export 'ui/blocful_widget.dart'; +export 'ui/native_dialog.dart'; From 2d04e776de08b02ff343adbae3686a7e32c22f93 Mon Sep 17 00:00:00 2001 From: Job Guldemeester Date: Fri, 28 Mar 2025 10:51:33 +0100 Subject: [PATCH 6/6] :art: formatted stuff --- lib/ui/native_dialog.dart | 52 +++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/lib/ui/native_dialog.dart b/lib/ui/native_dialog.dart index dd130a5..7bc87ba 100644 --- a/lib/ui/native_dialog.dart +++ b/lib/ui/native_dialog.dart @@ -24,35 +24,31 @@ void showNativeDialog( if (defaultTargetPlatform == TargetPlatform.iOS) { showCupertinoDialog( context: context, - builder: (context) => CupertinoAlertDialog( - title: Text(title), - content: Text(content), - actions: actions - .map( - (action) => CupertinoDialogAction( - onPressed: action.onTap, - isDestructiveAction: action.isDestructiveAction, - child: Text(action.text), - ), - ) - .toList(), - ), + builder: + (context) => CupertinoAlertDialog( + title: Text(title), + content: Text(content), + actions: + actions + .map( + (action) => CupertinoDialogAction( + onPressed: action.onTap, + isDestructiveAction: action.isDestructiveAction, + child: Text(action.text), + ), + ) + .toList(), + ), ); } else { showDialog( context: context, - builder: (context) => AlertDialog( - title: Text(title), - content: Text(content), - actions: actions - .map( - (action) => TextButton( - onPressed: action.onTap, - child: Text(action.text), - ), - ) - .toList(), - ), + builder: + (context) => AlertDialog( + title: Text(title), + content: Text(content), + actions: actions.map((action) => TextButton(onPressed: action.onTap, child: Text(action.text))).toList(), + ), ); } } @@ -60,11 +56,7 @@ void showNativeDialog( /// A dialog action which is used to show the actions of a native dialog. class DialogAction { /// Creates a [DialogAction]. - const DialogAction({ - required this.text, - required this.onTap, - this.isDestructiveAction = false, - }); + const DialogAction({required this.text, required this.onTap, this.isDestructiveAction = false}); /// The text of the action. final String text;