Skip to content

Instantly share code, notes, and snippets.

@Nipodemos
Created August 8, 2020 15:56
Show Gist options
  • Select an option

  • Save Nipodemos/88a1e009e25b50c66eb1001749ba8fae to your computer and use it in GitHub Desktop.

Select an option

Save Nipodemos/88a1e009e25b50c66eb1001749ba8fae to your computer and use it in GitHub Desktop.
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