2023-04-03 23:48:56 -05:00
|
|
|
import 'package:flutter/material.dart';
|
2021-09-05 18:02:49 +08:00
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
2023-03-29 20:44:37 -05:00
|
|
|
/// For icon that needs to change color when it is on hovered
|
|
|
|
///
|
|
|
|
/// Get the hover color from ThemeData
|
|
|
|
class FlowySvg extends StatelessWidget {
|
|
|
|
const FlowySvg({super.key, this.size, required this.name});
|
|
|
|
final String name;
|
|
|
|
final Size? size;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-04-05 10:36:50 -10:00
|
|
|
return svgWidget(
|
2023-04-05 17:39:29 -05:00
|
|
|
name,
|
2023-04-05 10:36:50 -10:00
|
|
|
size: size,
|
|
|
|
color: Theme.of(context).iconTheme.color,
|
|
|
|
);
|
2023-03-29 20:44:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-28 15:34:55 +08:00
|
|
|
Widget svgWidget(String name, {Size? size, Color? color}) {
|
|
|
|
if (size != null) {
|
|
|
|
return SizedBox.fromSize(
|
|
|
|
size: size,
|
2023-04-03 23:48:56 -05:00
|
|
|
child: SvgPicture.asset(
|
|
|
|
'assets/images/$name.svg',
|
|
|
|
colorFilter:
|
|
|
|
color != null ? ColorFilter.mode(color, BlendMode.srcIn) : null,
|
|
|
|
),
|
2022-11-28 15:34:55 +08:00
|
|
|
);
|
|
|
|
} else {
|
2023-04-03 23:48:56 -05:00
|
|
|
return SvgPicture.asset(
|
|
|
|
'assets/images/$name.svg',
|
|
|
|
colorFilter:
|
|
|
|
color != null ? ColorFilter.mode(color, BlendMode.srcIn) : null,
|
|
|
|
);
|
2022-11-28 15:34:55 +08:00
|
|
|
}
|
|
|
|
}
|