GardenPlanner/lib/widgets/content_widgets/dashboard_widgets/plant_drop.dart

50 lines
1.3 KiB
Dart
Raw Normal View History

2023-06-25 10:13:39 +02:00
import 'package:flutter/material.dart';
import '../../../../entities/plant.dart';
class PlantDrop extends StatelessWidget {
final Function(Plant) onPlantDropped;
final bool showSpaceRequirement;
const PlantDrop({
Key? key,
required this.onPlantDropped,
required this.showSpaceRequirement,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return DragTarget<Plant>(
onAccept: (droppedItem) {
onPlantDropped(droppedItem);
},
builder: (context, candidateData, rejectedData) {
return Container(
margin: const EdgeInsets.all(0),
height: showSpaceRequirement ? 100 : 100,
width: 100,
decoration: BoxDecoration(
color: Colors.brown,
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'lib/assets/layout/planting-64-white.png',
),
const Expanded(
child: Text('Pflanzen',
style: TextStyle(
color: Colors.white,
)),
),
],
),
);
},
);
}
}