Skip to content

Instantly share code, notes, and snippets.

@jianastrero
Created November 26, 2019 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianastrero/f9a633762a24534e0a9de82604601da5 to your computer and use it in GitHub Desktop.
Save jianastrero/f9a633762a24534e0a9de82604601da5 to your computer and use it in GitHub Desktop.
view orientation sample for flutter
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