Created
November 26, 2019 06:10
-
-
Save jianastrero/f9a633762a24534e0a9de82604601da5 to your computer and use it in GitHub Desktop.
view orientation sample for flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
} | |
abstract class BaseView { | |
portrait(); | |
landscape(); | |
handleViewRendering( | |
Context context, | |
Function() onPortrait, | |
Function() onLandscape | |
) { | |
if (isPortrait) { | |
portrait(); | |
onPortrait(); | |
} else { | |
// landscape | |
landscape(); | |
onLandscape(); | |
} | |
} | |
} | |
class MainView extends BaseView { | |
@override | |
portrait() { | |
// ilagay yung UI dito, yung panget na mukhang json | |
} | |
@override | |
landscape() { | |
// ilagay yung UI dito, yung panget na mukhang json | |
} | |
} | |
class MyWidget extends WidgetSomething { | |
final view = MainView(); | |
build(Context context) { | |
view.handleViewRendering( | |
context, | |
() => { | |
// is called when screen is portrait | |
}, | |
() => { | |
// is called when screen is landscape | |
} | |
); | |
} | |
} | |
/** | |
* | |
* -root | |
* --views | |
* --widgets | |
* --services | |
* --repositories | |
* --models | |
* --dao | |
* --api | |
* | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment