import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:sk_base_mobile/app_theme.dart'; import 'package:sk_base_mobile/constants/constants.dart'; import 'package:sk_base_mobile/screens/home/components/responsive.dart'; import 'package:sk_base_mobile/screens/home/components/task_detail_container.dart'; import 'package:sk_base_mobile/screens/home/home_controller.dart'; import 'package:sk_base_mobile/util/util.dart'; class TaskList extends StatelessWidget { const TaskList({super.key, required this.index}); final int index; @override Widget build(BuildContext context) { return Responsive( tablet: Grid( crossAsis: 2, ratio: 3, ind: index, ), largeTablet: Grid( crossAsis: 3, ratio: 3, ind: index, ), mobile: Grid( ratio: 3, crossAsis: 1, ind: index, )); } } class Grid extends StatelessWidget { final int crossAsis; final double ratio; final int ind; final controller = Get.put(HomeController()); Grid( {super.key, required this.crossAsis, required this.ratio, required this.ind}); @override Widget build(BuildContext context) { return Obx(() => controller.list[ind].isEmpty ? Center( child: Text( TextEnum.noInventoryInout, style: TextStyle( color: AppTheme.black, fontWeight: FontWeight.w600, letterSpacing: ScreenAdaper.width(2), fontSize: ScreenAdaper.sp(30)), ), ) : GridView.builder( padding: const EdgeInsets.only(top: 40), itemCount: controller.list[ind].length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: crossAsis, childAspectRatio: ratio), itemBuilder: (context, index) { return TaskDetailContainer( index: index, ind: ind, ); }, )); } }