Skip to content

Commit 28cb180

Browse files
committed
Support return null for wire function
1 parent 9484d44 commit 28cb180

File tree

12 files changed

+16
-15
lines changed

12 files changed

+16
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
**2.0.1**
44
* Fixed tooltip and popover position
5+
* Support return null for wire function
56

67
**2.0.0**
78
* Migrate to null safety

lib/src/affix.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Affix extends Base {
2828
/**
2929
*
3030
*/
31-
static Affix wire(Element element, [Affix create()?]) =>
31+
static Affix? wire(Element element, [Affix? create()?]) =>
3232
p.wire(element, _name, create ?? (() => Affix(element)));
3333

3434
/**

lib/src/alert.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Alert extends Base {
2020
* + [create] - If provided, it will be used for Alert creation. Otherwise
2121
* the default constructor with no optional parameter value is used.
2222
*/
23-
static Alert wire(Element element, [Alert create()?]) =>
23+
static Alert? wire(Element element, [Alert? create()?]) =>
2424
p.wire(element, _name, create ?? (() => Alert(element)));
2525

2626
/** Detach the Alert component from DOM.

lib/src/button.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Button extends Base {
3131
* + [create] - If provided, it will be used for Button creation. Otherwise
3232
* the default constructor with no optional parameter value is used.
3333
*/
34-
static Button wire(Element element, [Button create()?]) =>
34+
static Button? wire(Element element, [Button? create()?]) =>
3535
p.wire(element, _name, create ?? (() => Button(element)));
3636

3737
/** Set the button state, which will change the button text according to [texts]
@@ -87,7 +87,7 @@ class Button extends Base {
8787
if (e.target is Element) {
8888
final $btn = $(e.target).closest('.btn');
8989
if ($btn.isNotEmpty)
90-
Button.wire($btn.first).toggle();
90+
Button.wire($btn.first)!.toggle();
9191
}
9292

9393
}, selector: '[data-toggle^=button]');

lib/src/collapse.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Collapse extends Base {
3232
* + [create] - If provided, it will be used for Collapse creation. Otherwise
3333
* the default constructor with no optional parameter value is used.
3434
*/
35-
static Collapse wire(Element element, [Collapse create()?]) =>
35+
static Collapse? wire(Element element, [Collapse? create()?]) =>
3636
p.wire(element, _name, create ?? (() => Collapse(element)));
3737

3838

@@ -65,7 +65,7 @@ class Collapse extends Base {
6565
if (active?.transitioning ?? false)
6666
return;
6767

68-
Collapse.wire(elem).hide();
68+
Collapse.wire(elem)!.hide();
6969
$(elem).data.set(_name, null);
7070
}
7171

lib/src/dropdown.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Dropdown extends Base {
2323
* + [create] - If provided, it will be used for Dropdown creation. Otherwise
2424
* the default constructor with no optional parameter value is used.
2525
*/
26-
static Dropdown wire(Element element, [Dropdown create()?]) =>
26+
static Dropdown? wire(Element element, [Dropdown? create()?]) =>
2727
p.wire(element, _name, create ?? (() => Dropdown(element)));
2828

2929
/** Toggle the open/close state of the Dropdown.

lib/src/modal.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Modal extends Base {
3232
* + [create] - If provided, it will be used for Modal creation. Otherwise
3333
* the default constructor with no optional parameter value is used.
3434
*/
35-
static Modal wire(Element element, [Modal create()?]) =>
35+
static Modal? wire(Element element, [Modal? create()?]) =>
3636
p.wire(element, _name, create ?? (() => Modal(element)));
3737

3838
/** Toggle the visibility state of the Modal.
@@ -224,7 +224,7 @@ class Modal extends Base {
224224
return;
225225

226226
// , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
227-
Modal.wire($target.first, () => Modal($target.first)).toggle(); // TODO: other options
227+
Modal.wire($target.first, () => Modal($target.first))!.toggle(); // TODO: other options
228228

229229
$target.one('hide', (QueryEvent e) => $(elem).trigger('focus'));
230230

lib/src/popover.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Popover extends Tooltip {
3737
* + [create] - If provided, it will be used for Popover creation. Otherwise
3838
* the default constructor with no optional parameter value is used.
3939
*/
40-
static Popover wire(Element element, [Popover create()?]) =>
40+
static Popover? wire(Element element, [Popover? create()?]) =>
4141
p.wire(element, _name, create ?? (() => Popover(element)));
4242

4343
@override

lib/src/scrollspy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Scrollspy extends Base {
3434
* Scrollspy object, a new one will be created.
3535
*
3636
*/
37-
static Scrollspy wire(Element element, [Scrollspy create()?]) =>
37+
static Scrollspy? wire(Element element, [Scrollspy? create()?]) =>
3838
p.wire(element, _name, create ?? (() => Scrollspy(element)));
3939

4040
final ElementQuery _$body;

lib/src/tab.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Tab extends Base {
1919
* + [create] - If provided, it will be used for Tab creation. Otherwise
2020
* the default constructor with no optional parameter value is used.
2121
*/
22-
static Tab wire(Element element, [Tab create()?]) =>
22+
static Tab? wire(Element element, [Tab? create()?]) =>
2323
p.wire(element, _name, create ?? (() => Tab(element)));
2424

2525
/** Show the tab.
@@ -94,7 +94,7 @@ class Tab extends Base {
9494

9595
$document().on('click.tab.data-api', (QueryEvent e) {
9696
e.preventDefault();
97-
wire(e.target as Element).show();
97+
wire(e.target as Element)!.show();
9898

9999
}, selector: '[data-toggle="tab"], [data-toggle="pill"]');
100100
}

0 commit comments

Comments
 (0)