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-03-04 15:32:28 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
72ff3b57eb09feea1340ef15d105fc3abee3212b
72ff3b57
1 parent
28a78ffc
update to 4.0.0-nullsafety.2
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
205 additions
and
203 deletions
.metadata
CHANGELOG.md
example/lib/lang/translation_service.dart
example/lib/main.dart
example/lib/pages/home/data/home_api_provider.dart
example/lib/pages/home/data/home_repository.dart
example/lib/pages/home/domain/entity/cases_model.dart
example/lib/pages/home/presentation/controllers/home_controller.dart
example/lib/pages/home/presentation/views/country_view.dart
example/lib/pages/home/presentation/views/home_view.dart
example/pubspec.yaml
example/test/main_test.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/multipart/multipart_file.dart
lib/get_connect/http/src/request/request.dart
lib/get_connect/http/src/response/response.dart
lib/get_connect/http/src/utils/utils.dart
lib/get_core/src/log.dart
lib/get_instance/src/extension_instance.dart
lib/get_navigation/src/extension_navigation.dart
lib/get_state_manager/src/simple/get_view.dart
lib/get_utils/src/extensions/internacionalization.dart
pubspec.yaml
test/instance/get_instance_test.dart
.metadata
0 → 100644
View file @
72ff3b5
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: 60bd88df915880d23877bfc1602e8ddcf4c4dd2a
channel: stable
project_type: app
...
...
CHANGELOG.md
View file @
72ff3b5
## [4.0.0-nullsafety.2]
-
Added append function to StateMixin. Now is possible track loading, success and error handle of your application with ONE LINE OF CODE. Ex: append(()=> api.getUser);
## [4.0.0-nullsafety.0]
-
Migrate to null-safety
-
Added ScrollMixin to controllers
...
...
example/lib/lang/translation_service.dart
View file @
72ff3b5
...
...
@@ -5,11 +5,11 @@ import 'en_US.dart';
import
'pt_BR.dart'
;
class
TranslationService
extends
Translations
{
static
final
locale
=
Get
.
deviceLocale
;
static
Locale
get
locale
=>
Get
.
deviceLocale
!
;
static
final
fallbackLocale
=
Locale
(
'en'
,
'US'
);
@override
@override
Map
<
String
,
Map
<
String
,
String
>>
get
keys
=>
{
'en_US'
:
en_US
,
'pt_BR'
:
pt_BR
,
};
}
\ No newline at end of file
'en_US'
:
en_US
,
'pt_BR'
:
pt_BR
,
};
}
...
...
example/lib/main.dart
View file @
72ff3b5
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'lang/translation_service.dart'
;
...
...
@@ -9,7 +11,7 @@ void main() {
}
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
key
})
:
super
(
key:
key
);
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
example/lib/pages/home/data/home_api_provider.dart
View file @
72ff3b5
...
...
@@ -9,7 +9,8 @@ abstract class IHomeProvider {
class
HomeProvider
extends
GetConnect
implements
IHomeProvider
{
@override
void
onInit
()
{
httpClient
.
defaultDecoder
=
CasesModel
.
fromJson
;
httpClient
.
defaultDecoder
=
(
val
)
=>
CasesModel
.
fromJson
(
val
as
Map
<
String
,
dynamic
>);
httpClient
.
baseUrl
=
'https://api.covid19api.com'
;
}
...
...
example/lib/pages/home/data/home_repository.dart
View file @
72ff3b5
...
...
@@ -3,16 +3,16 @@ import '../domain/entity/cases_model.dart';
import
'home_api_provider.dart'
;
class
HomeRepository
implements
IHomeRepository
{
HomeRepository
({
this
.
provider
});
HomeRepository
({
required
this
.
provider
});
final
IHomeProvider
provider
;
@override
Future
<
CasesModel
>
getCases
()
async
{
final
cases
=
await
provider
.
getCases
(
"/summary"
);
if
(
cases
.
status
.
hasError
)
{
return
Future
.
error
(
cases
.
statusText
);
return
Future
.
error
(
cases
.
statusText
!
);
}
else
{
return
cases
.
body
;
return
cases
.
body
!
;
}
}
}
...
...
example/lib/pages/home/domain/entity/cases_model.dart
View file @
72ff3b5
// To parse this JSON data, do
//
// final
CasesModel = CasesModel
FromJson(jsonString);
// final
welcome = welcome
FromJson(jsonString);
import
'dart:convert'
;
class
CasesModel
{
final
Global
global
;
final
List
<
Country
>
countries
;
final
String
date
;
CasesModel
({
this
.
global
,
this
.
countries
,
this
.
date
,
required
this
.
id
,
required
this
.
message
,
required
this
.
global
,
required
this
.
countries
,
required
this
.
date
,
});
static
CasesModel
fromRawJson
(
String
str
)
=>
final
String
id
;
final
String
message
;
final
Global
global
;
final
List
<
Country
>
countries
;
final
DateTime
date
;
factory
CasesModel
.
fromRawJson
(
String
str
)
=>
CasesModel
.
fromJson
(
json
.
decode
(
str
)
as
Map
<
String
,
dynamic
>);
String
toRawJson
()
=>
json
.
encode
(
toJson
());
static
CasesModel
fromJson
(
dynamic
json
)
=>
CasesModel
(
global:
json
[
"Global"
]
==
null
?
null
:
Global
.
fromJson
(
json
[
"Global"
]
as
Map
<
String
,
dynamic
>),
countries:
json
[
"Countries"
]
==
null
?
null
:
List
<
Country
>.
from
(
(
json
[
"Countries"
]
as
List
<
dynamic
>)
.
map
((
x
)
=>
Country
.
fromJson
(
x
as
Map
<
String
,
dynamic
>)),
),
date:
json
[
"Date"
]
==
null
?
null
:
json
[
"Date"
]
as
String
,
factory
CasesModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
CasesModel
(
id:
json
[
"ID"
]
as
String
,
message:
json
[
"Message"
]
as
String
,
global:
Global
.
fromJson
(
json
[
"Global"
]
as
Map
<
String
,
dynamic
>),
countries:
List
<
Country
>.
from
((
json
[
"Countries"
]
as
Iterable
).
map
(
(
x
)
=>
Country
.
fromJson
(
x
as
Map
<
String
,
dynamic
>),
)),
date:
DateTime
.
parse
(
json
[
"Date"
]
as
String
),
);
Map
<
String
,
dynamic
>
toJson
()
=>
{
"Global"
:
global
==
null
?
null
:
global
.
toJson
(),
"Countries"
:
countries
==
null
?
null
:
List
<
dynamic
>.
from
(
countries
.
map
((
x
)
=>
x
.
toJson
())),
"Date"
:
date
==
null
?
null
:
date
,
"ID"
:
id
,
"Message"
:
message
,
"Global"
:
global
.
toJson
(),
"Countries"
:
List
<
dynamic
>.
from
(
countries
.
map
((
x
)
=>
x
.
toJson
())),
"Date"
:
date
.
toIso8601String
(),
};
}
class
Country
{
Country
({
required
this
.
id
,
required
this
.
country
,
required
this
.
countryCode
,
required
this
.
slug
,
required
this
.
newConfirmed
,
required
this
.
totalConfirmed
,
required
this
.
newDeaths
,
required
this
.
totalDeaths
,
required
this
.
newRecovered
,
required
this
.
totalRecovered
,
required
this
.
date
,
required
this
.
premium
,
});
final
String
id
;
final
String
country
;
final
String
countryCode
;
final
String
slug
;
...
...
@@ -52,20 +69,8 @@ class Country {
final
int
totalDeaths
;
final
int
newRecovered
;
final
int
totalRecovered
;
final
String
date
;
Country
({
this
.
country
,
this
.
countryCode
,
this
.
slug
,
this
.
newConfirmed
,
this
.
totalConfirmed
,
this
.
newDeaths
,
this
.
totalDeaths
,
this
.
newRecovered
,
this
.
totalRecovered
,
this
.
date
,
});
final
DateTime
date
;
final
Premium
premium
;
factory
Country
.
fromRawJson
(
String
str
)
=>
Country
.
fromJson
(
json
.
decode
(
str
)
as
Map
<
String
,
dynamic
>);
...
...
@@ -73,56 +78,67 @@ class Country {
String
toRawJson
()
=>
json
.
encode
(
toJson
());
factory
Country
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
Country
(
country:
json
[
"Country"
]
==
null
?
null
:
json
[
"Country"
]
as
String
,
countryCode:
json
[
"CountryCode"
]
==
null
?
null
:
json
[
"CountryCode"
]
as
String
,
slug:
json
[
"Slug"
]
==
null
?
null
:
json
[
"Slug"
]
as
String
,
newConfirmed:
json
[
"NewConfirmed"
]
==
null
?
null
:
json
[
"NewConfirmed"
]
as
int
,
totalConfirmed:
json
[
"TotalConfirmed"
]
==
null
?
null
:
json
[
"TotalConfirmed"
]
as
int
,
newDeaths:
json
[
"NewDeaths"
]
==
null
?
null
:
json
[
"NewDeaths"
]
as
int
,
totalDeaths:
json
[
"TotalDeaths"
]
==
null
?
null
:
json
[
"TotalDeaths"
]
as
int
,
newRecovered:
json
[
"NewRecovered"
]
==
null
?
null
:
json
[
"NewRecovered"
]
as
int
,
totalRecovered:
json
[
"TotalRecovered"
]
==
null
?
null
:
json
[
"TotalRecovered"
]
as
int
,
date:
json
[
"Date"
]
==
null
?
null
:
json
[
"Date"
]
as
String
,
id:
json
[
"ID"
]
as
String
,
country:
json
[
"Country"
]
as
String
,
countryCode:
json
[
"CountryCode"
]
as
String
,
slug:
json
[
"Slug"
]
as
String
,
newConfirmed:
json
[
"NewConfirmed"
]
as
int
,
totalConfirmed:
json
[
"TotalConfirmed"
]
as
int
,
newDeaths:
json
[
"NewDeaths"
]
as
int
,
totalDeaths:
json
[
"TotalDeaths"
]
as
int
,
newRecovered:
json
[
"NewRecovered"
]
as
int
,
totalRecovered:
json
[
"TotalRecovered"
]
as
int
,
date:
DateTime
.
parse
(
json
[
"Date"
]
as
String
),
premium:
Premium
.
fromJson
(
json
[
"Premium"
]
as
Map
<
String
,
dynamic
>),
);
Map
<
String
,
dynamic
>
toJson
()
=>
{
"Country"
:
country
==
null
?
null
:
country
,
"CountryCode"
:
countryCode
==
null
?
null
:
countryCode
,
"Slug"
:
slug
==
null
?
null
:
slug
,
"NewConfirmed"
:
newConfirmed
==
null
?
null
:
newConfirmed
,
"TotalConfirmed"
:
totalConfirmed
==
null
?
null
:
totalConfirmed
,
"NewDeaths"
:
newDeaths
==
null
?
null
:
newDeaths
,
"TotalDeaths"
:
totalDeaths
==
null
?
null
:
totalDeaths
,
"NewRecovered"
:
newRecovered
==
null
?
null
:
newRecovered
,
"TotalRecovered"
:
totalRecovered
==
null
?
null
:
totalRecovered
,
"Date"
:
date
==
null
?
null
:
date
,
"ID"
:
id
,
"Country"
:
country
,
"CountryCode"
:
countryCode
,
"Slug"
:
slug
,
"NewConfirmed"
:
newConfirmed
,
"TotalConfirmed"
:
totalConfirmed
,
"NewDeaths"
:
newDeaths
,
"TotalDeaths"
:
totalDeaths
,
"NewRecovered"
:
newRecovered
,
"TotalRecovered"
:
totalRecovered
,
"Date"
:
date
.
toIso8601String
(),
"Premium"
:
premium
.
toJson
(),
};
}
class
Premium
{
Premium
();
factory
Premium
.
fromRawJson
(
String
str
)
=>
Premium
.
fromJson
(
json
.
decode
(
str
)
as
Map
<
String
,
dynamic
>);
String
toRawJson
()
=>
json
.
encode
(
toJson
());
factory
Premium
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
Premium
();
Map
<
String
,
dynamic
>
toJson
()
=>
{};
}
class
Global
{
Global
({
required
this
.
newConfirmed
,
required
this
.
totalConfirmed
,
required
this
.
newDeaths
,
required
this
.
totalDeaths
,
required
this
.
newRecovered
,
required
this
.
totalRecovered
,
required
this
.
date
,
});
final
int
newConfirmed
;
final
int
totalConfirmed
;
final
int
newDeaths
;
final
int
totalDeaths
;
final
int
newRecovered
;
final
int
totalRecovered
;
Global
({
this
.
newConfirmed
,
this
.
totalConfirmed
,
this
.
newDeaths
,
this
.
totalDeaths
,
this
.
newRecovered
,
this
.
totalRecovered
,
});
final
DateTime
date
;
factory
Global
.
fromRawJson
(
String
str
)
=>
Global
.
fromJson
(
json
.
decode
(
str
)
as
Map
<
String
,
dynamic
>);
...
...
@@ -130,27 +146,22 @@ class Global {
String
toRawJson
()
=>
json
.
encode
(
toJson
());
factory
Global
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
Global
(
newConfirmed:
json
[
"NewConfirmed"
]
==
null
?
null
:
json
[
"NewConfirmed"
]
as
int
,
totalConfirmed:
json
[
"TotalConfirmed"
]
==
null
?
null
:
json
[
"TotalConfirmed"
]
as
int
,
newDeaths:
json
[
"NewDeaths"
]
==
null
?
null
:
json
[
"NewDeaths"
]
as
int
,
totalDeaths:
json
[
"TotalDeaths"
]
==
null
?
null
:
json
[
"TotalDeaths"
]
as
int
,
newRecovered:
json
[
"NewRecovered"
]
==
null
?
null
:
json
[
"NewRecovered"
]
as
int
,
totalRecovered:
json
[
"TotalRecovered"
]
==
null
?
null
:
json
[
"TotalRecovered"
]
as
int
,
newConfirmed:
json
[
"NewConfirmed"
]
as
int
,
totalConfirmed:
json
[
"TotalConfirmed"
]
as
int
,
newDeaths:
json
[
"NewDeaths"
]
as
int
,
totalDeaths:
json
[
"TotalDeaths"
]
as
int
,
newRecovered:
json
[
"NewRecovered"
]
as
int
,
totalRecovered:
json
[
"TotalRecovered"
]
as
int
,
date:
DateTime
.
parse
(
json
[
"Date"
]
as
String
),
);
Map
<
String
,
dynamic
>
toJson
()
=>
{
"NewConfirmed"
:
newConfirmed
==
null
?
null
:
newConfirmed
,
"TotalConfirmed"
:
totalConfirmed
==
null
?
null
:
totalConfirmed
,
"NewDeaths"
:
newDeaths
==
null
?
null
:
newDeaths
,
"TotalDeaths"
:
totalDeaths
==
null
?
null
:
totalDeaths
,
"NewRecovered"
:
newRecovered
==
null
?
null
:
newRecovered
,
"TotalRecovered"
:
totalRecovered
==
null
?
null
:
totalRecovered
,
"NewConfirmed"
:
newConfirmed
,
"TotalConfirmed"
:
totalConfirmed
,
"NewDeaths"
:
newDeaths
,
"TotalDeaths"
:
totalDeaths
,
"NewRecovered"
:
newRecovered
,
"TotalRecovered"
:
totalRecovered
,
"Date"
:
date
.
toIso8601String
(),
};
}
...
...
example/lib/pages/home/presentation/controllers/home_controller.dart
View file @
72ff3b5
...
...
@@ -4,22 +4,16 @@ import '../../domain/adapters/repository_adapter.dart';
import
'../../domain/entity/cases_model.dart'
;
class
HomeController
extends
SuperController
<
CasesModel
>
{
HomeController
({
this
.
homeRepository
});
HomeController
({
required
this
.
homeRepository
});
/// inject repo abstraction dependency
final
IHomeRepository
homeRepository
;
/// When the controller is initialized, make the http request
@override
void
onInit
()
{
super
.
onInit
();
// show loading on start, data on success
// and error message on error with 0 boilerplate
homeRepository
.
getCases
().
then
((
data
)
{
change
(
data
,
status:
RxStatus
.
success
());
},
onError:
(
err
)
{
change
(
null
,
status:
RxStatus
.
error
(
err
.
toString
()));
});
//Loading, Success, Error handle with 1 line of code
append
(()
=>
homeRepository
.
getCases
);
}
@override
...
...
example/lib/pages/home/presentation/views/country_view.dart
View file @
72ff3b5
...
...
@@ -29,9 +29,9 @@ class CountryView extends GetView<HomeController> {
),
body:
Center
(
child:
ListView
.
builder
(
itemCount:
controller
.
state
.
countries
.
length
,
itemCount:
controller
.
state
!
.
countries
.
length
,
itemBuilder:
(
context
,
index
)
{
final
country
=
controller
.
state
.
countries
[
index
];
final
country
=
controller
.
state
!
.
countries
[
index
];
return
ListTile
(
onTap:
()
{
Get
.
toNamed
(
'/home/country/details'
,
...
...
example/lib/pages/home/presentation/views/home_view.dart
View file @
72ff3b5
...
...
@@ -42,7 +42,7 @@ class HomeView extends GetView<HomeController> {
),
),
Text
(
'
${state.global.totalConfirmed}
'
,
'
${state
!
.global.totalConfirmed}
'
,
style:
TextStyle
(
fontSize:
45
,
fontWeight:
FontWeight
.
bold
),
),
SizedBox
(
...
...
example/pubspec.yaml
View file @
72ff3b5
...
...
@@ -18,7 +18,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
version
:
1.0.0+1
environment
:
sdk
:
"
>=2.
7
.0
<3.0.0"
sdk
:
"
>=2.
12
.0
<3.0.0"
dependencies
:
flutter
:
...
...
example/test/main_test.dart
View file @
72ff3b5
...
...
@@ -17,7 +17,18 @@ class MockRepository implements IHomeRepository {
if
(
Random
().
nextBool
())
{
return
CasesModel
(
global:
Global
(
totalDeaths:
100
,
totalConfirmed:
200
),
global:
Global
(
totalDeaths:
100
,
totalConfirmed:
200
,
date:
DateTime
.
now
(),
newConfirmed:
0
,
newDeaths:
0
,
newRecovered:
0
,
totalRecovered:
0
),
countries:
[],
date:
DateTime
.
now
(),
id:
''
,
message:
''
,
);
}
...
...
@@ -30,7 +41,7 @@ void main() {
final
binding
=
BindingsBuilder
(()
{
Get
.
lazyPut
<
IHomeRepository
>(()
=>
MockRepository
());
Get
.
lazyPut
<
HomeController
>(
()
=>
HomeController
(
homeRepository:
Get
.
find
()));
()
=>
HomeController
(
homeRepository:
Get
.
find
()
!
));
});
test
(
'Test Binding'
,
()
{
...
...
@@ -69,8 +80,8 @@ void main() {
}
if
(
controller
.
status
.
isSuccess
)
{
expect
(
controller
.
state
.
global
.
totalDeaths
,
100
);
expect
(
controller
.
state
.
global
.
totalConfirmed
,
200
);
expect
(
controller
.
state
!.
global
.
totalDeaths
,
100
);
expect
(
controller
.
state
!.
global
.
totalConfirmed
,
200
);
}
});
...
...
@@ -104,33 +115,6 @@ void main() {
),
test:
(
e
)
{
expect
(
find
.
text
(
"ban:0"
),
findsOneWidget
);
expect
(
e
.
count
.
value
,
0
);
},
);
testGetBuilder
(
'GetBuilder test'
,
widget:
GetBuilder
<
Controller
>(
init:
Controller
(),
builder:
(
controller
)
{
return
Text
(
"ban:
${controller.count}
"
);
},
),
test:
(
e
)
{
expect
(
find
.
text
(
"ban:0"
),
findsOneWidget
);
expect
(
e
.
count
.
value
,
0
);
},
);
testObx
(
'Obx test'
,
widget:
(
controller
)
=>
Obx
(
()
=>
Text
(
"ban:
${controller.count}
"
),
),
controller:
Controller
(),
test:
(
e
)
{
expect
(
find
.
text
(
"ban:0"
),
findsOneWidget
);
expect
(
e
.
count
.
value
,
0
);
},
);
...
...
lib/get_connect/http/src/http.dart
View file @
72ff3b5
...
...
@@ -93,7 +93,7 @@ class GetHttpClient {
Progress
?
uploadProgress
,
)
async
{
List
<
int
>?
bodyBytes
;
BodyBytesStream
?
bodyStream
;
Stream
<
List
<
int
>>
?
bodyStream
;
final
headers
=
<
String
,
String
>{};
headers
[
'user-agent'
]
=
userAgent
;
...
...
@@ -145,7 +145,7 @@ class GetHttpClient {
);
}
BodyBytesStream
_trackProgress
(
Stream
<
List
<
int
>>
_trackProgress
(
List
<
int
>
bodyBytes
,
Progress
?
uploadProgress
,
)
{
...
...
@@ -163,7 +163,7 @@ class GetHttpClient {
sink
.
add
(
data
);
}),
);
return
BodyBytesStream
(
byteStream
)
;
return
byteStream
;
}
void
_setSimpleHeaders
(
...
...
lib/get_connect/http/src/http/html/http_request_html.dart
View file @
72ff3b5
...
...
@@ -46,7 +46,7 @@ class HttpRequestImpl implements HttpRequestBase {
var
reader
=
html
.
FileReader
();
reader
.
onLoad
.
first
.
then
((
_
)
async
{
var
bodyBytes
=
BodyBytesStream
.
fromBytes
(
reader
.
result
as
Uint8List
?
);
var
bodyBytes
=
BodyBytesStream
.
fromBytes
(
reader
.
result
as
List
<
int
>
);
final
stringBody
=
await
bodyBytesToString
(
bodyBytes
,
xhr
.
responseHeaders
);
...
...
lib/get_connect/http/src/http/io/http_request_io.dart
View file @
72ff3b5
...
...
@@ -50,7 +50,7 @@ class HttpRequestImpl extends HttpRequestBase {
headers
[
key
]
=
values
.
join
(
','
);
});
final
bodyBytes
=
BodyBytesStream
(
response
);
final
bodyBytes
=
(
response
);
final
stringBody
=
await
bodyBytesToString
(
bodyBytes
,
headers
);
final
body
=
bodyDecoded
<
T
>(
...
...
lib/get_connect/http/src/multipart/multipart_file.dart
View file @
72ff3b5
...
...
@@ -19,11 +19,11 @@ class MultipartFile {
final
String
contentType
;
/// This stream will emit the file content of File.
BodyBytesStream
?
_stream
;
Stream
<
List
<
int
>>
?
_stream
;
int
?
_length
;
BodyBytesStream
?
get
stream
=>
_stream
;
Stream
<
List
<
int
>>
?
get
stream
=>
_stream
;
int
?
get
length
=>
_length
;
...
...
lib/get_connect/http/src/request/request.dart
View file @
72ff3b5
...
...
@@ -21,7 +21,7 @@ class Request<T> {
final
int
?
contentLength
;
/// The BodyBytesStream of body from this [Request]
final
BodyBytesStream
bodyBytes
;
final
Stream
<
List
<
int
>>
bodyBytes
;
/// When true, the client will follow redirects to resolves this [Request]
final
bool
followRedirects
;
...
...
@@ -50,7 +50,7 @@ class Request<T> {
required
Uri
url
,
required
String
method
,
required
Map
<
String
,
String
>
headers
,
BodyBytesStream
?
bodyBytes
,
Stream
<
List
<
int
>>
?
bodyBytes
,
bool
followRedirects
=
true
,
int
maxRedirects
=
4
,
int
?
contentLength
,
...
...
@@ -76,11 +76,9 @@ class Request<T> {
}
}
class
BodyBytesStream
extends
StreamView
<
List
<
int
>?>
{
BodyBytesStream
(
Stream
<
List
<
int
>?>
stream
)
:
super
(
stream
);
factory
BodyBytesStream
.
fromBytes
(
List
<
int
>?
bytes
)
=>
BodyBytesStream
(
Stream
.
fromIterable
([
bytes
]));
extension
BodyBytesStream
on
Stream
<
List
<
int
>>
{
static
Stream
<
List
<
int
>>
fromBytes
(
List
<
int
>
bytes
)
=>
Stream
.
fromIterable
([
bytes
]);
Future
<
Uint8List
>
toBytes
()
{
var
completer
=
Completer
<
Uint8List
>();
...
...
@@ -89,7 +87,7 @@ class BodyBytesStream extends StreamView<List<int>?> {
Uint8List
.
fromList
(
bytes
),
),
);
listen
((
val
)
=>
sink
.
add
(
val
!
),
listen
((
val
)
=>
sink
.
add
(
val
),
onError:
completer
.
completeError
,
onDone:
sink
.
close
,
cancelOnError:
true
);
...
...
@@ -97,5 +95,5 @@ class BodyBytesStream extends StreamView<List<int>?> {
}
Future
<
String
>
bytesToString
([
Encoding
encoding
=
utf8
])
=>
encoding
.
decodeStream
(
this
as
Stream
<
List
<
int
>>
);
encoding
.
decodeStream
(
this
);
}
...
...
lib/get_connect/http/src/response/response.dart
View file @
72ff3b5
...
...
@@ -49,7 +49,7 @@ class Response<T> {
bool
get
unauthorized
=>
status
.
isUnauthorized
;
/// The response body as a Stream of Bytes.
final
BodyBytesStream
?
bodyBytes
;
final
Stream
<
List
<
int
>>
?
bodyBytes
;
/// The response body as a Stream of Bytes.
final
String
?
bodyString
;
...
...
@@ -61,7 +61,7 @@ class Response<T> {
}
Future
<
String
>
bodyBytesToString
(
BodyBytesStream
bodyBytes
,
Map
<
String
,
String
>
headers
)
{
Stream
<
List
<
int
>>
bodyBytes
,
Map
<
String
,
String
>
headers
)
{
return
bodyBytes
.
bytesToString
(
_encodingForHeaders
(
headers
));
}
...
...
lib/get_connect/http/src/utils/utils.dart
View file @
72ff3b5
...
...
@@ -52,10 +52,9 @@ String validateField(String field) {
return
field
.
toLowerCase
();
}
BodyBytesStream
toBodyBytesStream
(
Stream
<
List
<
int
>>
stream
)
{
if
(
stream
is
BodyBytesStream
)
return
stream
as
BodyBytesStream
;
return
BodyBytesStream
(
stream
);
}
// Stream<List<int>> toBodyBytesStream(Stream<List<int>> stream) {
// return (stream);
// }
final
_asciiOnly
=
RegExp
(
r'^[\x00-\x7F]+$'
);
...
...
lib/get_core/src/log.dart
View file @
72ff3b5
...
...
@@ -2,9 +2,9 @@ import 'dart:developer' as developer;
import
'get_main.dart'
;
///Voidcallback from logs
typedef
LogWriterCallback
=
void
Function
(
String
text
,
{
bool
?
isError
});
typedef
LogWriterCallback
=
void
Function
(
String
text
,
{
bool
isError
});
/// default logger from GetX
void
defaultLogWriterCallback
(
String
value
,
{
bool
?
isError
=
false
})
{
if
(
isError
!
||
Get
.
isLogEnable
)
developer
.
log
(
value
,
name:
'GETX'
);
void
defaultLogWriterCallback
(
String
value
,
{
bool
isError
=
false
})
{
if
(
isError
||
Get
.
isLogEnable
)
developer
.
log
(
value
,
name:
'GETX'
);
}
...
...
lib/get_instance/src/extension_instance.dart
View file @
72ff3b5
...
...
@@ -67,7 +67,7 @@ extension Inst on GetInterface {
/// Finds a Instance of the required Class <[S]>(or [tag])
/// In the case of using [Get.create()], it will generate an Instance
/// each time you call [Get.find()].
S
?
find
<
S
>({
String
?
tag
})
=>
GetInstance
().
find
<
S
>(
tag:
tag
)
;
S
find
<
S
>({
String
?
tag
})
=>
GetInstance
().
find
<
S
>(
tag:
tag
)!
;
/// Injects an [Instance<S>] in memory.
///
...
...
lib/get_navigation/src/extension_navigation.dart
View file @
72ff3b5
...
...
@@ -1105,9 +1105,9 @@ Since version 2.8 it is possible to access the properties
//TODO: Change to ui.SingletonFlutterWindow rather dynamic
//when Flutter update stable. dynamic is used to avoid Breaking Changes
/// The window to which this binding is bound.
dynamic
get
window
=>
ui
.
window
;
ui
.
SingletonFlutterWindow
get
window
=>
ui
.
window
;
Locale
get
deviceLocale
=>
ui
.
window
.
locale
;
Locale
?
get
deviceLocale
=>
ui
.
window
.
locale
;
///The number of device pixels for each logical pixel.
double
get
pixelRatio
=>
ui
.
window
.
devicePixelRatio
;
...
...
lib/get_state_manager/src/simple/get_view.dart
View file @
72ff3b5
...
...
@@ -35,7 +35,7 @@ abstract class GetView<T> extends StatelessWidget {
final
String
?
tag
=
null
;
T
?
get
controller
=>
GetInstance
().
find
<
T
>(
tag:
tag
)
;
T
get
controller
=>
GetInstance
().
find
<
T
>(
tag:
tag
)!
;
@override
Widget
build
(
BuildContext
context
);
...
...
@@ -53,7 +53,7 @@ abstract class GetWidget<S extends GetLifeCycleBase?> extends GetWidgetCache {
@protected
final
String
?
tag
=
null
;
S
?
get
controller
=>
GetWidget
.
_cache
[
this
]
as
S
?
;
S
get
controller
=>
GetWidget
.
_cache
[
this
]
as
S
;
// static final _cache = <GetWidget, GetLifeCycleBase>{};
...
...
lib/get_utils/src/extensions/internacionalization.dart
View file @
72ff3b5
import
'dart:ui'
;
import
'../../../get_core/get_core.dart'
;
extension
Trans
on
String
?
{
String
?
get
tr
{
extension
Trans
on
String
{
String
get
tr
{
// Returns the key if locale is null.
if
(
Get
.
locale
?.
languageCode
==
null
)
return
this
;
...
...
@@ -14,13 +14,13 @@ extension Trans on String? {
"
${Get.locale!.languageCode}
_
${Get.locale!.countryCode}
"
]!
.
containsKey
(
this
))
{
return
Get
.
translations
[
"
${Get.locale!.languageCode}
_
${Get.locale!.countryCode}
"
]![
this
!]
;
"
${Get.locale!.languageCode}
_
${Get.locale!.countryCode}
"
]![
this
]!
;
// Checks if there is a callback language in the absence of the specific
// country, and if it contains that key.
}
else
if
(
Get
.
translations
.
containsKey
(
Get
.
locale
!.
languageCode
)
&&
Get
.
translations
[
Get
.
locale
!.
languageCode
]!.
containsKey
(
this
))
{
return
Get
.
translations
[
Get
.
locale
!.
languageCode
]![
this
!]
;
return
Get
.
translations
[
Get
.
locale
!.
languageCode
]![
this
]!
;
// If there is no corresponding language or corresponding key, return
// the key.
}
else
if
(
Get
.
fallbackLocale
!=
null
)
{
...
...
@@ -29,11 +29,11 @@ extension Trans on String? {
if
(
Get
.
translations
.
containsKey
(
key
)
&&
Get
.
translations
[
key
]!.
containsKey
(
this
))
{
return
Get
.
translations
[
key
]![
this
!]
;
return
Get
.
translations
[
key
]![
this
]!
;
}
if
(
Get
.
translations
.
containsKey
(
fallback
.
languageCode
)
&&
Get
.
translations
[
fallback
.
languageCode
]!.
containsKey
(
this
))
{
return
Get
.
translations
[
fallback
.
languageCode
]![
this
!]
;
return
Get
.
translations
[
fallback
.
languageCode
]![
this
]!
;
}
return
this
;
}
else
{
...
...
@@ -41,25 +41,25 @@ extension Trans on String? {
}
}
String
?
trArgs
([
List
<
String
>
args
=
const
[]])
{
String
trArgs
([
List
<
String
>
args
=
const
[]])
{
var
key
=
tr
;
if
(
args
.
isNotEmpty
)
{
for
(
final
arg
in
args
)
{
key
=
key
!
.
replaceFirst
(
RegExp
(
r'%s'
),
arg
.
toString
());
key
=
key
.
replaceFirst
(
RegExp
(
r'%s'
),
arg
.
toString
());
}
}
return
key
;
}
String
?
trPlural
([
String
?
pluralKey
,
int
?
i
,
List
<
String
>
args
=
const
[]])
{
return
i
==
1
?
pluralKey
.
trArgs
(
args
)
:
trArgs
(
args
);
String
trPlural
([
String
?
pluralKey
,
int
?
i
,
List
<
String
>
args
=
const
[]])
{
return
i
==
1
?
pluralKey
!.
trArgs
(
args
)
:
trArgs
(
args
);
}
String
?
trParams
([
Map
<
String
,
String
>
params
=
const
{}])
{
var
trans
=
tr
;
if
(
params
.
isNotEmpty
)
{
params
.
forEach
((
key
,
value
)
{
trans
=
trans
!
.
replaceAll
(
'@
$key
'
,
value
);
trans
=
trans
.
replaceAll
(
'@
$key
'
,
value
);
});
}
return
trans
;
...
...
@@ -67,7 +67,7 @@ extension Trans on String? {
String
?
trPluralParams
(
[
String
?
pluralKey
,
int
?
i
,
Map
<
String
,
String
>
params
=
const
{}])
{
return
i
==
1
?
pluralKey
.
trParams
(
params
)
:
trParams
(
params
);
return
i
==
1
?
pluralKey
!
.
trParams
(
params
)
:
trParams
(
params
);
}
}
...
...
pubspec.yaml
View file @
72ff3b5
name
:
get
description
:
Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX.
version
:
4.0.0-nullsafety.
0
version
:
4.0.0-nullsafety.
2
homepage
:
https://github.com/jonataslaw/getx
environment
:
...
...
test/instance/get_instance_test.dart
View file @
72ff3b5
...
...
@@ -39,7 +39,7 @@ void main() {
test
(
'Get start and delete called just one time'
,
()
async
{
Get
..
put
(
Controller
())..
put
(
Controller
());
final
controller
=
Get
.
find
<
Controller
>()
!
;
final
controller
=
Get
.
find
<
Controller
>();
expect
(
controller
.
init
,
1
);
Get
..
delete
<
Controller
>()..
delete
<
Controller
>();
...
...
@@ -83,19 +83,19 @@ void main() {
test
(
'Get.lazyPut fenix test'
,
()
async
{
Get
.
lazyPut
<
Controller
>(()
=>
Controller
(),
fenix:
true
);
Get
.
find
<
Controller
>()
!
.
increment
();
Get
.
find
<
Controller
>().
increment
();
expect
(
Get
.
find
<
Controller
>()
!
.
count
,
1
);
expect
(
Get
.
find
<
Controller
>().
count
,
1
);
Get
.
delete
<
Controller
>();
expect
(
Get
.
find
<
Controller
>()
!
.
count
,
0
);
expect
(
Get
.
find
<
Controller
>().
count
,
0
);
Get
.
reset
();
});
test
(
'Get.lazyPut without fenix'
,
()
async
{
Get
.
lazyPut
<
Controller
>(()
=>
Controller
());
Get
.
find
<
Controller
>()
!
.
increment
();
Get
.
find
<
Controller
>().
increment
();
expect
(
Get
.
find
<
Controller
>()
!
.
count
,
1
);
expect
(
Get
.
find
<
Controller
>().
count
,
1
);
Get
.
delete
<
Controller
>();
expect
(()
=>
Get
.
find
<
Controller
>(),
throwsA
(
m
.
TypeMatcher
<
String
>()));
Get
.
reset
();
...
...
@@ -103,13 +103,13 @@ void main() {
test
(
'Get.reloadInstance test'
,
()
async
{
Get
.
lazyPut
<
Controller
>(()
=>
Controller
());
var
ct1
=
Get
.
find
<
Controller
>()
!
;
var
ct1
=
Get
.
find
<
Controller
>();
ct1
.
increment
();
expect
(
ct1
.
count
,
1
);
ct1
=
Get
.
find
<
Controller
>()
!
;
ct1
=
Get
.
find
<
Controller
>();
expect
(
ct1
.
count
,
1
);
GetInstance
().
reload
<
Controller
>();
ct1
=
Get
.
find
<
Controller
>()
!
;
ct1
=
Get
.
find
<
Controller
>();
expect
(
ct1
.
count
,
0
);
Get
.
reset
();
});
...
...
Please
register
or
login
to post a comment