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
Ahmed Fwela
2021-05-30 12:06:02 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c3b673fb7957c146a586a3008a8bfe661f0d2ef5
c3b673fb
1 parent
f58bc304
added router outlet
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
288 additions
and
23 deletions
.vscode/launch.json
example_nav2/lib/app/modules/home/controllers/home_controller.dart
example_nav2/lib/app/modules/product_details/bindings/product_details_binding.dart
example_nav2/lib/app/modules/product_details/controllers/product_details_controller.dart
example_nav2/lib/app/modules/product_details/views/product_details_view.dart
example_nav2/lib/app/modules/profile/bindings/profile_binding.dart
example_nav2/lib/app/modules/profile/controllers/profile_controller.dart
example_nav2/lib/app/modules/profile/views/profile_view.dart
example_nav2/lib/app/modules/settings/bindings/settings_binding.dart
example_nav2/lib/app/modules/settings/controllers/settings_controller.dart
example_nav2/lib/app/modules/settings/views/settings_view.dart
example_nav2/lib/app/routes/app_pages.dart
example_nav2/lib/app/routes/app_routes.dart
example_nav2/pubspec.yaml
lib/get_core/src/get_interface.dart
lib/get_instance/src/extension_instance.dart
lib/get_navigation/src/nav2/router_outlet.dart
.vscode/launch.json
0 → 100644
View file @
c3b673f
{
//
Use
IntelliSense
to
learn
about
possible
attributes.
//
Hover
to
view
descriptions
of
existing
attributes.
//
For
more
information,
visit:
https://go.microsoft.com/fwlink/?linkid=830387
"version"
:
"0.2.0"
,
"configurations"
:
[
{
"name"
:
"getx"
,
"request"
:
"launch"
,
"type"
:
"dart"
},
{
"name"
:
"example"
,
"cwd"
:
"example"
,
"request"
:
"launch"
,
"type"
:
"dart"
},
{
"name"
:
"example_nav2"
,
"cwd"
:
"example_nav2"
,
"request"
:
"launch"
,
"type"
:
"dart"
}
]
}
\ No newline at end of file
...
...
example_nav2/lib/app/modules/home/controllers/home_controller.dart
View file @
c3b673f
import
'package:get/get.dart'
;
class
HomeController
extends
GetxController
{
//TODO: Implement HomeController
final
count
=
0
.
obs
;
@override
void
onInit
()
{
super
.
onInit
();
}
@override
void
onReady
()
{
super
.
onReady
();
}
@override
void
onClose
()
{}
void
increment
()
=>
count
.
value
++;
}
class
HomeController
extends
GetxController
{}
...
...
example_nav2/lib/app/modules/product_details/bindings/product_details_binding.dart
0 → 100644
View file @
c3b673f
import
'package:get/get.dart'
;
import
'../controllers/product_details_controller.dart'
;
class
ProductDetailsBinding
extends
Bindings
{
@override
void
dependencies
()
{
Get
.
lazyPut
<
ProductDetailsController
>(
()
=>
ProductDetailsController
(),
);
}
}
...
...
example_nav2/lib/app/modules/product_details/controllers/product_details_controller.dart
0 → 100644
View file @
c3b673f
import
'package:get/get.dart'
;
class
ProductDetailsController
extends
GetxController
{}
...
...
example_nav2/lib/app/modules/product_details/views/product_details_view.dart
0 → 100644
View file @
c3b673f
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'../controllers/product_details_controller.dart'
;
class
ProductDetailsView
extends
GetView
<
ProductDetailsController
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'ProductDetailsView'
),
centerTitle:
true
,
),
body:
Center
(
child:
Text
(
'ProductDetailsView is working'
,
style:
TextStyle
(
fontSize:
20
),
),
),
);
}
}
...
...
example_nav2/lib/app/modules/profile/bindings/profile_binding.dart
0 → 100644
View file @
c3b673f
import
'package:get/get.dart'
;
import
'../controllers/profile_controller.dart'
;
class
ProfileBinding
extends
Bindings
{
@override
void
dependencies
()
{
Get
.
lazyPut
<
ProfileController
>(
()
=>
ProfileController
(),
);
}
}
...
...
example_nav2/lib/app/modules/profile/controllers/profile_controller.dart
0 → 100644
View file @
c3b673f
import
'package:get/get.dart'
;
class
ProfileController
extends
GetxController
{
//TODO: Implement ProfileController
final
count
=
0
.
obs
;
@override
void
onInit
()
{
super
.
onInit
();
}
@override
void
onReady
()
{
super
.
onReady
();
}
@override
void
onClose
()
{}
void
increment
()
=>
count
.
value
++;
}
...
...
example_nav2/lib/app/modules/profile/views/profile_view.dart
0 → 100644
View file @
c3b673f
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'../controllers/profile_controller.dart'
;
class
ProfileView
extends
GetView
<
ProfileController
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'ProfileView'
),
centerTitle:
true
,
),
body:
Center
(
child:
Text
(
'ProfileView is working'
,
style:
TextStyle
(
fontSize:
20
),
),
),
);
}
}
...
...
example_nav2/lib/app/modules/settings/bindings/settings_binding.dart
0 → 100644
View file @
c3b673f
import
'package:get/get.dart'
;
import
'../controllers/settings_controller.dart'
;
class
SettingsBinding
extends
Bindings
{
@override
void
dependencies
()
{
Get
.
lazyPut
<
SettingsController
>(
()
=>
SettingsController
(),
);
}
}
...
...
example_nav2/lib/app/modules/settings/controllers/settings_controller.dart
0 → 100644
View file @
c3b673f
import
'package:get/get.dart'
;
class
SettingsController
extends
GetxController
{
//TODO: Implement SettingsController
final
count
=
0
.
obs
;
@override
void
onInit
()
{
super
.
onInit
();
}
@override
void
onReady
()
{
super
.
onReady
();
}
@override
void
onClose
()
{}
void
increment
()
=>
count
.
value
++;
}
...
...
example_nav2/lib/app/modules/settings/views/settings_view.dart
0 → 100644
View file @
c3b673f
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'../controllers/settings_controller.dart'
;
class
SettingsView
extends
GetView
<
SettingsController
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'SettingsView'
),
centerTitle:
true
,
),
body:
Center
(
child:
Text
(
'SettingsView is working'
,
style:
TextStyle
(
fontSize:
20
),
),
),
);
}
}
...
...
example_nav2/lib/app/routes/app_pages.dart
View file @
c3b673f
import
'package:get/get.dart'
;
import
'package:example_nav2/app/modules/home/bindings/home_binding.dart'
;
import
'package:example_nav2/app/modules/home/views/home_view.dart'
;
import
'package:example_nav2/app/modules/products/bindings/products_binding.dart'
;
import
'package:example_nav2/app/modules/products/views/products_view.dart'
;
import
'../modules/home/bindings/home_binding.dart'
;
import
'../modules/home/views/home_view.dart'
;
import
'../modules/product_details/bindings/product_details_binding.dart'
;
import
'../modules/product_details/views/product_details_view.dart'
;
import
'../modules/products/bindings/products_binding.dart'
;
import
'../modules/products/views/products_view.dart'
;
import
'../modules/profile/bindings/profile_binding.dart'
;
import
'../modules/profile/views/profile_view.dart'
;
import
'../modules/settings/bindings/settings_binding.dart'
;
import
'../modules/settings/views/settings_view.dart'
;
part
'app_routes.dart'
;
...
...
@@ -17,11 +23,30 @@ class AppPages {
name:
_Paths
.
HOME
,
page:
()
=>
HomeView
(),
binding:
HomeBinding
(),
children:
[
GetPage
(
name:
_Paths
.
PROFILE
,
page:
()
=>
ProfileView
(),
binding:
ProfileBinding
(),
),
],
),
GetPage
(
name:
_Paths
.
PRODUCTS
,
page:
()
=>
ProductsView
(),
binding:
ProductsBinding
(),
children:
[
GetPage
(
name:
_Paths
.
PRODUCT_DETAILS
,
page:
()
=>
ProductDetailsView
(),
binding:
ProductDetailsBinding
(),
),
],
),
GetPage
(
name:
_Paths
.
SETTINGS
,
page:
()
=>
SettingsView
(),
binding:
SettingsBinding
(),
),
];
}
...
...
example_nav2/lib/app/routes/app_routes.dart
View file @
c3b673f
...
...
@@ -5,10 +5,18 @@ abstract class Routes {
Routes
.
_
();
static
const
HOME
=
_Paths
.
HOME
;
static
const
PROFILE
=
_Paths
.
PROFILE
;
static
const
SETTINGS
=
_Paths
.
SETTINGS
;
static
const
PRODUCTS
=
_Paths
.
PRODUCTS
;
static
PRODUCT_DETAILS
(
String
productId
)
=>
'
${_Paths.PRODUCTS}
/
$productId
'
;
}
abstract
class
_Paths
{
static
const
HOME
=
'/home'
;
static
const
PRODUCTS
=
'/products'
;
static
const
PROFILE
=
'/profile'
;
static
const
SETTINGS
=
'/settings'
;
static
const
PRODUCT_DETAILS
=
'/:productId'
;
}
...
...
example_nav2/pubspec.yaml
View file @
c3b673f
...
...
@@ -8,6 +8,7 @@ environment:
dependencies
:
cupertino_icons
:
^1.0.2
effective_dart
:
1.3.1
# get: ^4.1.4
get
:
path
:
../
flutter
:
...
...
lib/get_core/src/get_interface.dart
View file @
c3b673f
import
'package:flutter/widgets.dart'
;
import
'package:get/get_navigation/src/nav2/get_router_delegate.dart'
;
import
'../../get_navigation/src/nav2/get_router_delegate.dart'
;
import
'../../get_navigation/src/routes/get_route.dart'
;
import
'log.dart'
;
import
'smart_management.dart'
;
...
...
lib/get_instance/src/extension_instance.dart
View file @
c3b673f
import
'package:flutter/widgets.dart'
;
import
'../../get_core/src/get_interface.dart'
;
import
'get_instance.dart'
;
...
...
@@ -121,4 +123,8 @@ extension Inst on GetInterface {
/// [Get.lazyPut()], is registered in memory.
/// - [tag] optional, if you use a [tag] to register the Instance.
bool
isPrepared
<
S
>({
String
?
tag
})
=>
GetInstance
().
isPrepared
<
S
>(
tag:
tag
);
/// Casts the stored router delegate to a desired type
TDelegate
?
delegate
<
TDelegate
extends
RouterDelegate
<
TPage
>,
TPage
>()
=>
routerDelegate
as
TDelegate
?;
}
...
...
lib/get_navigation/src/nav2/router_outlet.dart
0 → 100644
View file @
c3b673f
import
'dart:js'
;
import
'package:flutter/material.dart'
;
import
'../../../get.dart'
;
class
RouterOutlet
<
TDelegate
extends
RouterDelegate
<
T
>,
T
extends
Object
>
extends
StatefulWidget
{
final
TDelegate
routerDelegate
;
final
Widget
Function
(
BuildContext
context
,
TDelegate
delegate
,
T
?
currentRoute
,
)
builder
;
//keys
RouterOutlet
.
builder
({
TDelegate
?
delegate
,
required
this
.
builder
,
})
:
routerDelegate
=
delegate
??
Get
.
delegate
<
TDelegate
,
T
>()!,
super
();
RouterOutlet
({
TDelegate
?
delegate
,
required
List
<
T
>
Function
(
TDelegate
routerDelegate
)
currentNavStack
,
required
List
<
T
>
Function
(
List
<
T
>
currentNavStack
)
pickPages
,
required
Widget
Function
(
T
?
page
)
pageBuilder
,
})
:
this
.
builder
(
builder:
(
context
,
rDelegate
,
currentConfig
)
{
final
currentStack
=
currentNavStack
(
rDelegate
);
final
picked
=
pickPages
(
currentStack
);
if
(
picked
.
length
==
0
)
return
pageBuilder
(
null
);
return
pageBuilder
(
picked
.
last
);
},
delegate:
delegate
,
);
@override
_RouterOutletState
<
TDelegate
,
T
>
createState
()
=>
_RouterOutletState
<
TDelegate
,
T
>();
}
class
_RouterOutletState
<
TDelegate
extends
RouterDelegate
<
T
>,
T
extends
Object
>
extends
State
<
RouterOutlet
<
TDelegate
,
T
>>
{
TDelegate
get
delegate
=>
widget
.
routerDelegate
;
@override
void
initState
()
{
super
.
initState
();
delegate
.
addListener
(
onRouterDelegateChanged
);
}
@override
void
dispose
()
{
delegate
.
removeListener
(
onRouterDelegateChanged
);
super
.
dispose
();
}
T
?
currentRoute
;
void
onRouterDelegateChanged
()
{
setState
(()
{
currentRoute
=
delegate
.
currentConfiguration
;
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
widget
.
builder
(
context
,
delegate
,
currentRoute
);
}
}
...
...
Please
register
or
login
to post a comment