2024-05-24 14:04:26 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2024-06-12 12:48:30 +02:00
|
|
|
// Widget für eine benutzerdefinierten Button mit einem Hintergrundbild
|
2024-05-24 14:04:26 +02:00
|
|
|
class CustomImageButton extends StatelessWidget {
|
2024-06-12 12:48:30 +02:00
|
|
|
final VoidCallback onPressed; // Callback-Funktion für den Tastendruck
|
|
|
|
final Widget child; // Das Widget, das innerhalb der Schaltfläche angezeigt werden soll
|
|
|
|
final String backgroundImage; // Pfad zum Hintergrundbild
|
2024-05-24 14:04:26 +02:00
|
|
|
|
|
|
|
const CustomImageButton({
|
|
|
|
super.key,
|
|
|
|
required this.onPressed,
|
|
|
|
required this.child,
|
|
|
|
required this.backgroundImage,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: onPressed,
|
|
|
|
child: Container(
|
|
|
|
height: 150,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(5),
|
|
|
|
image: DecorationImage(
|
|
|
|
image: AssetImage(backgroundImage),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Center(
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|