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
2022-11-21 11:50:33 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b9822f2cba8747341b8031a5630526f4c87b7d52
b9822f2c
1 parent
d586377c
refactor bind create and fix scope problem
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
3 deletions
example_nav2/lib/app/modules/home/views/home_view.dart
example_nav2/lib/app/modules/product_details/bindings/product_details_binding.dart
example_nav2/lib/app/routes/app_pages.dart
example_nav2/lib/main.dart
lib/get_instance/src/extension_instance.dart
lib/get_state_manager/src/simple/get_state.dart
lib/get_state_manager/src/simple/get_view.dart
example_nav2/lib/app/modules/home/views/home_view.dart
View file @
b9822f2
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'../../../../main.dart'
;
import
'../../../routes/app_pages.dart'
;
import
'../controllers/home_controller.dart'
;
...
...
@@ -8,6 +9,8 @@ class HomeView extends GetView<HomeController> {
const
HomeView
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
final
value
=
Get
.
find
<
Controller
>();
print
(
value
);
return
GetRouterOutlet
.
builder
(
routerDelegate:
Get
.
nestedKey
(
Routes
.
home
),
builder:
(
context
)
{
...
...
example_nav2/lib/app/modules/product_details/bindings/product_details_binding.dart
View file @
b9822f2
...
...
@@ -5,6 +5,7 @@ import '../controllers/product_details_controller.dart';
class
ProductDetailsBinding
extends
Binding
{
@override
List
<
Bind
>
dependencies
()
{
print
(
'JDISOJDOSIJOI'
);
return
[
Bind
.
create
<
ProductDetailsController
>(
(
_
)
=>
ProductDetailsController
(
...
...
example_nav2/lib/app/routes/app_pages.dart
View file @
b9822f2
...
...
@@ -76,14 +76,14 @@ class AppPages {
transition:
Transition
.
cupertino
,
showCupertinoParallax:
true
,
participatesInRootNavigator:
false
,
bindings:
[
ProductsBinding
()],
bindings:
[
ProductsBinding
()
,
ProductDetailsBinding
()
],
children:
[
GetPage
(
name:
_Paths
.
productDetails
,
transition:
Transition
.
cupertino
,
showCupertinoParallax:
true
,
page:
()
=>
ProductDetailsView
(),
bindings:
[
ProductDetailsBinding
()
],
bindings:
[],
middlewares:
[
//only enter this route when authed
EnsureAuthMiddleware
(),
...
...
example_nav2/lib/main.dart
View file @
b9822f2
import
'package:example_nav2/services/auth_service.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'app/modules/splash/controllers/splash_service.dart'
;
import
'app/routes/app_pages.dart'
;
import
'services/auth_service.dart'
;
class
Controller
{}
void
main
(
)
{
runApp
(
GetMaterialApp
(
title:
"Application"
,
binds:
[
Bind
.
create
<
Controller
>(
(
_
)
=>
Controller
(),
),
Bind
.
put
(
SplashService
()),
Bind
.
put
(
AuthService
()),
],
...
...
lib/get_instance/src/extension_instance.dart
View file @
b9822f2
...
...
@@ -20,6 +20,11 @@ class InstanceInfo {
required
this
.
isPrepared
,
required
this
.
isInit
,
});
@override
String
toString
()
{
return
'InstanceInfo(isPermanent:
$isPermanent
, isSingleton:
$isSingleton
, isRegistered:
$isRegistered
, isPrepared:
$isPrepared
, isInit:
$isInit
)'
;
}
}
extension
Inst
on
GetInterface
{
...
...
lib/get_state_manager/src/simple/get_state.dart
View file @
b9822f2
...
...
@@ -463,6 +463,12 @@ class BindElement<T> extends InheritedElement {
}
}
}
else
{
if
(
widget
.
create
!=
null
)
{
_controllerBuilder
=
()
=>
widget
.
create
!.
call
(
this
);
Get
.
create
<
T
>(
_controllerBuilder
!,
tag:
widget
.
tag
,
permanent:
false
);
}
else
{
_controllerBuilder
=
widget
.
init
;
}
_controllerBuilder
=
(
widget
.
create
!=
null
?
()
=>
widget
.
create
!.
call
(
this
)
:
null
)
??
widget
.
init
;
...
...
lib/get_state_manager/src/simple/get_view.dart
View file @
b9822f2
...
...
@@ -74,13 +74,20 @@ class _GetCache<S extends GetLifeCycleMixin> extends WidgetCache<GetWidget<S>> {
void
onInit
()
{
info
=
Get
.
getInstanceInfo
<
S
>(
tag:
widget
!.
tag
);
print
(
'info:
$info
'
);
_isCreator
=
info
!.
isPrepared
&&
info
!.
isCreate
;
if
(
info
!.
isRegistered
)
{
_controller
=
Get
.
find
<
S
>(
tag:
widget
!.
tag
);
}
print
(
'controller:
$_controller
'
);
print
(
'widget:
$widget
'
);
GetWidget
.
_cache
[
widget
!]
=
_controller
;
print
(
'cache:
${GetWidget._cache}
'
);
super
.
onInit
();
}
...
...
Please
register
or
login
to post a comment