fix force close

This commit is contained in:
efrilm 2025-10-07 21:49:15 +07:00
parent 455a6afd70
commit 613b216c04
5 changed files with 76 additions and 58 deletions

View File

@ -117,4 +117,14 @@ class CategoryModel {
'updated_at': updatedAt.toIso8601String(),
};
}
factory CategoryModel.all() => CategoryModel(
id: 'all',
organizationId: '',
name: 'Semua',
businessType: 'restaurant',
metadata: {},
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
}

View File

@ -65,6 +65,8 @@ class CategoryLoaderBloc
log('✅ Categories loaded: ${categories.length}, hasReachedMax: $hasReachedMax');
categories.insert(0, CategoryModel.all());
emit(CategoryLoaderState.loaded(
categories: categories,
hasReachedMax: hasReachedMax,

View File

@ -49,48 +49,45 @@ class _CategoryTabBarState extends State<CategoryTabBar>
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: widget.categories.length,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Material(
elevation: 0,
color: Colors.white,
borderOnForeground: false,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: TabBar(
controller: _tabController,
isScrollable: true,
tabAlignment: TabAlignment.start,
labelColor: AppColors.primary,
labelStyle: TextStyle(
fontWeight: FontWeight.bold,
),
dividerColor: AppColors.primary,
unselectedLabelColor: AppColors.primary,
indicatorSize: TabBarIndicatorSize.label,
indicatorWeight: 4,
indicatorColor: AppColors.primary,
tabs: widget.categories
.map((category) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Tab(text: category.name),
))
.toList(),
),
),
),
Expanded(
// ini bagian penting
child: TabBarView(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Material(
elevation: 0,
color: Colors.white,
borderOnForeground: false,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: TabBar(
controller: _tabController,
children: widget.tabViews,
isScrollable: true,
tabAlignment: TabAlignment.start,
labelColor: AppColors.primary,
labelStyle: TextStyle(
fontWeight: FontWeight.bold,
),
dividerColor: AppColors.primary,
unselectedLabelColor: AppColors.primary,
indicatorSize: TabBarIndicatorSize.label,
indicatorWeight: 4,
indicatorColor: AppColors.primary,
tabs: widget.categories
.map((category) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Tab(text: category.name),
))
.toList(),
),
),
],
),
),
Expanded(
// ini bagian penting
child: TabBarView(
controller: _tabController,
children: widget.tabViews,
),
),
],
);
}
}

View File

@ -1,6 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:enaklo_pos/core/extensions/int_ext.dart';
import 'package:enaklo_pos/presentation/home/dialog/variant_dialog.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:enaklo_pos/core/constants/variables.dart';
@ -54,26 +55,34 @@ class ProductCard extends StatelessWidget {
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
child: CachedNetworkImage(
imageUrl: (data.imageUrl ?? "").contains('http')
? data.imageUrl!
: '${Variables.baseUrl}/${data.imageUrl}',
fit: BoxFit.cover,
width: double.infinity,
height: 120,
memCacheHeight: 120,
memCacheWidth: 120,
errorWidget: (context, url, error) => Container(
imageUrl: (data.imageUrl ?? "").contains('http')
? data.imageUrl!
: '${Variables.baseUrl}/${data.imageUrl}',
fit: BoxFit.cover,
width: double.infinity,
height: 120,
decoration: BoxDecoration(
color: AppColors.disabled.withOpacity(0.4),
),
child: const Icon(
Icons.image,
color: AppColors.grey,
),
),
),
memCacheHeight: 120,
memCacheWidth: 120,
errorWidget: (context, url, error) {
FirebaseCrashlytics.instance.recordError(
error,
StackTrace.current,
reason:
'Failed to load image from: $url, productId: ${data.id}, productName: ${data.name}',
fatal: false,
);
return Container(
width: double.infinity,
height: 120,
decoration: BoxDecoration(
color: AppColors.disabled.withOpacity(0.4),
),
child: const Icon(
Icons.image,
color: AppColors.grey,
),
);
}),
),
const Spacer(),
Text(

View File

@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.1+4
version: 1.0.2+4
environment:
sdk: ">=3.2.4 <4.0.0"