Files
driver_tripz/lib/views/widgets/elevated_btn.dart
Hamza-Ayed 90d4ca39bf 12/18/1
2024-12-18 16:39:57 +03:00

49 lines
1.3 KiB
Dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:sefer_driver/constant/style.dart';
import 'package:flutter/services.dart';
import 'package:vibration/vibration.dart';
import '../../constant/colors.dart';
class MyElevatedButton extends StatelessWidget {
final String title;
final VoidCallback onPressed;
final Color kolor;
final int vibrateDuration;
const MyElevatedButton({
Key? key,
required this.title,
required this.onPressed,
this.kolor = AppColor.primaryColor,
this.vibrateDuration = 100,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(kolor),
),
onPressed: () async {
// Handle haptic feedback for both iOS and Android
if (Platform.isIOS) {
HapticFeedback.selectionClick();
} else {
Vibration.vibrate(duration: 100);
// Vibrate.vibrateWithPauses(pauses);
}
// Ensure the onPressed callback is called after haptic feedback
onPressed();
},
child: Text(
title,
textAlign: TextAlign.center,
style: AppStyle.title.copyWith(color: AppColor.secondaryColor),
),
);
}
}