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
Nipodemos
2020-08-25 18:08:30 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
38c3e6d5f9c136c1c6a0c727cff93a2a54c52c49
38c3e6d5
1 parent
4e95003a
i think it's done now
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
154 additions
and
93 deletions
lib/src/extensions/context_extensions.dart
lib/src/extensions/dynamic_extensions.dart
lib/src/utils/extensions/context_extensions.dart
lib/src/extensions/double_extensions.dart → lib/src/utils/extensions/double_extensions.dart
lib/src/utils/extensions/dynamic_extensions.dart
lib/src/extensions/export.dart → lib/src/utils/extensions/export.dart
lib/src/extensions/num_extensions.dart → lib/src/utils/extensions/num_extensions.dart
lib/src/extensions/string_extensions.dart → lib/src/utils/extensions/string_extensions.dart
lib/src/extensions/widget_extensions.dart → lib/src/utils/extensions/widget_extensions.dart
lib/utils.dart
lib/src/extensions/context_extensions.dart
deleted
100644 → 0
View file @
4e95003
import
'package:flutter/widgets.dart'
;
extension
MDQ
on
BuildContext
{
Size
get
mediaQuerySize
=>
MediaQuery
.
of
(
this
).
size
;
double
get
height
=>
mediaQuerySize
.
height
;
double
get
width
=>
mediaQuerySize
.
width
;
double
heightTransformer
({
double
dividedBy
=
1
,
double
reducedBy
=
0.0
})
{
return
(
mediaQuerySize
.
height
-
((
mediaQuerySize
.
height
/
100
)
*
reducedBy
))
/
dividedBy
;
}
double
widthTransformer
({
double
dividedBy
=
1
,
double
reducedBy
=
0.0
})
{
return
(
mediaQuerySize
.
width
-
((
mediaQuerySize
.
width
/
100
)
*
reducedBy
))
/
dividedBy
;
}
double
ratio
(
{
double
dividedBy
=
1
,
double
reducedByW
=
0.0
,
double
reducedByH
=
0.0
})
{
return
heightTransformer
(
dividedBy:
dividedBy
,
reducedBy:
reducedByH
)
/
widthTransformer
(
dividedBy:
dividedBy
,
reducedBy:
reducedByW
);
}
/// similar to `MediaQuery.of(this).padding`.
EdgeInsets
get
mediaQueryPadding
=>
MediaQuery
.
of
(
this
).
padding
;
/// similar to `MediaQuery.of(this).viewPadding`.
EdgeInsets
get
mediaQueryViewPadding
=>
MediaQuery
.
of
(
this
).
viewPadding
;
/// similar to `MediaQuery.of(this).viewInsets`.
EdgeInsets
get
mediaQueryViewInsets
=>
MediaQuery
.
of
(
this
).
viewInsets
;
/// similar to `MediaQuery.of(this).orientation`.
Orientation
get
orientation
=>
MediaQuery
.
of
(
this
).
orientation
;
/// check if device is on LANDSCAPE mode.
bool
get
isLandscape
=>
orientation
==
Orientation
.
landscape
;
/// check if device is on PORTRAIT mode.
bool
get
isPortrait
=>
orientation
==
Orientation
.
portrait
;
/// similar to `MediaQuery.of(this).devicePixelRatio`.
double
get
devicePixelRatio
=>
MediaQuery
.
of
(
this
).
devicePixelRatio
;
/// similar to `MediaQuery.of(this).textScaleFactor`.
double
get
textScaleFactor
=>
MediaQuery
.
of
(
this
).
textScaleFactor
;
/// get the `shortestSide` from screen.
double
get
mediaQueryShortestSide
=>
mediaQuerySize
.
shortestSide
;
/// True if `width` is larger than 800p.
bool
get
showNavbar
=>
(
width
>
800
);
/// True if the `shortestSide` is smaller than 600p.
bool
get
isPhone
=>
(
mediaQueryShortestSide
<
600
);
/// True if the `shortestSide` is largest than 600p.
bool
get
isSmallTablet
=>
(
mediaQueryShortestSide
>=
600
);
/// True if the `shortestSide` is largest than 720p.
bool
get
isLargeTablet
=>
(
mediaQueryShortestSide
>=
720
);
/// True if the current device is TABLET.
bool
get
isTablet
=>
isSmallTablet
||
isLargeTablet
;
}
lib/src/extensions/dynamic_extensions.dart
deleted
100644 → 0
View file @
4e95003
import
'../../utils.dart'
;
extension
GetDynamicUtils
on
dynamic
{
bool
get
isNull
=>
GetUtils
.
isNull
(
this
);
bool
get
isNullOrBlank
=>
GetUtils
.
isNullOrBlank
(
this
);
bool
get
isOneAKind
=>
GetUtils
.
isOneAKind
(
this
);
bool
isLengthLowerThan
(
int
maxLength
)
=>
GetUtils
.
isLengthLowerThan
(
this
,
maxLength
);
bool
isLengthGreaterThan
(
int
maxLength
)
=>
GetUtils
.
isLengthGreaterThan
(
this
,
maxLength
);
bool
isLengthGreaterOrEqual
(
int
maxLength
)
=>
GetUtils
.
isLengthGreaterOrEqual
(
this
,
maxLength
);
bool
isLengthLowerOrEqual
(
int
maxLength
)
=>
GetUtils
.
isLengthLowerOrEqual
(
this
,
maxLength
);
bool
isLengthEqualTo
(
int
maxLength
)
=>
GetUtils
.
isLengthEqualTo
(
this
,
maxLength
);
bool
isLengthBetween
(
int
minLength
,
int
maxLength
)
=>
GetUtils
.
isLengthBetween
(
this
,
minLength
,
maxLength
);
}
lib/src/utils/extensions/context_extensions.dart
0 → 100644
View file @
38c3e6d
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/foundation.dart'
;
extension
ContextExtensionss
on
BuildContext
{
/// The same of [MediaQuery.of(context).size]
Size
get
mediaQuerySize
=>
MediaQuery
.
of
(
this
).
size
;
/// The same of [MediaQuery.of(context).size.height]
/// Note: updates when you rezise your screen (like on a browser or desktop window)
double
get
height
=>
mediaQuerySize
.
height
;
/// The same of [MediaQuery.of(context).size.width]
/// Note: updates when you rezise your screen (like on a browser or desktop window)
double
get
width
=>
mediaQuerySize
.
width
;
/// Gives you the power to get a portion of the height.
/// Useful for responsive applications.
///
/// [dividedBy] is for when you want to have a portion of the value you would get
/// like for example: if you want a value that represents a third of the screen
/// you can set it to 3, and you will get a third of the height
///
/// [reducedBy] is a percentage value of how much of the height you want
/// if you for example want 46% of the height, then you reduce it by 56%.
double
heightTransformer
({
double
dividedBy
=
1
,
double
reducedBy
=
0.0
})
{
return
(
mediaQuerySize
.
height
-
((
mediaQuerySize
.
height
/
100
)
*
reducedBy
))
/
dividedBy
;
}
/// Gives you the power to get a portion of the width.
/// Useful for responsive applications.
///
/// [dividedBy] is for when you want to have a portion of the value you would get
/// like for example: if you want a value that represents a third of the screen
/// you can set it to 3, and you will get a third of the width
///
/// [reducedBy] is a percentage value of how much of the width you want
/// if you for example want 46% of the width, then you reduce it by 56%.
double
widthTransformer
({
double
dividedBy
=
1
,
double
reducedBy
=
0.0
})
{
return
(
mediaQuerySize
.
width
-
((
mediaQuerySize
.
width
/
100
)
*
reducedBy
))
/
dividedBy
;
}
/// Divide the height proportionally by the given value
double
ratio
({
double
dividedBy
=
1
,
double
reducedByW
=
0.0
,
double
reducedByH
=
0.0
,
})
{
return
heightTransformer
(
dividedBy:
dividedBy
,
reducedBy:
reducedByH
)
/
widthTransformer
(
dividedBy:
dividedBy
,
reducedBy:
reducedByW
);
}
/// similar to [MediaQuery.of(context).padding]
ThemeData
get
theme
=>
Theme
.
of
(
this
);
/// similar to [MediaQuery.of(context).padding]
TextTheme
get
textTheme
=>
Theme
.
of
(
this
).
textTheme
;
/// similar to [MediaQuery.of(context).padding]
EdgeInsets
get
mediaQueryPadding
=>
MediaQuery
.
of
(
this
).
padding
;
/// similar to [MediaQuery.of(context).padding]
MediaQueryData
get
mediaQuery
=>
MediaQuery
.
of
(
this
);
/// similar to [MediaQuery.of(context).viewPadding]
EdgeInsets
get
mediaQueryViewPadding
=>
MediaQuery
.
of
(
this
).
viewPadding
;
/// similar to [MediaQuery.of(context).viewInsets]
EdgeInsets
get
mediaQueryViewInsets
=>
MediaQuery
.
of
(
this
).
viewInsets
;
/// similar to [MediaQuery.of(context).orientation]
Orientation
get
orientation
=>
MediaQuery
.
of
(
this
).
orientation
;
/// check if device is on landscape mode
bool
get
isLandscape
=>
orientation
==
Orientation
.
landscape
;
/// check if device is on portrait mode
bool
get
isPortrait
=>
orientation
==
Orientation
.
portrait
;
/// similar to [MediaQuery.of(this).devicePixelRatio]
double
get
devicePixelRatio
=>
MediaQuery
.
of
(
this
).
devicePixelRatio
;
/// similar to [MediaQuery.of(this).textScaleFactor]
double
get
textScaleFactor
=>
MediaQuery
.
of
(
this
).
textScaleFactor
;
/// get the shortestSide from screen
double
get
mediaQueryShortestSide
=>
mediaQuerySize
.
shortestSide
;
/// True if width be larger than 800
bool
get
showNavbar
=>
(
width
>
800
);
/// True if the shortestSide is smaller than 600p
bool
get
isPhone
=>
(
mediaQueryShortestSide
<
600
);
/// True if the shortestSide is largest than 600p
bool
get
isSmallTablet
=>
(
mediaQueryShortestSide
>=
600
);
/// True if the shortestSide is largest than 720p
bool
get
isLargeTablet
=>
(
mediaQueryShortestSide
>=
720
);
/// True if the current device is Tablet
bool
get
isTablet
=>
isSmallTablet
||
isLargeTablet
;
/// Returns a specific value according to the screen size
/// if the device width is higher than or equal to 1200 return [desktop] value.
/// if the device width is higher than or equal to 600 and less than 1200
/// return [tablet] value.
/// if the device width is less than 300 return [watch] value.
/// in other cases return [mobile] value.
T
responsiveValue
<
T
>({
T
mobile
,
T
tablet
,
T
desktop
,
T
watch
,
})
{
double
deviceWidth
=
mediaQuerySize
.
shortestSide
;
if
(
kIsWeb
)
{
deviceWidth
=
mediaQuerySize
.
width
;
}
if
(
deviceWidth
>=
1200
&&
desktop
!=
null
)
return
desktop
;
if
(
deviceWidth
>=
600
&&
tablet
!=
null
)
return
tablet
;
if
(
deviceWidth
<
300
&&
watch
!=
null
)
return
watch
;
return
mobile
;
}
}
...
...
lib/src/extensions/double_extensions.dart → lib/src/
utils/
extensions/double_extensions.dart
View file @
38c3e6d
lib/src/utils/extensions/dynamic_extensions.dart
0 → 100644
View file @
38c3e6d
import
'../regex/get_utils.dart'
;
extension
GetDynamicUtils
on
dynamic
{
/// It's This is overloading the IDE's options. Only the most useful and popular options will stay here.
bool
get
isNull
=>
GetUtils
.
isNull
(
this
);
bool
get
isNullOrBlank
=>
GetUtils
.
isNullOrBlank
(
this
);
// bool get isOneAKind => GetUtils.isOneAKind(this);
// bool isLengthLowerThan(int maxLength) =>
// GetUtils.isLengthLowerThan(this, maxLength);
// bool isLengthGreaterThan(int maxLength) =>
// GetUtils.isLengthGreaterThan(this, maxLength);
// bool isLengthGreaterOrEqual(int maxLength) =>
// GetUtils.isLengthGreaterOrEqual(this, maxLength);
// bool isLengthLowerOrEqual(int maxLength) =>
// GetUtils.isLengthLowerOrEqual(this, maxLength);
// bool isLengthEqualTo(int maxLength) =>
// GetUtils.isLengthEqualTo(this, maxLength);
// bool isLengthBetween(int minLength, int maxLength) =>
// GetUtils.isLengthBetween(this, minLength, maxLength);
}
...
...
lib/src/extensions/export.dart → lib/src/
utils/
extensions/export.dart
View file @
38c3e6d
lib/src/extensions/num_extensions.dart → lib/src/
utils/
extensions/num_extensions.dart
View file @
38c3e6d
import
'../
../
utils.dart'
;
import
'../
regex/get_
utils.dart'
;
extension
GetNumUtils
on
num
{
bool
isLowerThan
(
num
b
)
=>
GetUtils
.
isLowerThan
(
this
,
b
);
...
...
lib/src/extensions/string_extensions.dart → lib/src/
utils/
extensions/string_extensions.dart
View file @
38c3e6d
import
'../
../
utils.dart'
;
import
'../
regex/get_
utils.dart'
;
extension
GetStringUtils
on
String
{
bool
get
isNum
=>
GetUtils
.
isNum
(
this
);
...
...
lib/src/extensions/widget_extensions.dart → lib/src/
utils/
extensions/widget_extensions.dart
View file @
38c3e6d
lib/utils.dart
View file @
38c3e6d
export
'src/utils/
context_extensions/extensions
.dart'
;
export
'src/utils/
extensions/export
.dart'
;
export
'src/utils/queue/get_queue.dart'
;
export
'src/utils/platform/platform.dart'
;
export
'src/utils/regex/get_utils.dart'
;
export
'src/utils/regex/get_utils_extensions.dart'
;
...
...
Please
register
or
login
to post a comment