From e21c7410b8aad25dd53ab71ebfb69d042389c33b Mon Sep 17 00:00:00 2001 From: Hans Kokx Date: Thu, 10 Oct 2024 13:01:51 +0200 Subject: [PATCH] v1.1.0 Removed Unfocuser Signed-off-by: Hans Kokx --- CHANGELOG.md | 6 +++ example/lib/main.dart | 23 +++++---- lib/arcane_helper_utils.dart | 1 - lib/src/widgets/unfocuser.dart | 88 ---------------------------------- pubspec.yaml | 5 -- 5 files changed, 17 insertions(+), 106 deletions(-) delete mode 100644 lib/src/widgets/unfocuser.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 794e2ae..0a85ca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.1.0 + +- [BREAKING] Removed `Unfocuser` widget to ensure pure Dart compatibility. + +To continue using `Unfocuser`, add `unfocuser: ^1.0.0` to your pubspec.yaml. + ## 1.0.4 - Added `yesterday` and `tomorrow` extensions to `DateTime` diff --git a/example/lib/main.dart b/example/lib/main.dart index 9f37b9a..4a45d03 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,37 +1,36 @@ import "package:arcane_helper_utils/arcane_helper_utils.dart"; -import "package:flutter/foundation.dart"; void main() { // DateTime final DateTime dateTime = DateTime(2019, 1, 1, 13, 45); - debugPrint(dateTime.toIso8601String()); // 2019-01-01T13:45:00.0 - debugPrint(dateTime.startOfHour.toIso8601String()); // 2019-01-01T13:00:00.0 + print(dateTime.toIso8601String()); // 2019-01-01T13:45:00.0 + print(dateTime.startOfHour.toIso8601String()); // 2019-01-01T13:00:00.0 final bool today = DateTime.now().isToday; final bool notToday = DateTime(2001, 12, 31).isToday; - debugPrint("$today"); // true - debugPrint("$notToday"); // false + print("$today"); // true + print("$notToday"); // false final DateTime yesterday = DateTime(0).yesterday; final DateTime tomorrow = DateTime(0).tomorrow; - debugPrint("Yesterday: $yesterday"); - debugPrint("Tomorrow: $tomorrow"); + print("Yesterday: $yesterday"); + print("Tomorrow: $tomorrow"); // Strings const String? nullString = null; const String emptyString = " "; const String nonEmptyString = "Hello World!"; - debugPrint("${nullString.isNullOrEmpty}"); // true - debugPrint("${emptyString.isNullOrEmpty}"); // true - debugPrint("${nonEmptyString.isNullOrEmpty}"); // false + print("${nullString.isNullOrEmpty}"); // true + print("${emptyString.isNullOrEmpty}"); // true + print("${nonEmptyString.isNullOrEmpty}"); // false const String text = "DartLang"; final List result = text.splitByLength(3); - debugPrint("$result"); // ["Dar", "tLa", "ng"] + print("$result"); // ["Dar", "tLa", "ng"] const String lowercase = "hello"; final String capitalized = lowercase.capitalize; - debugPrint(capitalized); // "Hello" + print(capitalized); // "Hello" } diff --git a/lib/arcane_helper_utils.dart b/lib/arcane_helper_utils.dart index 30962b1..68f8ffe 100644 --- a/lib/arcane_helper_utils.dart +++ b/lib/arcane_helper_utils.dart @@ -5,4 +5,3 @@ export "package:arcane_helper_utils/src/extensions/string.dart"; export "package:arcane_helper_utils/src/extensions/string_jwt.dart"; export "package:arcane_helper_utils/src/utils/json_converter.dart"; export "package:arcane_helper_utils/src/utils/ticker.dart"; -export "package:arcane_helper_utils/src/widgets/unfocuser.dart"; diff --git a/lib/src/widgets/unfocuser.dart b/lib/src/widgets/unfocuser.dart deleted file mode 100644 index 6e0a1ab..0000000 --- a/lib/src/widgets/unfocuser.dart +++ /dev/null @@ -1,88 +0,0 @@ -/* -(c) Copyright 2020 Serov Konstantin. - -Licensed under the MIT license: - - http://www.opensource.org/licenses/mit-license.php - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -import "package:flutter/material.dart"; - -/// A widget that unfocuses the currently focused widget when tapping outside of it. -/// -/// This is useful for dismissing the keyboard or any focused input field when the user -/// taps outside of the focused area. The widget wraps its `child` with a `GestureDetector` -/// that detects taps and unfocuses the primary focus if there is any. -/// -/// The unfocus behavior can be disabled by setting [isEnabled] to `false`. -/// -/// Example usage: -/// -/// ```dart -/// Unfocuser( -/// child: YourWidget(), -/// ) -/// ``` -/// -/// This will unfocus any input fields when the user taps outside of them. -/// -/// [child] The widget that this widget wraps. -/// [isEnabled] Whether the unfocus behavior is enabled. Defaults to `true`. -class Unfocuser extends StatelessWidget { - /// Creates an [Unfocuser] widget. - /// - /// The [child] parameter must not be null. The [isEnabled] parameter determines - /// whether the unfocus functionality is active. - const Unfocuser({ - required this.child, - super.key, - this.isEnabled = true, - }); - - /// The widget below this widget in the tree. - /// - /// This widget will be wrapped with a `GestureDetector` that triggers an - /// unfocus action when tapped outside a focused widget, if [isEnabled] is `true`. - final Widget child; - - /// Whether this widget will trigger the unfocus action. - /// - /// If set to `true`, tapping outside a focused widget will unfocus it. - /// Defaults to `true`. - final bool isEnabled; - - @override - Widget build(BuildContext context) { - if (!isEnabled) { - return child; - } - return GestureDetector( - onTap: () { - final focusScopeNode = FocusScope.of(context); - if (focusScopeNode.hasPrimaryFocus == false && - focusScopeNode.focusedChild != null) { - FocusManager.instance.primaryFocus?.unfocus(); - } - }, - child: child, - ); - } -} diff --git a/pubspec.yaml b/pubspec.yaml index 7becf5a..439f914 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,15 +12,10 @@ topics: environment: sdk: ^3.5.2 - flutter: ">=1.17.0" dependencies: - flutter: - sdk: flutter freezed_annotation: ^2.4.4 week_number: ^1.1.0 dev_dependencies: arcane_analysis: ^1.0.1 - flutter_test: - sdk: flutter