Last active
July 31, 2020 19:28
-
-
Save fer-ri/b6959da15106fbbb14588fbc41e3afaf to your computer and use it in GitHub Desktop.
GetX Debug Template
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
import 'package:get/get.dart'; | |
void main() => runApp(App()); | |
class App extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return GetMaterialApp( | |
initialRoute: '/', | |
getPages: [ | |
GetPage(name: '/', page: () => FirstScreen(), binding: FirstBinding()), | |
GetPage( | |
name: '/second', | |
page: () => SecondScreen(), | |
binding: SecondBinding()), | |
], | |
); | |
} | |
} | |
class FirstBinding implements Bindings { | |
@override | |
void dependencies() { | |
Get.lazyPut<FirstController>(() => FirstController()); | |
} | |
} | |
class SecondBinding implements Bindings { | |
@override | |
void dependencies() { | |
Get.lazyPut<SecondController>(() => SecondController()); | |
} | |
} | |
class FirstController extends GetxController { | |
} | |
class SecondController extends GetxController { | |
} | |
class FirstScreen extends GetView<FirstController> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
FlatButton( | |
onPressed: () { | |
Get.toNamed('/second'); | |
}, | |
child: Text('Go to second'), | |
), | |
], | |
), | |
), | |
); | |
} | |
} | |
class SecondScreen extends GetView<SecondController> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
FlatButton( | |
onPressed: () { | |
Get.back(); | |
}, | |
child: Text('Go back to first'), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment