import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:vibration/vibration.dart'; import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/colors.dart'; import 'package:SEFER/constant/style.dart'; import 'package:SEFER/main.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) { final bool vibrate = box.read(BoxName.isvibrate) ?? true; return ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: kolor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.0), ), ), onPressed: () async { if (vibrate) { if (Platform.isIOS) { HapticFeedback.selectionClick(); } else { await Vibration.vibrate(duration: vibrateDuration); } } onPressed(); }, child: Text( title, textAlign: TextAlign.center, style: AppStyle.title.copyWith(color: AppColor.secondaryColor), ), ); } }