127 lines
3.4 KiB
Dart
127 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
|
||
class FeatureTable extends StatelessWidget {
|
||
const FeatureTable({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
// Static data using a simple model
|
||
final features = [
|
||
FeatureModel('Access to attractions', true, true),
|
||
FeatureModel('Entry to attractions', true, true),
|
||
FeatureModel('Access to experiences', true, true),
|
||
FeatureModel('Entry to sites', false, true),
|
||
FeatureModel('Access to venues', true, true),
|
||
FeatureModel('Entry to events', true, true),
|
||
FeatureModel('Access to experiences', true, true),
|
||
];
|
||
|
||
return Center(
|
||
child: Padding(
|
||
padding: EdgeInsets.symmetric(horizontal: 20.w),
|
||
child: Container(
|
||
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.h),
|
||
decoration: BoxDecoration(
|
||
color: Color(0xFFF3F3F3),
|
||
borderRadius: BorderRadius.circular(16),
|
||
boxShadow: [
|
||
BoxShadow(
|
||
color: Colors.black12,
|
||
blurRadius: 1,
|
||
offset: const Offset(0, 2),
|
||
),
|
||
],
|
||
),
|
||
child: Table(
|
||
columnWidths: const {
|
||
0: FlexColumnWidth(2.5),
|
||
1: FlexColumnWidth(1.2),
|
||
2: FlexColumnWidth(1.2),
|
||
},
|
||
|
||
children: [
|
||
_buildHeaderRow(),
|
||
...features.map((f) => _buildFeatureRow(f)).toList(),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
);
|
||
|
||
}
|
||
|
||
// Header Row
|
||
TableRow _buildHeaderRow() {
|
||
return TableRow(
|
||
children: [
|
||
Padding(
|
||
padding: EdgeInsets.symmetric(vertical: 6.h),
|
||
child: Text(
|
||
'Features',
|
||
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 16.sp),
|
||
),
|
||
),
|
||
Padding(
|
||
padding: EdgeInsets.symmetric(vertical: 6.h),
|
||
child: Center(
|
||
child: Text(
|
||
'Flexi',
|
||
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 16.sp),
|
||
),
|
||
),
|
||
),
|
||
Padding(
|
||
padding: EdgeInsets.symmetric(vertical: 6.h),
|
||
child: Center(
|
||
child: Text(
|
||
'Unlimited',
|
||
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 16.sp),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
);
|
||
}
|
||
|
||
// Each Feature Row
|
||
TableRow _buildFeatureRow(FeatureModel feature) {
|
||
return TableRow(
|
||
children: [
|
||
_buildCell(feature.name),
|
||
_buildIconCell(feature.flexi),
|
||
_buildIconCell(feature.unlimited),
|
||
],
|
||
);
|
||
}
|
||
|
||
// Text cell
|
||
Widget _buildCell(String text) {
|
||
return Padding(
|
||
padding: EdgeInsets.symmetric(vertical: 6.h),
|
||
child: Text(text, style: TextStyle(fontSize: 12.sp, color: Colors.black.withOpacity(.8)),),
|
||
);
|
||
}
|
||
|
||
// Icon cell
|
||
Widget _buildIconCell(bool isAvailable) {
|
||
return Padding(
|
||
padding: EdgeInsets.symmetric(vertical: 6.h),
|
||
child: Center(
|
||
child: isAvailable
|
||
? Icon(Icons.check_circle, color: Colors.redAccent,size: 16.sp,)
|
||
: const Text('–', style: TextStyle(color: Colors.black54)),
|
||
),
|
||
);
|
||
}
|
||
}
|
||
|
||
// Model for feature row
|
||
class FeatureModel {
|
||
final String name;
|
||
final bool flexi;
|
||
final bool unlimited;
|
||
|
||
FeatureModel(this.name, this.flexi, this.unlimited);
|
||
}
|