Commit 6f88931d authored by Nguyễn Thành Tâm's avatar Nguyễn Thành Tâm

Merge branch 'dev/tam_nguyen' into 'develop'

ntt update

See merge request !1
parents 71954c96 dfe2dc6d
import 'package:betting/view/mobile/test_controller.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:get/get.dart';
class Test extends GetWidget<TestControler>{
final controller = Get.put(TestControler());
@override
Widget build(BuildContext context) {
return
Column(
children: [
Obx(() => ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: controller.ischeckall.value ==true ? Colors.green : Colors.red
),
onPressed: (){
controller.ischeckall.value =! controller.ischeckall.value;
if( controller.ischeckall.value== true){
for(int i = 0; i< controller.ischecklist.length; i++){
controller.ischecklist[i] = true;
controller.indexx.value = controller.ischecklist.length;
}
print(controller.ischecklist);
}else{
for(int i = 0; i< controller.ischecklist.length; i++){
controller.ischecklist[i] = false;
controller.indexx.value = 0;
}
}
},
child: Text('text'))),
Obx(() => ListView.builder(
shrinkWrap: true,
itemCount: controller.list.length,
itemBuilder: (context, index) {
return Row(
children: [
Obx(() => ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: controller.ischecklist[index] == false ? Colors.red: Colors.green
),
onPressed: (){
controller.ischecklist[index] =! controller.ischecklist[index];
if(controller.ischecklist[index] == true){
controller.indexx.value ++;
print( controller.indexx.value);
}
if(controller.indexx.value == controller.ischecklist.length){
controller.ischeckall.value = true;
}
if( controller.ischeckall.value == true){
if(controller.ischecklist[index] == false){
controller.indexx.value --;
print( controller.indexx.value);
controller.ischeckall.value = false;
}
}else{
if(controller.ischecklist[index] == false){
controller.indexx.value --;
print( controller.indexx.value);
}
}
},
child: Text('list ${controller.list[index]}'))),
Text('${controller.list[index]}')
],
);
},))
],
);
}
}
\ No newline at end of file
import 'package:get/get.dart';
class TestControler extends GetxController{
@override
void onInit() async {
super.onInit();
check();
}
RxList<String> list = [
"1", "2", "3"
].obs;
var indexx = 0.obs;
RxList ischecklist =[].obs;
var ischeckall= false.obs;
check(){
for(int i = 0 ; i< list.length; i++){
ischecklist.add(false);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment