mobile-app/lib/utils/custom_button.dart

45 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
class CustomButton extends StatelessWidget {
final String buttonText;
final Widget targetScreen;
final VoidCallback? onPressed; // Optional onPressed function
const CustomButton({
super.key,
required this.buttonText,
required this.targetScreen,
this.onPressed, // Optional onPressed function
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
// Execute any additional onPressed function if provided
if (onPressed != null) {
onPressed!();
}
// Navigate to the target screen
Navigator.push(
context,
MaterialPageRoute(builder: (context) => targetScreen),
);
},
child: Container(
width: double.infinity, // Full width
height: 50, // Set height
decoration: BoxDecoration(
color: const Color(0xFF4545DB), // Button color
borderRadius: BorderRadius.circular(25), // Border radius
),
alignment: Alignment.center,
child: Text(
buttonText,
style: const TextStyle(color: Colors.white),
),
),
);
}
}