mirror of
https://github.com/hanskokx/arcane_helper_utils.git
synced 2026-05-14 02:19:09 +02:00
v1.1.0
Removed Unfocuser Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -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
|
## 1.0.4
|
||||||
|
|
||||||
- Added `yesterday` and `tomorrow` extensions to `DateTime`
|
- Added `yesterday` and `tomorrow` extensions to `DateTime`
|
||||||
|
|||||||
+11
-12
@@ -1,37 +1,36 @@
|
|||||||
import "package:arcane_helper_utils/arcane_helper_utils.dart";
|
import "package:arcane_helper_utils/arcane_helper_utils.dart";
|
||||||
import "package:flutter/foundation.dart";
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// DateTime
|
// DateTime
|
||||||
final DateTime dateTime = DateTime(2019, 1, 1, 13, 45);
|
final DateTime dateTime = DateTime(2019, 1, 1, 13, 45);
|
||||||
debugPrint(dateTime.toIso8601String()); // 2019-01-01T13:45:00.0
|
print(dateTime.toIso8601String()); // 2019-01-01T13:45:00.0
|
||||||
debugPrint(dateTime.startOfHour.toIso8601String()); // 2019-01-01T13:00:00.0
|
print(dateTime.startOfHour.toIso8601String()); // 2019-01-01T13:00:00.0
|
||||||
|
|
||||||
final bool today = DateTime.now().isToday;
|
final bool today = DateTime.now().isToday;
|
||||||
final bool notToday = DateTime(2001, 12, 31).isToday;
|
final bool notToday = DateTime(2001, 12, 31).isToday;
|
||||||
debugPrint("$today"); // true
|
print("$today"); // true
|
||||||
debugPrint("$notToday"); // false
|
print("$notToday"); // false
|
||||||
|
|
||||||
final DateTime yesterday = DateTime(0).yesterday;
|
final DateTime yesterday = DateTime(0).yesterday;
|
||||||
final DateTime tomorrow = DateTime(0).tomorrow;
|
final DateTime tomorrow = DateTime(0).tomorrow;
|
||||||
|
|
||||||
debugPrint("Yesterday: $yesterday");
|
print("Yesterday: $yesterday");
|
||||||
debugPrint("Tomorrow: $tomorrow");
|
print("Tomorrow: $tomorrow");
|
||||||
|
|
||||||
// Strings
|
// Strings
|
||||||
const String? nullString = null;
|
const String? nullString = null;
|
||||||
const String emptyString = " ";
|
const String emptyString = " ";
|
||||||
const String nonEmptyString = "Hello World!";
|
const String nonEmptyString = "Hello World!";
|
||||||
|
|
||||||
debugPrint("${nullString.isNullOrEmpty}"); // true
|
print("${nullString.isNullOrEmpty}"); // true
|
||||||
debugPrint("${emptyString.isNullOrEmpty}"); // true
|
print("${emptyString.isNullOrEmpty}"); // true
|
||||||
debugPrint("${nonEmptyString.isNullOrEmpty}"); // false
|
print("${nonEmptyString.isNullOrEmpty}"); // false
|
||||||
|
|
||||||
const String text = "DartLang";
|
const String text = "DartLang";
|
||||||
final List<String> result = text.splitByLength(3);
|
final List<String> result = text.splitByLength(3);
|
||||||
debugPrint("$result"); // ["Dar", "tLa", "ng"]
|
print("$result"); // ["Dar", "tLa", "ng"]
|
||||||
|
|
||||||
const String lowercase = "hello";
|
const String lowercase = "hello";
|
||||||
final String capitalized = lowercase.capitalize;
|
final String capitalized = lowercase.capitalize;
|
||||||
debugPrint(capitalized); // "Hello"
|
print(capitalized); // "Hello"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/extensions/string_jwt.dart";
|
||||||
export "package:arcane_helper_utils/src/utils/json_converter.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/utils/ticker.dart";
|
||||||
export "package:arcane_helper_utils/src/widgets/unfocuser.dart";
|
|
||||||
|
|||||||
@@ -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,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,15 +12,10 @@ topics:
|
|||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.5.2
|
sdk: ^3.5.2
|
||||||
flutter: ">=1.17.0"
|
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
|
||||||
sdk: flutter
|
|
||||||
freezed_annotation: ^2.4.4
|
freezed_annotation: ^2.4.4
|
||||||
week_number: ^1.1.0
|
week_number: ^1.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
arcane_analysis: ^1.0.1
|
arcane_analysis: ^1.0.1
|
||||||
flutter_test:
|
|
||||||
sdk: flutter
|
|
||||||
|
|||||||
Reference in New Issue
Block a user