spotube/lib/components/links/link_text.dart
2025-01-31 21:07:51 +06:00

44 lines
939 B
Dart

import 'package:auto_route/auto_route.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:spotube/components/links/anchor_button.dart';
class LinkText<T> extends StatelessWidget {
final String text;
final TextStyle style;
final TextAlign? textAlign;
final TextOverflow? overflow;
final PageRouteInfo route;
final int? maxLines;
final bool push;
const LinkText(
this.text,
this.route, {
super.key,
this.textAlign,
this.overflow,
this.style = const TextStyle(),
this.maxLines,
this.push = false,
});
@override
Widget build(BuildContext context) {
return AnchorButton(
text,
onTap: () {
if (push) {
context.pushRoute(route);
} else {
context.navigateTo(route);
}
},
key: key,
overflow: overflow,
style: style,
textAlign: textAlign,
maxLines: maxLines,
);
}
}