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-07-25 04:17:01 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
56f6b32bb7cb751da5ccdf5a4aade972d1bbdb8a
56f6b32b
1 parent
4fa5f608
added GetResponsiveWidget
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
37 deletions
lib/get_state_manager/src/simple/get_responsive.dart
lib/get_state_manager/src/simple/get_responsive.dart
View file @
56f6b32
...
...
@@ -3,39 +3,11 @@ import 'package:flutter/widgets.dart';
import
'../../../get.dart'
;
import
'get_view.dart'
;
abstract
class
_GetResponsive
<
T
>
extends
GetView
<
T
>
{
final
ResponsiveScreen
screen
;
_GetResponsive
(
ResponsiveScreenSettings
settings
,
{
Key
?
key
})
:
screen
=
ResponsiveScreen
(
settings
),
super
(
key:
key
);
Widget
?
builder
();
Widget
?
phone
();
Widget
?
tablet
();
Widget
?
desktop
();
Widget
?
watch
();
}
mixin
GetResponsiveMixin
on
Widget
{
ResponsiveScreen
get
screen
;
bool
get
alwaysUseBuilder
;
/// Extend this widget to build responsive view.
/// this widget contains the `screen` property that have all
/// information about the screen size and type.
/// You have two options to build it.
/// 1- with `builder` method you return the widget to build.
/// 2- with methods `desktop`, `tablet`,`phone`, `watch`. the specific
/// method will be built when the screen type matches the method
/// when the screen is [ScreenType.Tablet] the `tablet` method
/// will be exuded and so on.
/// Note if you use this method please set the
/// property `alwaysUseBuilder` to false
/// With `settings` property you can set the width limit for the screen types.
class
GetResponsiveView
<
T
>
extends
_GetResponsive
<
T
>
{
final
bool
alwaysUseBuilder
=
true
;
GetResponsiveView
(
{
alwaysUseBuilder
,
ResponsiveScreenSettings
settings
=
const
ResponsiveScreenSettings
(),
Key
?
key
})
:
super
(
settings
,
key:
key
);
@override
@protected
Widget
build
(
BuildContext
context
)
{
screen
.
context
=
context
;
Widget
?
widget
;
...
...
@@ -58,22 +30,60 @@ class GetResponsiveView<T> extends _GetResponsive<T> {
return
watch
()
??
phone
()
??
tablet
()
??
desktop
()
??
builder
()!;
}
@override
Widget
?
builder
()
=>
null
;
@override
Widget
?
desktop
()
=>
null
;
@override
Widget
?
phone
()
=>
null
;
@override
Widget
?
tablet
()
=>
null
;
@override
Widget
?
watch
()
=>
null
;
}
/// Extend this widget to build responsive view.
/// this widget contains the `screen` property that have all
/// information about the screen size and type.
/// You have two options to build it.
/// 1- with `builder` method you return the widget to build.
/// 2- with methods `desktop`, `tablet`,`phone`, `watch`. the specific
/// method will be built when the screen type matches the method
/// when the screen is [ScreenType.Tablet] the `tablet` method
/// will be exuded and so on.
/// Note if you use this method please set the
/// property `alwaysUseBuilder` to false
/// With `settings` property you can set the width limit for the screen types.
class
GetResponsiveView
<
T
>
extends
GetView
<
T
>
with
GetResponsiveMixin
{
@override
final
bool
alwaysUseBuilder
;
@override
final
ResponsiveScreen
screen
;
GetResponsiveView
({
this
.
alwaysUseBuilder
=
false
,
ResponsiveScreenSettings
settings
=
const
ResponsiveScreenSettings
(),
Key
?
key
,
})
:
screen
=
ResponsiveScreen
(
settings
),
super
(
key:
key
);
}
class
GetResponsiveWidget
<
T
extends
GetLifeCycleBase
?>
extends
GetWidget
<
T
>
with
GetResponsiveMixin
{
@override
final
bool
alwaysUseBuilder
;
@override
final
ResponsiveScreen
screen
;
GetResponsiveWidget
({
this
.
alwaysUseBuilder
=
false
,
ResponsiveScreenSettings
settings
=
const
ResponsiveScreenSettings
(),
Key
?
key
,
})
:
screen
=
ResponsiveScreen
(
settings
),
super
(
key:
key
);
}
class
ResponsiveScreenSettings
{
/// When the width is greater als this value
/// the display will be set as [ScreenType.Desktop]
...
...
Please
register
or
login
to post a comment