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-12-25 06:28:35 +0200
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
e7c5bd9555572af53408bdc526a21cad4f16cc25
e7c5bd95
2 parents
97d3e744
fa1888be
Merge branch 'master' of
git://github.com/jonataslaw/getx
Show whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
413 additions
and
133 deletions
.DS_Store
.github/workflows/main.yml
CHANGELOG.md
README.ko-kr.md
example/lib/main.dart
example/lib/pages/home/presentation/views/home_view.dart
example/lib/shared/logger/logger_utils.dart
lib/get_connect/connect.dart
lib/get_connect/http/src/http.dart
lib/get_connect/http/src/http/html/http_request_html.dart
lib/get_connect/http/src/http/io/http_request_io.dart
lib/get_connect/http/src/http/stub/http_request_stub.dart
lib/get_instance/src/extension_instance.dart
lib/get_instance/src/get_instance.dart
lib/get_navigation/src/extension_navigation.dart
lib/get_navigation/src/nav2/router_outlet.dart
lib/get_navigation/src/root/get_cupertino_app.dart
lib/get_navigation/src/root/get_material_app.dart
lib/get_navigation/src/root/parse_route.dart
lib/get_navigation/src/root/root_controller.dart
lib/get_navigation/src/routes/circular_reveal_clipper.dart
lib/get_navigation/src/routes/default_route.dart
lib/get_navigation/src/routes/default_transitions.dart
lib/get_navigation/src/routes/get_route.dart
lib/get_navigation/src/routes/get_transition_mixin.dart
lib/get_navigation/src/routes/observers/route_observer.dart
lib/get_navigation/src/routes/transitions_type.dart
lib/get_rx/src/rx_types/rx_core/rx_impl.dart
lib/get_state_manager/src/rx_flutter/rx_ticket_provider_mixin.dart
lib/get_state_manager/src/simple/get_responsive.dart
lib/get_state_manager/src/simple/list_notifier.dart
lib/get_state_manager/src/simple/mixin_state.dart
lib/get_utils/src/extensions/context_extensions.dart
lib/get_utils/src/extensions/internacionalization.dart
pubspec.yaml
test/instance/get_instance_test.dart
test/navigation/get_main_test.dart
test/navigation/routes_test.dart
test/rx/rx_workers_test.dart
.DS_Store
View file @
e7c5bd9
No preview for this file type
.github/workflows/main.yml
View file @
e7c5bd9
...
...
@@ -23,7 +23,7 @@ jobs:
# https://github.com/marketplace/actions/flutter-action
-
uses
:
subosito/flutter-action@v1
with
:
flutter-version
:
"
2.
2.3
"
flutter-version
:
"
2.
8.0
"
channel
:
"
stable"
-
run
:
flutter pub get
#- run: flutter analyze
...
...
CHANGELOG.md
View file @
e7c5bd9
## [4.5.1] - Big Update
## [4.6.1]
Fix GetConnect on Flutter web
## [4.6.0]
Add useInheritedMediaQuery to GetMaterialApp and GetCupertinoApp (@davidhole)
Add Circular reveal Transition (@parmarravi)
Add request to failed response (@heftekharm)
Fix internationalization with only country code (@codercengiz)
Add GetTickerProviderStateMixin when multiple AnimationController objects are used (@NatsuOnFire)
Add the followRedirects and maxRedirects fields to the Request object (@wei53881)
Fix to rx.trigger fires twice (@gslender)
Add proxy setting support to GetConnect (@jtans)
Fix markAsDirty used on permanent controllers (@zenalex)
Update Korean readme (@dumbokim)
## [4.5.1]
Fix Snackbar when it have action and icon the same time
## [4.5.0] - Big Update
To have a
context-free,
page-agnostic snackbar, we used OverlayRoute to display a partial route.
To have a page-agnostic snackbar, we used OverlayRoute to display a partial route.
However this had several problems:
1: There was no possibility to close the page without closing the snackbar
...
...
README.ko-kr.md
View file @
e7c5bd9
...
...
@@ -328,7 +328,7 @@ Text(controller.textFromApi);
### 종속성 관리에 대한 자세한 내용
**종속성 관리에 대한 더
제사
한 사항은 [여기](./documentation/kr_KO/dependency_management.md)에 있습니다.**
**종속성 관리에 대한 더
자세
한 사항은 [여기](./documentation/kr_KO/dependency_management.md)에 있습니다.**
# 기능들
...
...
@@ -1092,6 +1092,73 @@ class SettingsService extends GetxService {
따라서 앱 실행중 절대로 유지되어야 하는 클래스 인스턴스가 필요하면
`GetxService`
를 사용하세요.
### 테스트
당신은 당신의 컨트롤러들을 생성주기를 포함하여 다른 어떤 클래스처럼 테스트할 수 있습니다 :
```
dart
class
Controller
extends
GetxController
{
@override
void
onInit
()
{
super
.
onInit
();
//name2로 값 변경
name
.
value
=
'name2'
;
}
@override
void
onClose
()
{
name
.
value
=
''
;
super
.
onClose
();
}
final
name
=
'name1'
.
obs
;
void
changeName
()
=>
name
.
value
=
'name3'
;
}
void
main
(
)
{
test
(
'''
Test the state of the reactive variable "name" across all of its lifecycles'''
,
()
{
/// 당신은 생성주기를 제외하고 컨트롤러를 테스트할 수 있습니다,
/// 그러나 당신이 사용하지 않는다면 추천되지 않습니다
/// GetX 종속성 주입
final
controller
=
Controller
();
expect
(
controller
.
name
.
value
,
'name1'
);
/// 당신이 그것을 사용한다면, 당신은 모든 것을 테스트할 수 있습니다,
/// 각각의 생성주기 이후 어플리케이션의 상태를 포함하여.
Get
.
put
(
controller
);
// onInit was called
expect
(
controller
.
name
.
value
,
'name2'
);
/// 당신의 함수를 테스트하세요
controller
.
changeName
();
expect
(
controller
.
name
.
value
,
'name3'
);
/// onClose 호출됨
Get
.
delete
<
Controller
>();
expect
(
controller
.
name
.
value
,
''
);
});
}
```
#### 팁들
##### Mockito 또는 mocktail
당신이 당신의 GetxController/GetxService를 모킹하려고 한다면, 당신은 GetxController를 extend 하고, Mock과 mixin 하라, 그렇게 되면
```
dart
class
NotificationServiceMock
extends
GetxService
with
Mock
implements
NotificationService
{}
```
##### Get.reset() 사용하기
당신이 위젯 또는 테스트 그룹을 테스트하고 있다면, 당신의 테스트의 마지막 또는 해제 때 당신의 이전 테스트에서 모든 설정을 리셋하기 위해 Get.rest을 사용하십시오
##### Get.testMode
당신이 당신의 컨트롤러에서 당신의 네비게이션을 사용하고 있다면, 당신의 메인의 시작에
`Get.testMode = true`
를 사용하십시오.
# 2.0의 주요 변경점
1- Rx 타입들:
...
...
example/lib/main.dart
View file @
e7c5bd9
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
...
...
example/lib/pages/home/presentation/views/home_view.dart
View file @
e7c5bd9
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
...
...
example/lib/shared/logger/logger_utils.dart
View file @
e7c5bd9
class
Logger
{
mixin
Logger
{
// Sample of abstract logging function
static
void
write
(
String
text
,
{
bool
isError
=
false
})
{
Future
.
microtask
(()
=>
print
(
'**
$text
. isError: [
$isError
]'
));
...
...
lib/get_connect/connect.dart
View file @
e7c5bd9
...
...
@@ -115,6 +115,7 @@ class GetConnect extends GetConnectInterface {
Decoder
?
defaultDecoder
;
Duration
timeout
;
List
<
TrustedCertificate
>?
trustedCertificates
;
String
Function
(
Uri
url
)?
findProxy
;
GetHttpClient
?
_httpClient
;
List
<
GetSocket
>?
_sockets
;
bool
withCredentials
;
...
...
@@ -134,7 +135,7 @@ class GetConnect extends GetConnectInterface {
baseUrl:
baseUrl
,
trustedCertificates:
trustedCertificates
,
withCredentials:
withCredentials
,
);
findProxy:
findProxy
);
@override
Future
<
Response
<
T
>>
get
<
T
>(
...
...
lib/get_connect/http/src/http.dart
View file @
e7c5bd9
...
...
@@ -39,6 +39,8 @@ class GetHttpClient {
final
GetModifier
_modifier
;
String
Function
(
Uri
url
)?
findProxy
;
GetHttpClient
({
this
.
userAgent
=
'getx-client'
,
this
.
timeout
=
const
Duration
(
seconds:
8
),
...
...
@@ -50,10 +52,12 @@ class GetHttpClient {
this
.
baseUrl
,
List
<
TrustedCertificate
>?
trustedCertificates
,
bool
withCredentials
=
false
,
String
Function
(
Uri
url
)?
findProxy
,
})
:
_httpClient
=
HttpRequestImpl
(
allowAutoSignedCert:
allowAutoSignedCert
,
trustedCertificates:
trustedCertificates
,
withCredentials:
withCredentials
,
findProxy:
findProxy
,
),
_modifier
=
GetModifier
();
...
...
@@ -195,7 +199,6 @@ class GetHttpClient {
int
requestNumber
=
1
,
Map
<
String
,
String
>?
headers
,
})
async
{
try
{
var
request
=
await
handler
();
headers
?.
forEach
((
key
,
value
)
{
...
...
@@ -206,6 +209,7 @@ class GetHttpClient {
final
newRequest
=
await
_modifier
.
modifyRequest
<
T
>(
request
);
_httpClient
.
timeout
=
timeout
;
try
{
var
response
=
await
_httpClient
.
send
<
T
>(
newRequest
);
final
newResponse
=
...
...
@@ -242,7 +246,7 @@ class GetHttpClient {
throw
GetHttpException
(
err
.
toString
());
}
else
{
return
Response
<
T
>(
request:
n
ull
,
request:
n
ewRequest
,
headers:
null
,
statusCode:
null
,
body:
null
,
...
...
@@ -268,6 +272,8 @@ class GetHttpClient {
headers:
headers
,
decoder:
decoder
??
(
defaultDecoder
as
Decoder
<
T
>?),
contentLength:
0
,
followRedirects:
followRedirects
,
maxRedirects:
maxRedirects
,
));
}
...
...
lib/get_connect/http/src/http/html/http_request_html.dart
View file @
e7c5bd9
...
...
@@ -14,6 +14,7 @@ class HttpRequestImpl implements HttpRequestBase {
bool
allowAutoSignedCert
=
true
,
List
<
TrustedCertificate
>?
trustedCertificates
,
this
.
withCredentials
=
false
,
String
Function
(
Uri
url
)?
findProxy
,
});
/// The currently active XHRs.
...
...
lib/get_connect/http/src/http/io/http_request_io.dart
View file @
e7c5bd9
...
...
@@ -17,6 +17,7 @@ class HttpRequestImpl extends HttpRequestBase {
bool
allowAutoSignedCert
=
true
,
List
<
TrustedCertificate
>?
trustedCertificates
,
bool
withCredentials
=
false
,
String
Function
(
Uri
url
)?
findProxy
,
})
{
_httpClient
=
io
.
HttpClient
();
if
(
trustedCertificates
!=
null
)
{
...
...
@@ -29,6 +30,7 @@ class HttpRequestImpl extends HttpRequestBase {
_httpClient
=
io
.
HttpClient
(
context:
_securityContext
);
_httpClient
!.
badCertificateCallback
=
(
_
,
__
,
___
)
=>
allowAutoSignedCert
;
_httpClient
!.
findProxy
=
findProxy
;
}
@override
...
...
lib/get_connect/http/src/http/stub/http_request_stub.dart
View file @
e7c5bd9
...
...
@@ -8,6 +8,7 @@ class HttpRequestImpl extends HttpRequestBase {
bool
allowAutoSignedCert
=
true
,
List
<
TrustedCertificate
>?
trustedCertificates
,
bool
withCredentials
=
false
,
String
Function
(
Uri
url
)?
findProxy
,
});
@override
void
close
()
{}
...
...
lib/get_instance/src/extension_instance.dart
View file @
e7c5bd9
import
'../../get_core/src/get_interface.dart'
;
import
'../../route_manager.dart'
;
import
'get_instance.dart'
;
...
...
lib/get_instance/src/get_instance.dart
View file @
e7c5bd9
...
...
@@ -232,7 +232,7 @@ class GetInstance {
final
newKey
=
key
??
_getKey
(
S
,
tag
);
if
(
_singl
.
containsKey
(
newKey
))
{
final
dep
=
_singl
[
newKey
];
if
(
dep
!=
null
)
{
if
(
dep
!=
null
&&
!
dep
.
permanent
)
{
dep
.
isDirty
=
true
;
}
}
...
...
lib/get_navigation/src/extension_navigation.dart
View file @
e7c5bd9
...
...
@@ -9,9 +9,6 @@ import '../../get_utils/get_utils.dart';
import
'../get_navigation.dart'
;
import
'dialog/dialog_route.dart'
;
import
'root/parse_route.dart'
;
import
'root/root_controller.dart'
;
import
'routes/transitions_type.dart'
;
import
'snackbar/snackbar_controller.dart'
;
/// It replaces the Flutter Navigator, but needs no context.
/// You can to use navigator.push(YourRoute()) rather
...
...
lib/get_navigation/src/nav2/router_outlet.dart
View file @
e7c5bd9
import
'package:flutter/material.dart'
;
import
'../../../get.dart'
;
import
'get_navigator.dart'
;
import
'get_router_delegate.dart'
;
class
RouterOutlet
<
TDelegate
extends
RouterDelegate
<
T
>,
T
extends
Object
>
extends
StatefulWidget
{
...
...
lib/get_navigation/src/root/get_cupertino_app.dart
View file @
e7c5bd9
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'../../../get_core/get_core.dart'
;
import
'../../../get_instance/get_instance.dart'
;
import
'../../../get_state_manager/get_state_manager.dart'
;
import
'../../../get_utils/get_utils.dart'
;
import
'../../get_navigation.dart'
;
import
'root_controller.dart'
;
class
GetCupertinoApp
extends
StatelessWidget
{
final
GlobalKey
<
NavigatorState
>?
navigatorKey
;
final
Widget
?
home
;
final
Map
<
String
,
WidgetBuilder
>?
routes
;
final
String
?
initialRoute
;
final
RouteFactory
?
onGenerateRoute
;
final
InitialRouteListFactory
?
onGenerateInitialRoutes
;
final
RouteFactory
?
onUnknownRoute
;
final
List
<
NavigatorObserver
>?
navigatorObservers
;
final
TransitionBuilder
?
builder
;
final
String
title
;
final
GenerateAppTitle
?
onGenerateTitle
;
final
CustomTransition
?
customTransition
;
final
Color
?
color
;
final
Map
<
String
,
Map
<
String
,
String
>>?
translationsKeys
;
final
Translations
?
translations
;
final
TextDirection
?
textDirection
;
final
Locale
?
locale
;
final
Locale
?
fallbackLocale
;
final
Iterable
<
LocalizationsDelegate
<
dynamic
>>?
localizationsDelegates
;
final
LocaleListResolutionCallback
?
localeListResolutionCallback
;
final
LocaleResolutionCallback
?
localeResolutionCallback
;
final
Iterable
<
Locale
>
supportedLocales
;
final
bool
showPerformanceOverlay
;
final
bool
checkerboardRasterCacheImages
;
final
bool
checkerboardOffscreenLayers
;
final
bool
showSemanticsDebugger
;
final
bool
debugShowCheckedModeBanner
;
final
Map
<
LogicalKeySet
,
Intent
>?
shortcuts
;
final
ThemeData
?
highContrastTheme
;
final
ThemeData
?
highContrastDarkTheme
;
final
Map
<
Type
,
Action
<
Intent
>>?
actions
;
final
Function
(
Routing
?)?
routingCallback
;
final
Transition
?
defaultTransition
;
final
bool
?
opaqueRoute
;
final
VoidCallback
?
onInit
;
final
VoidCallback
?
onReady
;
final
VoidCallback
?
onDispose
;
final
bool
?
enableLog
;
final
LogWriterCallback
?
logWriterCallback
;
final
bool
?
popGesture
;
final
SmartManagement
smartManagement
;
final
Bindings
?
initialBinding
;
final
Duration
?
transitionDuration
;
final
bool
?
defaultGlobalState
;
final
List
<
GetPage
>?
getPages
;
final
GetPage
?
unknownRoute
;
final
RouteInformationProvider
?
routeInformationProvider
;
final
RouteInformationParser
<
Object
>?
routeInformationParser
;
final
RouterDelegate
<
Object
>?
routerDelegate
;
final
BackButtonDispatcher
?
backButtonDispatcher
;
final
CupertinoThemeData
?
theme
;
final
bool
useInheritedMediaQuery
;
const
GetCupertinoApp
({
Key
?
key
,
this
.
theme
,
...
...
@@ -46,6 +99,7 @@ class GetCupertinoApp extends StatelessWidget {
this
.
shortcuts
,
this
.
smartManagement
=
SmartManagement
.
full
,
this
.
initialBinding
,
this
.
useInheritedMediaQuery
=
false
,
this
.
unknownRoute
,
this
.
routingCallback
,
this
.
defaultTransition
,
...
...
@@ -66,58 +120,6 @@ class GetCupertinoApp extends StatelessWidget {
backButtonDispatcher
=
null
,
super
(
key:
key
);
final
GlobalKey
<
NavigatorState
>?
navigatorKey
;
final
Widget
?
home
;
final
Map
<
String
,
WidgetBuilder
>?
routes
;
final
String
?
initialRoute
;
final
RouteFactory
?
onGenerateRoute
;
final
InitialRouteListFactory
?
onGenerateInitialRoutes
;
final
RouteFactory
?
onUnknownRoute
;
final
List
<
NavigatorObserver
>?
navigatorObservers
;
final
TransitionBuilder
?
builder
;
final
String
title
;
final
GenerateAppTitle
?
onGenerateTitle
;
final
CustomTransition
?
customTransition
;
final
Color
?
color
;
final
Map
<
String
,
Map
<
String
,
String
>>?
translationsKeys
;
final
Translations
?
translations
;
final
TextDirection
?
textDirection
;
final
Locale
?
locale
;
final
Locale
?
fallbackLocale
;
final
Iterable
<
LocalizationsDelegate
<
dynamic
>>?
localizationsDelegates
;
final
LocaleListResolutionCallback
?
localeListResolutionCallback
;
final
LocaleResolutionCallback
?
localeResolutionCallback
;
final
Iterable
<
Locale
>
supportedLocales
;
final
bool
showPerformanceOverlay
;
final
bool
checkerboardRasterCacheImages
;
final
bool
checkerboardOffscreenLayers
;
final
bool
showSemanticsDebugger
;
final
bool
debugShowCheckedModeBanner
;
final
Map
<
LogicalKeySet
,
Intent
>?
shortcuts
;
final
ThemeData
?
highContrastTheme
;
final
ThemeData
?
highContrastDarkTheme
;
final
Map
<
Type
,
Action
<
Intent
>>?
actions
;
final
Function
(
Routing
?)?
routingCallback
;
final
Transition
?
defaultTransition
;
final
bool
?
opaqueRoute
;
final
VoidCallback
?
onInit
;
final
VoidCallback
?
onReady
;
final
VoidCallback
?
onDispose
;
final
bool
?
enableLog
;
final
LogWriterCallback
?
logWriterCallback
;
final
bool
?
popGesture
;
final
SmartManagement
smartManagement
;
final
Bindings
?
initialBinding
;
final
Duration
?
transitionDuration
;
final
bool
?
defaultGlobalState
;
final
List
<
GetPage
>?
getPages
;
final
GetPage
?
unknownRoute
;
final
RouteInformationProvider
?
routeInformationProvider
;
final
RouteInformationParser
<
Object
>?
routeInformationParser
;
final
RouterDelegate
<
Object
>?
routerDelegate
;
final
BackButtonDispatcher
?
backButtonDispatcher
;
final
CupertinoThemeData
?
theme
;
GetCupertinoApp
.
router
({
Key
?
key
,
this
.
theme
,
...
...
@@ -128,6 +130,7 @@ class GetCupertinoApp extends StatelessWidget {
this
.
builder
,
this
.
title
=
''
,
this
.
onGenerateTitle
,
this
.
useInheritedMediaQuery
=
false
,
this
.
color
,
this
.
highContrastTheme
,
this
.
highContrastDarkTheme
,
...
...
@@ -183,31 +186,6 @@ class GetCupertinoApp extends StatelessWidget {
Get
.
routeInformationParser
=
routeInformationParser
;
}
Route
<
dynamic
>
generator
(
RouteSettings
settings
)
{
return
PageRedirect
(
settings:
settings
,
unknownRoute:
unknownRoute
).
page
();
}
List
<
Route
<
dynamic
>>
initialRoutesGenerate
(
String
name
)
{
return
[
PageRedirect
(
settings:
RouteSettings
(
name:
name
),
unknownRoute:
unknownRoute
,
).
page
()
];
}
Widget
defaultBuilder
(
BuildContext
context
,
Widget
?
child
)
{
return
Directionality
(
textDirection:
textDirection
??
(
rtlLanguages
.
contains
(
Get
.
locale
?.
languageCode
)
?
TextDirection
.
rtl
:
TextDirection
.
ltr
),
child:
builder
==
null
?
(
child
??
Material
())
:
builder
!(
context
,
child
??
Material
()),
);
}
@override
Widget
build
(
BuildContext
context
)
=>
GetBuilder
<
GetMaterialController
>(
init:
Get
.
rootController
,
...
...
@@ -271,6 +249,7 @@ class GetCupertinoApp extends StatelessWidget {
showSemanticsDebugger:
showSemanticsDebugger
,
debugShowCheckedModeBanner:
debugShowCheckedModeBanner
,
shortcuts:
shortcuts
,
useInheritedMediaQuery:
useInheritedMediaQuery
,
)
:
CupertinoApp
(
key:
_
.
unikey
,
...
...
@@ -310,7 +289,33 @@ class GetCupertinoApp extends StatelessWidget {
showSemanticsDebugger:
showSemanticsDebugger
,
debugShowCheckedModeBanner:
debugShowCheckedModeBanner
,
shortcuts:
shortcuts
,
useInheritedMediaQuery:
useInheritedMediaQuery
,
// actions: actions,
),
);
Widget
defaultBuilder
(
BuildContext
context
,
Widget
?
child
)
{
return
Directionality
(
textDirection:
textDirection
??
(
rtlLanguages
.
contains
(
Get
.
locale
?.
languageCode
)
?
TextDirection
.
rtl
:
TextDirection
.
ltr
),
child:
builder
==
null
?
(
child
??
Material
())
:
builder
!(
context
,
child
??
Material
()),
);
}
Route
<
dynamic
>
generator
(
RouteSettings
settings
)
{
return
PageRedirect
(
settings:
settings
,
unknownRoute:
unknownRoute
).
page
();
}
List
<
Route
<
dynamic
>>
initialRoutesGenerate
(
String
name
)
{
return
[
PageRedirect
(
settings:
RouteSettings
(
name:
name
),
unknownRoute:
unknownRoute
,
).
page
()
];
}
}
...
...
lib/get_navigation/src/root/get_material_app.dart
View file @
e7c5bd9
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -7,7 +6,6 @@ import '../../../get_instance/get_instance.dart';
import
'../../../get_state_manager/get_state_manager.dart'
;
import
'../../../get_utils/get_utils.dart'
;
import
'../../get_navigation.dart'
;
import
'root_controller.dart'
;
class
GetMaterialApp
extends
StatelessWidget
{
final
GlobalKey
<
NavigatorState
>?
navigatorKey
;
...
...
@@ -67,6 +65,7 @@ class GetMaterialApp extends StatelessWidget {
final
RouteInformationParser
<
Object
>?
routeInformationParser
;
final
RouterDelegate
<
Object
>?
routerDelegate
;
final
BackButtonDispatcher
?
backButtonDispatcher
;
final
bool
useInheritedMediaQuery
;
const
GetMaterialApp
({
Key
?
key
,
this
.
navigatorKey
,
...
...
@@ -78,6 +77,7 @@ class GetMaterialApp extends StatelessWidget {
this
.
onGenerateRoute
,
this
.
onGenerateInitialRoutes
,
this
.
onUnknownRoute
,
this
.
useInheritedMediaQuery
=
false
,
List
<
NavigatorObserver
>
this
.
navigatorObservers
=
const
<
NavigatorObserver
>[],
this
.
builder
,
...
...
@@ -142,6 +142,7 @@ class GetMaterialApp extends StatelessWidget {
this
.
color
,
this
.
theme
,
this
.
darkTheme
,
this
.
useInheritedMediaQuery
=
false
,
this
.
highContrastTheme
,
this
.
highContrastDarkTheme
,
this
.
themeMode
=
ThemeMode
.
system
,
...
...
@@ -271,6 +272,7 @@ class GetMaterialApp extends StatelessWidget {
debugShowCheckedModeBanner:
debugShowCheckedModeBanner
,
shortcuts:
shortcuts
,
scrollBehavior:
scrollBehavior
,
useInheritedMediaQuery:
useInheritedMediaQuery
,
)
:
MaterialApp
(
key:
_
.
unikey
,
...
...
@@ -317,6 +319,7 @@ class GetMaterialApp extends StatelessWidget {
debugShowCheckedModeBanner:
debugShowCheckedModeBanner
,
shortcuts:
shortcuts
,
scrollBehavior:
scrollBehavior
,
useInheritedMediaQuery:
useInheritedMediaQuery
,
// actions: actions,
),
);
...
...
lib/get_navigation/src/root/parse_route.dart
View file @
e7c5bd9
import
'../../get_navigation.dart'
;
import
'../routes/get_route.dart'
;
class
RouteDecoder
{
final
List
<
GetPage
>
treeBranch
;
...
...
lib/get_navigation/src/root/root_controller.dart
View file @
e7c5bd9
import
'package:flutter/material.dart'
;
import
'../../../get.dart'
;
import
'../../../get_state_manager/get_state_manager.dart'
;
import
'../../../get_utils/get_utils.dart'
;
import
'../routes/custom_transition.dart'
;
import
'../routes/observers/route_observer.dart'
;
import
'../routes/transitions_type.dart'
;
class
GetMaterialController
extends
SuperController
{
bool
testMode
=
false
;
...
...
lib/get_navigation/src/routes/circular_reveal_clipper.dart
0 → 100644
View file @
e7c5bd9
import
'dart:math'
show
sqrt
,
max
;
import
'dart:ui'
show
lerpDouble
;
import
'package:flutter/material.dart'
;
class
CircularRevealClipper
extends
CustomClipper
<
Path
>
{
final
double
fraction
;
final
Alignment
?
centerAlignment
;
final
Offset
?
centerOffset
;
final
double
?
minRadius
;
final
double
?
maxRadius
;
CircularRevealClipper
({
required
this
.
fraction
,
this
.
centerAlignment
,
this
.
centerOffset
,
this
.
minRadius
,
this
.
maxRadius
,
});
@override
Path
getClip
(
Size
size
)
{
final
center
=
centerAlignment
?.
alongSize
(
size
)
??
centerOffset
??
Offset
(
size
.
width
/
2
,
size
.
height
/
2
);
final
minRadius
=
this
.
minRadius
??
0
;
final
maxRadius
=
this
.
maxRadius
??
calcMaxRadius
(
size
,
center
);
return
Path
()
..
addOval
(
Rect
.
fromCircle
(
center:
center
,
radius:
lerpDouble
(
minRadius
,
maxRadius
,
fraction
)!,
),
);
}
@override
bool
shouldReclip
(
CustomClipper
<
Path
>
oldClipper
)
=>
true
;
static
double
calcMaxRadius
(
Size
size
,
Offset
center
)
{
final
w
=
max
(
center
.
dx
,
size
.
width
-
center
.
dx
);
final
h
=
max
(
center
.
dy
,
size
.
height
-
center
.
dy
);
return
sqrt
(
w
*
w
+
h
*
h
);
}
}
...
...
lib/get_navigation/src/routes/default_route.dart
View file @
e7c5bd9
...
...
@@ -2,10 +2,7 @@ import 'package:flutter/material.dart';
import
'../../../get.dart'
;
import
'../router_report.dart'
;
import
'custom_transition.dart'
;
import
'get_transition_mixin.dart'
;
import
'route_middleware.dart'
;
import
'transitions_type.dart'
;
mixin
PageRouteReportMixin
<
T
>
on
Route
<
T
>
{
@override
...
...
lib/get_navigation/src/routes/default_transitions.dart
View file @
e7c5bd9
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'circular_reveal_clipper.dart'
;
class
LeftToRightFadeTransition
{
Widget
buildTransitions
(
BuildContext
context
,
...
...
@@ -184,3 +186,24 @@ class SizeTransitions {
);
}
}
class
CircularRevealTransition
{
Widget
buildTransitions
(
BuildContext
context
,
Curve
?
curve
,
Alignment
?
alignment
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
,
Widget
child
)
{
return
ClipPath
(
clipper:
CircularRevealClipper
(
fraction:
animation
.
value
,
centerAlignment:
Alignment
.
center
,
centerOffset:
Offset
.
zero
,
minRadius:
0
,
maxRadius:
800
,
),
child:
child
,
);
}
}
...
...
lib/get_navigation/src/routes/get_route.dart
View file @
e7c5bd9
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'../../../get_core/src/get_main.dart'
;
import
'../../../get_instance/get_instance.dart'
;
import
'../../get_navigation.dart'
;
import
'custom_transition.dart'
;
import
'transitions_type.dart'
;
class
GetPage
<
T
>
extends
Page
<
T
>
{
final
GetPageBuilder
page
;
...
...
lib/get_navigation/src/routes/get_transition_mixin.dart
View file @
e7c5bd9
...
...
@@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
import
'../../../get.dart'
;
import
'default_transitions.dart'
;
import
'transitions_type.dart'
;
const
double
_kBackGestureWidth
=
20.0
;
const
int
_kMaxDroppedSwipePageForwardAnimationTime
=
...
...
@@ -620,6 +619,22 @@ Cannot read the previousTitle for a route that has not yet been installed''',
child:
child
)
:
child
);
case
Transition
.
circularReveal
:
return
CircularRevealTransition
().
buildTransitions
(
context
,
route
.
curve
,
route
.
alignment
,
animation
,
secondaryAnimation
,
route
.
popGesture
??
Get
.
defaultPopGesture
?
CupertinoBackGestureDetector
<
T
>(
gestureWidth:
route
.
gestureWidth
?.
call
(
context
)
??
_kBackGestureWidth
,
enabledCallback:
()
=>
_isPopGestureEnabled
<
T
>(
route
),
onStartPopGesture:
()
=>
_startPopGesture
<
T
>(
route
),
child:
child
)
:
child
);
default
:
if
(
Get
.
customTransition
!=
null
)
{
return
Get
.
customTransition
!.
buildTransition
(
context
,
route
.
curve
,
...
...
lib/get_navigation/src/routes/observers/route_observer.dart
View file @
e7c5bd9
...
...
@@ -5,7 +5,6 @@ import '../../../../instance_manager.dart';
import
'../../../get_navigation.dart'
;
import
'../../dialog/dialog_route.dart'
;
import
'../../router_report.dart'
;
import
'../default_route.dart'
;
/// Extracts the name of a route based on it's instance type
/// or null if not possible.
...
...
lib/get_navigation/src/routes/transitions_type.dart
View file @
e7c5bd9
...
...
@@ -17,7 +17,8 @@ enum Transition {
cupertino
,
cupertinoDialog
,
size
,
native
circularReveal
,
native
,
}
typedef
GetPageBuilder
=
Widget
Function
();
...
...
lib/get_rx/src/rx_types/rx_core/rx_impl.dart
View file @
e7c5bd9
...
...
@@ -67,6 +67,7 @@ mixin RxObjectMixin<T> on NotifyManager<T> {
}
bool
firstRebuild
=
true
;
bool
sentToStream
=
false
;
/// Same as `toString()` but using a getter.
String
get
string
=>
value
.
toString
();
...
...
@@ -96,10 +97,11 @@ mixin RxObjectMixin<T> on NotifyManager<T> {
/// Widget, only if it's different from the previous value.
set
value
(
T
val
)
{
if
(
subject
.
isClosed
)
return
;
sentToStream
=
false
;
if
(
_value
==
val
&&
!
firstRebuild
)
return
;
firstRebuild
=
false
;
_value
=
val
;
sentToStream
=
true
;
subject
.
add
(
_value
);
}
...
...
@@ -254,7 +256,7 @@ abstract class _RxImpl<T> extends RxNotifier<T> with RxObjectMixin<T> {
value
=
v
;
// If it's not the first rebuild, the listeners have been called already
// So we won't call them again.
if
(!
firstRebuild
)
{
if
(!
firstRebuild
&&
!
sentToStream
)
{
subject
.
add
(
v
);
}
}
...
...
lib/get_state_manager/src/rx_flutter/rx_ticket_provider_mixin.dart
View file @
e7c5bd9
...
...
@@ -36,13 +36,13 @@ mixin GetSingleTickerProviderStateMixin on GetxController
if
(
_ticker
==
null
)
return
true
;
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'
$runtimeType
is a SingleTickerProviderStateMixin but multiple tickers were created.'
),
'
$runtimeType
is a
Get
SingleTickerProviderStateMixin but multiple tickers were created.'
),
ErrorDescription
(
'A SingleTickerProviderStateMixin can only be used as a TickerProvider once.'
),
'A
Get
SingleTickerProviderStateMixin can only be used as a TickerProvider once.'
),
ErrorHint
(
'If a State is used for multiple AnimationController objects, or if it is passed to other '
'objects and those objects might use it more than one time in total, then instead of '
'mixing in a
SingleTickerProviderStateMixin, use a regular
TickerProviderStateMixin.'
,
'mixing in a
GetSingleTickerProviderStateMixin, use a regular Get
TickerProviderStateMixin.'
,
),
]);
}());
...
...
@@ -66,7 +66,7 @@ mixin GetSingleTickerProviderStateMixin on GetxController
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'
$this
was disposed with an active Ticker.'
),
ErrorDescription
(
'
$runtimeType
created a Ticker via its SingleTickerProviderStateMixin, but at the time '
'
$runtimeType
created a Ticker via its
Get
SingleTickerProviderStateMixin, but at the time '
'dispose() was called on the mixin, that Ticker was still active. The Ticker must '
'be disposed before calling super.dispose().'
,
),
...
...
@@ -82,6 +82,100 @@ mixin GetSingleTickerProviderStateMixin on GetxController
}
}
/// Used like `TickerProviderMixin` but only with Get Controllers.
/// Simplifies multiple AnimationController creation inside GetxController.
///
/// Example:
///```
///class SplashController extends GetxController with
/// GetTickerProviderStateMixin {
/// AnimationController first_controller;
/// AnimationController second_controller;
///
/// @override
/// void onInit() {
/// final duration = const Duration(seconds: 2);
/// first_controller =
/// AnimationController.unbounded(duration: duration, vsync: this);
/// second_controller =
/// AnimationController.unbounded(duration: duration, vsync: this);
/// first_controller.repeat();
/// first_controller.addListener(() =>
/// print("Animation Controller value: ${first_controller.value}"));
/// second_controller.addListener(() =>
/// print("Animation Controller value: ${second_controller.value}"));
/// }
/// ...
/// ```
mixin
GetTickerProviderStateMixin
on
GetxController
implements
TickerProvider
{
Set
<
Ticker
>?
_tickers
;
@override
Ticker
createTicker
(
TickerCallback
onTick
)
{
_tickers
??=
<
_WidgetTicker
>{};
final
result
=
_WidgetTicker
(
onTick
,
this
,
debugLabel:
kDebugMode
?
'created by
${describeIdentity(this)}
'
:
null
);
_tickers
!.
add
(
result
);
return
result
;
}
void
_removeTicker
(
_WidgetTicker
ticker
)
{
assert
(
_tickers
!=
null
);
assert
(
_tickers
!.
contains
(
ticker
));
_tickers
!.
remove
(
ticker
);
}
void
didChangeDependencies
(
BuildContext
context
)
{
final
muted
=
!
TickerMode
.
of
(
context
);
if
(
_tickers
!=
null
)
{
for
(
final
ticker
in
_tickers
!)
{
ticker
.
muted
=
muted
;
}
}
}
@override
void
onClose
()
{
assert
(()
{
if
(
_tickers
!=
null
)
{
for
(
final
ticker
in
_tickers
!)
{
if
(
ticker
.
isActive
)
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'
$this
was disposed with an active Ticker.'
),
ErrorDescription
(
'
$runtimeType
created a Ticker via its GetTickerProviderStateMixin, but at the time '
'dispose() was called on the mixin, that Ticker was still active. All Tickers must '
'be disposed before calling super.dispose().'
,
),
ErrorHint
(
'Tickers used by AnimationControllers '
'should be disposed by calling dispose() on the AnimationController itself. '
'Otherwise, the ticker will leak.'
,
),
ticker
.
describeForError
(
'The offending ticker was'
),
]);
}
}
}
return
true
;
}());
super
.
onClose
();
}
}
class
_WidgetTicker
extends
Ticker
{
_WidgetTicker
(
TickerCallback
onTick
,
this
.
_creator
,
{
String
?
debugLabel
})
:
super
(
onTick
,
debugLabel:
debugLabel
);
final
GetTickerProviderStateMixin
_creator
;
@override
void
dispose
()
{
_creator
.
_removeTicker
(
this
);
super
.
dispose
();
}
}
@Deprecated
(
'use GetSingleTickerProviderStateMixin'
)
/// Used like `SingleTickerProviderMixin` but only with Get Controllers.
...
...
lib/get_state_manager/src/simple/get_responsive.dart
View file @
e7c5bd9
import
'package:flutter/widgets.dart'
;
import
'../../../get.dart'
;
import
'get_view.dart'
;
mixin
GetResponsiveMixin
on
Widget
{
ResponsiveScreen
get
screen
;
...
...
lib/get_state_manager/src/simple/list_notifier.dart
View file @
e7c5bd9
import
'dart:collection'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
// This callback remove the listener on addListener function
...
...
lib/get_state_manager/src/simple/mixin_state.dart
View file @
e7c5bd9
import
'package:flutter/material.dart'
;
import
'../../get_state_manager.dart'
;
import
'get_state.dart'
;
class
MixinBuilder
<
T
extends
GetxController
>
extends
StatelessWidget
{
@required
...
...
lib/get_utils/src/extensions/context_extensions.dart
View file @
e7c5bd9
import
'package:collection/collection.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
extension
ContextExtensionss
on
BuildContext
{
/// The same of [MediaQuery.of(context).size]
...
...
lib/get_utils/src/extensions/internacionalization.dart
View file @
e7c5bd9
...
...
@@ -68,14 +68,14 @@ extension Trans on String {
Map
<
String
,
String
>?
get
_getSimilarLanguageTranslation
{
final
translationsWithNoCountry
=
Get
.
translations
.
map
((
key
,
value
)
=>
MapEntry
(
key
.
split
(
"_"
).
first
,
value
));
final
containsKey
=
translationsWithNoCountry
.
containsKey
(
Get
.
locale
!.
languageCode
);
final
containsKey
=
translationsWithNoCountry
.
containsKey
(
Get
.
locale
!.
languageCode
.
split
(
"_"
).
first
);
if
(!
containsKey
)
{
return
null
;
}
return
translationsWithNoCountry
[
Get
.
locale
!.
languageCode
];
return
translationsWithNoCountry
[
Get
.
locale
!.
languageCode
.
split
(
"_"
).
first
];
}
String
get
tr
{
...
...
pubspec.yaml
View file @
e7c5bd9
name
:
get
description
:
Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX.
version
:
4.
5
.1
version
:
4.
6
.1
homepage
:
https://github.com/jonataslaw/getx
environment
:
...
...
test/instance/get_instance_test.dart
View file @
e7c5bd9
// ignore_for_file: avoid_classes_with_only_static_members
import
'package:flutter_test/flutter_test.dart'
;
import
'package:get/get.dart'
;
...
...
@@ -146,8 +148,8 @@ void main() {
Get
.
create
<
Service
>(()
=>
Api
());
final
ct1
=
Get
.
find
<
Service
>();
final
ct2
=
Get
.
find
<
Service
>();
expect
(
ct1
is
Service
,
true
);
expect
(
ct2
is
Service
,
true
);
// expect(ct1 is Service, true);
// expect(ct2 is Service, true);
expect
(
ct1
==
ct2
,
false
);
Get
.
reset
();
});
...
...
test/navigation/get_main_test.dart
View file @
e7c5bd9
...
...
@@ -336,7 +336,10 @@ void main() {
testWidgets
(
"Get.back navigates back"
,
(
tester
)
async
{
await
tester
.
pumpWidget
(
Wrapper
(
child:
FirstScreen
()),
Wrapper
(
child:
FirstScreen
(),
defaultTransition:
Transition
.
circularReveal
,
),
);
Get
.
to
(
SecondScreen
());
...
...
test/navigation/routes_test.dart
View file @
e7c5bd9
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:get/get.dart'
;
...
...
test/rx/rx_workers_test.dart
View file @
e7c5bd9
...
...
@@ -114,6 +114,23 @@ void main() {
expect
(
1
,
timesCalled
);
});
test
(
'Rx different value will call the listener when `trigger`'
,
()
async
{
var
reactiveInteger
=
RxInt
(
0
);
var
timesCalled
=
0
;
reactiveInteger
.
listen
((
newInt
)
{
timesCalled
++;
});
// we call 3
reactiveInteger
.
trigger
(
1
);
// then repeat twice
reactiveInteger
.
trigger
(
2
);
reactiveInteger
.
trigger
(
3
);
await
Future
.
delayed
(
Duration
(
milliseconds:
100
));
expect
(
3
,
timesCalled
);
});
test
(
'Rx same value will call the listener when `trigger`'
,
()
async
{
var
reactiveInteger
=
RxInt
(
2
);
var
timesCalled
=
0
;
...
...
@@ -126,9 +143,10 @@ void main() {
// then repeat twice
reactiveInteger
.
trigger
(
3
);
reactiveInteger
.
trigger
(
3
);
reactiveInteger
.
trigger
(
1
);
await
Future
.
delayed
(
Duration
(
milliseconds:
100
));
expect
(
3
,
timesCalled
);
expect
(
4
,
timesCalled
);
});
test
(
'Rx String with non null values'
,
()
async
{
...
...
Please
register
or
login
to post a comment