Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
MHosssam
2021-12-01 12:38:38 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2021-12-01 12:38:38 +0200
Commit
8a3babdc93c48870283d14eb9cf18400d3395a42
8a3babdc
1 parent
f47d67e9
Update simple_builder.dart
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
lib/get_state_manager/src/simple/simple_builder.dart
lib/get_state_manager/src/simple/simple_builder.dart
View file @
8a3babd
...
...
@@ -5,7 +5,7 @@ import 'list_notifier.dart';
typedef
ValueBuilderUpdateCallback
<
T
>
=
void
Function
(
T
snapshot
);
typedef
ValueBuilderBuilder
<
T
>
=
Widget
Function
(
T
?
snapshot
,
ValueBuilderUpdateCallback
<
T
>
updater
);
T
snapshot
,
ValueBuilderUpdateCallback
<
T
>
updater
);
/// Manages a local state like ObxValue, but uses a callback instead of
/// a Rx value.
...
...
@@ -23,36 +23,32 @@ typedef ValueBuilderBuilder<T> = Widget Function(
/// ),
/// ```
class
ValueBuilder
<
T
>
extends
StatefulWidget
{
final
T
?
initialValue
;
final
T
initialValue
;
final
ValueBuilderBuilder
<
T
>
builder
;
final
void
Function
()?
onDispose
;
final
void
Function
(
T
)?
onUpdate
;
const
ValueBuilder
({
Key
?
key
,
this
.
initialValue
,
required
this
.
initialValue
,
this
.
onDispose
,
this
.
onUpdate
,
required
this
.
builder
,
})
:
super
(
key:
key
);
@override
_ValueBuilderState
<
T
>
createState
()
=>
_ValueBuilderState
<
T
>();
_ValueBuilderState
<
T
>
createState
()
=>
_ValueBuilderState
<
T
>(
initialValue
);
}
class
_ValueBuilderState
<
T
>
extends
State
<
ValueBuilder
<
T
?>>
{
T
?
value
;
T
value
;
_ValueBuilderState
(
this
.
value
);
@override
void
initState
()
{
super
.
initState
();
value
=
widget
.
initialValue
;
}
@override
Widget
build
(
BuildContext
context
)
=>
widget
.
builder
(
value
,
updater
);
void
updater
(
T
?
newValue
)
{
void
updater
(
T
newValue
)
{
if
(
widget
.
onUpdate
!=
null
)
{
widget
.
onUpdate
!(
newValue
);
}
...
...
@@ -70,7 +66,6 @@ class _ValueBuilderState<T> extends State<ValueBuilder<T?>> {
}
else
if
(
value
is
StreamController
)
{
(
value
as
StreamController
?)?.
close
();
}
value
=
null
;
}
}
...
...
Please
register
or
login
to post a comment