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
Jonny Borges
2021-12-31 19:30:29 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f2e15bbd281312ac7e94accffc40bc4a66eaf395
f2e15bbd
1 parent
6480b964
dry
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
142 additions
and
80 deletions
example_nav2/ios/Flutter/AppFrameworkInfo.plist
example_nav2/ios/Runner.xcodeproj/project.pbxproj
example_nav2/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
example_nav2/lib/main.dart
lib/get_navigation/src/nav2/get_router_delegate.dart
lib/get_rx/src/rx_stream/get_stream.dart
lib/get_rx/src/rx_types/rx_types.dart
lib/get_state_manager/src/rx_flutter/rx_notifier.dart
lib/get_state_manager/src/simple/get_controllers.dart
lib/get_state_manager/src/simple/list_notifier.dart
example_nav2/ios/Flutter/AppFrameworkInfo.plist
View file @
f2e15bb
...
...
@@ -21,6 +21,6 @@
<key>
CFBundleVersion
</key>
<string>
1.0
</string>
<key>
MinimumOSVersion
</key>
<string>
8
.0
</string>
<string>
9
.0
</string>
</dict>
</plist>
...
...
example_nav2/ios/Runner.xcodeproj/project.pbxproj
View file @
f2e15bb
...
...
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion =
46
;
objectVersion =
50
;
objects = {
/* Begin PBXBuildFile section */
...
...
@@ -127,7 +127,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1
02
0;
LastUpgradeCheck = 1
30
0;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
...
...
example_nav2/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
View file @
f2e15bb
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"1
02
0"
LastUpgradeVersion =
"1
30
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
example_nav2/lib/main.dart
View file @
f2e15bb
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'app/routes/app_pages.dart'
;
import
'services/auth_service.dart'
;
void
main
(
)
{
runApp
(
GetMaterialApp
.
router
(
title:
"Application"
,
initialBinding:
BindingsBuilder
(
()
{
Get
.
put
(
AuthService
());
},
),
getPages:
AppPages
.
routes
,
// routeInformationParser: GetInformationParser(
// // initialRoute: Routes.HOME,
// ),
// routerDelegate: GetDelegate(
// backButtonPopMode: PopMode.History,
// preventDuplicateHandlingMode:
// PreventDuplicateHandlingMode.ReorderRoutes,
// ),
GetMaterialApp
(
home:
Home
(),
),
);
}
class
Controller
extends
GetxController
{
final
count
=
0
.
reactive
;
void
increment
()
{
count
.
value
++;
update
();
}
}
class
Home
extends
ObxStatelessWidget
{
const
Home
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
final
controller
=
Get
.
put
(
Controller
());
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"counter"
)),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
SimpleBuilder
(
builder:
(
context
)
{
print
(
'builder'
);
return
Text
(
'
${controller.count.value}
'
,
style:
TextStyle
(
fontSize:
30
),
);
}),
// ElevatedButton(
// child: Text('Next Route'),
// onPressed: () {
// Get.to(() => Second());
// },
// ),
],
),
),
floatingActionButton:
FloatingActionButton
(
child:
Icon
(
Icons
.
add
),
onPressed:
controller
.
increment
,
),
);
}
}
...
...
lib/get_navigation/src/nav2/get_router_delegate.dart
View file @
f2e15bb
...
...
@@ -6,7 +6,8 @@ import 'package:flutter/material.dart';
import
'../../../get.dart'
;
import
'../../../get_state_manager/src/simple/list_notifier.dart'
;
class
GetDelegate
extends
RouterDelegate
<
GetNavConfig
>
with
ListNotifierMixin
{
class
GetDelegate
extends
RouterDelegate
<
GetNavConfig
>
with
ListNotifierSingleMixin
{
final
List
<
GetNavConfig
>
history
=
<
GetNavConfig
>[];
final
PopMode
backButtonPopMode
;
final
PreventDuplicateHandlingMode
preventDuplicateHandlingMode
;
...
...
lib/get_rx/src/rx_stream/get_stream.dart
View file @
f2e15bb
...
...
@@ -106,7 +106,7 @@ class GetStream<T> {
late
T
_value
;
T
get
value
{
RxInterface
.
proxy
?.
addListener
(
this
);
//
RxInterface.proxy?.addListener(this);
return
_value
;
}
...
...
lib/get_rx/src/rx_types/rx_types.dart
View file @
f2e15bb
...
...
@@ -4,6 +4,7 @@ import 'dart:async';
import
'dart:collection'
;
import
'package:flutter/foundation.dart'
;
import
'package:get/get_state_manager/src/simple/list_notifier.dart'
;
import
'../rx_stream/rx_stream.dart'
;
import
'../rx_typedefs/rx_typedefs.dart'
;
...
...
lib/get_state_manager/src/rx_flutter/rx_notifier.dart
View file @
f2e15bb
...
...
@@ -5,7 +5,7 @@ import '../../../instance_manager.dart';
import
'../../get_state_manager.dart'
;
import
'../simple/list_notifier.dart'
;
mixin
StateMixin
<
T
>
on
ListNotifier
Mixin
{
mixin
StateMixin
<
T
>
on
ListNotifier
{
late
T
_value
;
RxStatus
?
_status
;
...
...
@@ -27,7 +27,7 @@ mixin StateMixin<T> on ListNotifierMixin {
}
RxStatus
get
status
{
notifyChildrens
();
reportRead
();
return
_status
??=
_status
=
RxStatus
.
loading
();
}
...
...
@@ -35,7 +35,7 @@ mixin StateMixin<T> on ListNotifierMixin {
@protected
T
get
value
{
notifyChildrens
();
reportRead
();
return
_value
;
}
...
...
@@ -82,7 +82,7 @@ class Value<T> extends ListNotifier
@override
T
get
value
{
notifyChildrens
();
reportRead
();
return
_value
;
}
...
...
lib/get_state_manager/src/simple/get_controllers.dart
View file @
f2e15bb
...
...
@@ -6,8 +6,7 @@ import '../rx_flutter/rx_notifier.dart';
import
'list_notifier.dart'
;
// ignore: prefer_mixin
abstract
class
GetxController
extends
Listenable
with
GetLifeCycleMixin
,
ListNotifierMixin
{
abstract
class
GetxController
extends
ListNotifier
with
GetLifeCycleMixin
{
/// Rebuilds `GetBuilder` each time you call `update()`;
/// Can take a List of [ids], that will only update the matching
/// `GetBuilder( id: )`,
...
...
lib/get_state_manager/src/simple/list_notifier.dart
View file @
f2e15bb
import
'dart:collection'
;
import
'package:flutter/
widgets
.dart'
;
import
'package:flutter/
foundation
.dart'
;
// This callback remove the listener on addListener function
typedef
Disposer
=
void
Function
();
...
...
@@ -9,42 +9,50 @@ typedef Disposer = void Function();
// if it brings overhead the extra call,
typedef
GetStateUpdate
=
void
Function
();
class
ListNotifier
extends
Listenable
with
ListNotifierMixin
{}
class
ListNotifier
extends
Listenable
with
ListNotifierSingleMixin
,
ListNotifierGroupMixin
{}
mixin
ListNotifierMixin
on
Listenable
{
class
ListNotifierSingle
=
ListNotifier
with
ListNotifierSingleMixin
;
class
ListNotifierGroup
=
ListNotifier
with
ListNotifierGroupMixin
;
mixin
ListNotifierSingleMixin
on
Listenable
{
List
<
GetStateUpdate
?>?
_updaters
=
<
GetStateUpdate
?>[];
HashMap
<
Object
?,
List
<
GetStateUpdate
>>?
_updatersGroupIds
=
HashMap
<
Object
?,
List
<
GetStateUpdate
>>();
@override
Disposer
addListener
(
GetStateUpdate
listener
)
{
assert
(
_debugAssertNotDisposed
());
_updaters
!.
add
(
listener
);
return
()
=>
_updaters
!.
remove
(
listener
);
}
bool
containsListener
(
GetStateUpdate
listener
)
{
return
_updaters
?.
contains
(
listener
)
??
false
;
}
@override
void
removeListener
(
VoidCallback
listener
)
{
assert
(
_debugAssertNotDisposed
());
_updaters
!.
remove
(
listener
);
}
@protected
void
refresh
()
{
assert
(
_debugAssertNotDisposed
());
_notifyUpdate
();
}
@protected
void
reportRead
()
{
TaskManager
.
instance
.
notify
(
this
);
}
void
_notifyUpdate
()
{
for
(
var
element
in
_updaters
!)
{
element
!();
}
}
void
_notifyIdUpdate
(
Object
id
)
{
if
(
_updatersGroupIds
!.
containsKey
(
id
))
{
final
listGroup
=
_updatersGroupIds
![
id
]!;
for
(
var
item
in
listGroup
)
{
item
();
}
}
}
@protected
void
refreshGroup
(
Object
id
)
{
assert
(
_debugAssertNotDisposed
());
_notifyIdUpdate
(
id
);
}
bool
_debugAssertNotDisposed
()
{
assert
(()
{
if
(
_updaters
==
null
)
{
...
...
@@ -56,59 +64,79 @@ mixin ListNotifierMixin on Listenable {
return true;
}
@protected
void notifyChildrens() {
TaskManager.instance.notify(_updaters);
int get listenersLength {
assert(_debugAssertNotDisposed());
return _updaters!.length;
}
bool get hasListeners {
@mustCallSuper
void dispose() {
assert(_debugAssertNotDisposed());
return _updaters!.isNotEmpty
;
_updaters = null
;
}
}
mixin ListNotifierGroupMixin on Listenable {
HashMap<Object?, ListNotifierSingleMixin>? _updatersGroupIds =
HashMap<Object?, ListNotifierSingleMixin>();
int get listeners {
void _notifyGroupUpdate(Object id) {
if (_updatersGroupIds!.containsKey(id)) {
_updatersGroupIds![id]!._notifyUpdate();
}
}
@protected
void notifyGroupChildrens(Object id) {
assert(_debugAssertNotDisposed());
return _updaters!.length
;
TaskManager.instance.notify(_updatersGroupIds![id]!)
;
}
@override
void removeListener(VoidCallback listener) {
bool containsId(Object id) {
return _updatersGroupIds?.containsKey(id) ?? false;
}
@protected
void refreshGroup(Object id) {
assert(_debugAssertNotDisposed());
_updaters!.remove(listener);
_notifyGroupUpdate(id);
}
bool _debugAssertNotDisposed() {
assert(() {
if (_updatersGroupIds == null) {
throw FlutterError('''
A
$runtimeType
was
used
after
being
disposed
.
\
n
'Once you have called dispose() on a
$runtimeType
, it can no longer be used.'''
);
}
return
true
;
}());
return
true
;
}
void
removeListenerId
(
Object
id
,
VoidCallback
listener
)
{
assert
(
_debugAssertNotDisposed
());
if
(
_updatersGroupIds
!.
containsKey
(
id
))
{
_updatersGroupIds![id]!.remove(listener);
_updatersGroupIds
![
id
]!.
remove
Listener
(
listener
);
}
_updaters!.remove(listener);
}
@mustCallSuper
void
dispose
()
{
assert
(
_debugAssertNotDisposed
());
_updaters
= null
;
_updaters
GroupIds
?.
forEach
((
key
,
value
)
=>
value
.
dispose
())
;
_updatersGroupIds
=
null
;
}
@override
Disposer addListener(GetStateUpdate listener) {
assert(_debugAssertNotDisposed());
_updaters!.add(listener);
return () => _updaters!.remove(listener);
}
Disposer
addListenerId
(
Object
?
key
,
GetStateUpdate
listener
)
{
_updatersGroupIds![key] ??= <GetStateUpdate>[];
_updatersGroupIds![key]!.add(listener);
return () => _updatersGroupIds![key]!.remove(listener);
_updatersGroupIds
![
key
]
??=
ListNotifierSingle
();
return
_updatersGroupIds
![
key
]!.
addListener
(
listener
);
}
/// To dispose an [id] from future updates(), this ids are registered
/// by `GetBuilder()` or similar, so is a way to unlink the state change with
/// the Widget from the Controller.
void
disposeId
(
Object
id
)
{
_updatersGroupIds
?[
id
]?.
dispose
();
_updatersGroupIds
!.
remove
(
id
);
}
}
...
...
@@ -123,11 +151,18 @@ class TaskManager {
GetStateUpdate
?
_setter
;
List
<
VoidCallback
>?
_remove
;
void notify(List<GetStateUpdate?>? _updaters) {
if (_setter != null) {
if (!_updaters!.contains(_setter)) {
_updaters.add(_setter);
_remove!.add(() => _updaters.remove(_setter));
final
listNotifier
=
ListNotifierGroup
();
// void addElement(Object id, GetStateUpdate listener) {
// _remove?.add(listNotifier.addListenerId(id, listener));
// }
void
notify
(
ListNotifierSingleMixin
_updaters
)
{
final
listener
=
_setter
;
if
(
listener
!=
null
)
{
if
(!
_updaters
.
containsListener
(
listener
))
{
_updaters
.
addListener
(
listener
);
_remove
?.
add
(()
=>
_updaters
.
removeListener
(
listener
));
}
}
}
...
...
Please
register
or
login
to post a comment