Skip to content

Commit 35bfecc

Browse files
committed
unfocuser isEnabled
1 parent 8f69cf2 commit 35bfecc

6 files changed

Lines changed: 15 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [2.10.4]
2+
- Unfocuser now has isEnabled parameter so it can be easily disabled when it's
3+
not necessage e.g. on the web
14
## [2.10.3]
25
- CountryDropdown now does not have initialCountryCode parameter but uses initialPhoneCode instead, because some countries might have a few phone codes and we need to determin which one of them should be used
36
## [2.10.2]

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ packages:
8989
path: ".."
9090
relative: true
9191
source: path
92-
version: "2.10.3"
92+
version: "2.10.4"
9393
flutter_test:
9494
dependency: "direct dev"
9595
description: flutter

lib/formatters/credit_card_number_input_formatter.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ THE SOFTWARE.
2626

2727
import 'dart:math';
2828

29-
import 'package:flutter/foundation.dart';
3029
import 'package:flutter/services.dart';
3130

3231
import 'formatter_utils.dart';

lib/formatters/money_input_formatter.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ THE SOFTWARE.
2626

2727
import 'dart:math';
2828

29-
import 'package:flutter/foundation.dart';
3029
import 'package:flutter/services.dart';
3130

3231
import 'formatter_utils.dart';

lib/utils/unfocuser.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ import 'package:flutter/rendering.dart';
3636
/// In case you want it to always unfocus current text field
3737
/// just set this value to 0.0
3838
class Unfocuser extends StatefulWidget {
39-
final Widget? child;
39+
final Widget child;
4040
final double minScrollDistance;
41+
final bool isEnabled;
4142

4243
const Unfocuser({
4344
Key? key,
44-
this.child,
45+
required this.child,
46+
this.isEnabled = true,
4547
this.minScrollDistance = 10.0,
4648
}) : super(key: key);
4749

@@ -55,6 +57,9 @@ class _UnfocuserState extends State<Unfocuser> {
5557

5658
@override
5759
Widget build(BuildContext context) {
60+
if (!widget.isEnabled) {
61+
return widget.child;
62+
}
5863
return Listener(
5964
onPointerDown: (e) {
6065
_touchStartPosition = e.position;
@@ -73,8 +78,8 @@ class _UnfocuserState extends State<Unfocuser> {
7378
var result = BoxHitTestResult();
7479
rb.hitTest(result, position: touchStopPosition);
7580

76-
if (result.path.any(
77-
(entry) => entry.target.runtimeType == IgnoreUnfocuserRenderBox)) {
81+
if (result.path
82+
.any((entry) => entry.target.runtimeType == IgnoreUnfocuserRenderBox)) {
7883
return;
7984
}
8085
var isEditable = result.path.any((entry) =>
@@ -120,8 +125,7 @@ class IgnoreUnfocuser extends SingleChildRenderObjectWidget {
120125
}
121126

122127
class ForceUnfocuser extends SingleChildRenderObjectWidget {
123-
const ForceUnfocuser({Key? key, required Widget child})
124-
: super(key: key, child: child);
128+
const ForceUnfocuser({Key? key, required Widget child}) : super(key: key, child: child);
125129

126130
@override
127131
ForceUnfocuserRenderBox createRenderObject(BuildContext context) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_multi_formatter
22
description: A package of formatters for international phone numbers, credit / debit cards and a masked formatter
3-
version: 2.10.3
3+
version: 2.10.4
44
homepage: https://github.com/caseyryan/flutter_multi_formatter
55

66
environment:

0 commit comments

Comments
 (0)