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
Gabriel Rohden
2020-09-10 17:30:46 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
176fa4cd4b9a11b8dd80c48c70e72c5af2c865e3
176fa4cd
1 parent
d11200bd
fix(num) Fix num issues with operator overloads
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
50 deletions
lib/src/state_manager/rx/rx_core/rx_impl.dart
lib/src/state_manager/rx/rx_core/rx_impl.dart
View file @
176fa4c
...
...
@@ -217,81 +217,75 @@ class RxBool extends _RxImpl<bool> {
}
}
/// Base Rx class for `num` Types (`double` and `int`) as mostly share the same
/// operator overload, we centralize the common code here.
abstract
class
_BaseRxNum
<
T
>
extends
_RxImpl
<
num
>
{
_BaseRxNum
operator
+(
num
val
)
{
subject
.
add
(
_value
+=
val
);
return
this
;
}
_BaseRxNum
operator
-(
num
val
)
{
subject
.
add
(
_value
-=
val
);
return
this
;
}
_BaseRxNum
operator
/(
num
val
)
{
subject
.
add
(
_value
/=
val
);
return
this
;
}
_BaseRxNum
operator
*(
num
val
)
{
subject
.
add
(
_value
*=
val
);
return
this
;
}
/// Rx class for `num` Types (`double` and `int`) shared comparison operations
abstract
class
_RxNumComparators
<
T
extends
num
>
extends
_RxImpl
<
T
>
{
bool
operator
<=(
T
other
)
=>
_value
<=
other
;
_BaseRxNum
operator
~/(
num
val
)
{
subject
.
add
(
_value
~/
val
);
return
this
;
}
bool
operator
>=(
T
other
)
=>
_value
>=
other
;
_BaseRxNum
operator
%(
num
val
)
{
subject
.
add
(
_value
%
val
);
return
this
;
}
bool
operator
<(
T
other
)
=>
_value
<
other
;
bool
operator
<=(
num
other
)
=>
_value
<=
other
;
bool
operator
>=(
num
other
)
=>
_value
>=
other
;
bool
operator
<(
num
other
)
=>
_value
<
other
;
bool
operator
>(
num
other
)
=>
_value
>
other
;
bool
operator
>(
T
other
)
=>
_value
>
other
;
}
/// Rx class for `double` Type.
class
RxDouble
extends
_
BaseRxNum
<
double
>
{
class
RxDouble
extends
_
RxNumComparators
<
double
>
{
RxDouble
([
double
initial
])
{
_value
=
initial
;
}
double
operator
*(
double
val
)
=>
_value
*
val
;
double
operator
-(
double
val
)
=>
_value
-
val
;
double
operator
+(
double
val
)
=>
_value
+
val
;
double
operator
/(
double
val
)
=>
_value
/
val
;
double
operator
%(
double
val
)
=>
_value
%
val
;
}
/// Rx class for `num` Type.
class
RxNum
extends
_
BaseRxNum
<
num
>
{
class
RxNum
extends
_
RxNumComparators
<
num
>
{
RxNum
([
num
initial
])
{
_value
=
initial
;
}
num
operator
*(
num
val
)
=>
_value
*
val
;
num
operator
-(
num
val
)
=>
_value
-
val
;
num
operator
+(
num
val
)
=>
_value
+
val
;
num
operator
/(
num
val
)
=>
_value
/
val
;
num
operator
%(
num
val
)
=>
_value
%
val
;
}
/// Rx class for `String` Type.
class
RxString
extends
_RxImpl
<
String
>
{
RxString
([
String
initial
])
{
/// Rx class for `int` Type.
class
RxInt
extends
_RxNumComparators
<
int
>
{
RxInt
([
int
initial
])
{
_value
=
initial
;
}
RxString
operator
+(
String
val
)
{
subject
.
add
(
_value
+=
val
);
return
this
;
}
int
operator
%(
int
val
)
=>
_value
%
val
;
RxString
operator
*(
int
val
)
{
subject
.
add
(
_value
*=
val
);
return
this
;
}
int
operator
*(
int
val
)
=>
_value
*
val
;
int
operator
-(
int
val
)
=>
_value
-
val
;
int
operator
+(
int
val
)
=>
_value
+
val
;
double
operator
/(
int
val
)
=>
_value
/
val
;
}
/// Rx class for `int` Type.
class
RxInt
extends
_BaseRxNum
<
int
>
{
RxInt
([
int
initial
])
{
/// Rx class for `String` Type.
class
RxString
extends
_RxImpl
<
String
>
{
RxString
([
String
initial
])
{
_value
=
initial
;
}
String
operator
+(
String
val
)
=>
_value
+
val
;
}
/// Foundation class used for custom `Types` outside the common native Dart
...
...
Please
register
or
login
to post a comment