58 lines
1.3 KiB
Dart
58 lines
1.3 KiB
Dart
import 'dart:io';
|
|
import 'package:flutter/material.dart';
|
|
|
|
const _BORDER_RADIUS = 8.0;
|
|
|
|
class ImageWrapper extends StatelessWidget {
|
|
final String title;
|
|
final String? path;
|
|
final VoidCallback? onTap;
|
|
final double width;
|
|
final double height;
|
|
|
|
const ImageWrapper({
|
|
super.key,
|
|
required this.title,
|
|
this.onTap,
|
|
this.path,
|
|
this.width = 45,
|
|
this.height = 45,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (path == null) {
|
|
return InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
|
child: SizedBox(
|
|
width: width,
|
|
height: height,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey,
|
|
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
|
),
|
|
child: Center(child: Text(title[0])),
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
return ClipRRect(
|
|
borderRadius: BorderRadius.circular(_BORDER_RADIUS),
|
|
child: Material(
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
radius: _BORDER_RADIUS,
|
|
child: Ink.image(
|
|
width: width,
|
|
height: height,
|
|
image: FileImage(File(path!)),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|