Created
August 8, 2020 15:56
-
-
Save Nipodemos/88a1e009e25b50c66eb1001749ba8fae to your computer and use it in GitHub Desktop.
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'; | |
| class ColorBackGroundView extends GetView<ColorBackgroundController> { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Container( | |
| child: Center( | |
| child: Column( | |
| children: [ | |
| Obx( | |
| () => Container( | |
| width: 100, | |
| height: 100, | |
| color: controller.color.value, | |
| ), | |
| ), | |
| RaisedButton( | |
| onPressed: () { | |
| controller.color.value = Color(0xFFFF9000); | |
| }, | |
| child: Text('change to orange'), | |
| ), | |
| RaisedButton( | |
| onPressed: () { | |
| controller.color.value = Color(0xFF459000); | |
| }, | |
| child: Text('change to green'), | |
| ), | |
| RaisedButton( | |
| onPressed: () { | |
| controller.color.value = Color(0xFFFF1000); | |
| }, | |
| child: Text('change to red'), | |
| ), | |
| ], | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
| class ColorBackgroundController extends GetxController { | |
| Rx<Color> color = Color(0xFF42A5F5).obs; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment