41 lines
894 B
Dart
41 lines
894 B
Dart
import 'dart:io';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ImageWrapper extends StatelessWidget {
|
|
final String title;
|
|
final String? path;
|
|
final VoidCallback onTap;
|
|
|
|
const ImageWrapper({
|
|
super.key,
|
|
required this.title,
|
|
required this.onTap,
|
|
this.path,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget widget;
|
|
if (path == null) {
|
|
widget = SizedBox(
|
|
width: 45,
|
|
height: 45,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Center(child: Text(title[0])),
|
|
),
|
|
);
|
|
} else {
|
|
widget = ClipRRect(
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Image.file(File(path!), width: 45, height: 45),
|
|
);
|
|
}
|
|
|
|
return InkWell(onTap: onTap, child: widget);
|
|
}
|
|
}
|