Files
flutter_wisetronic/lib/widgets/general/text_link.dart
2020-12-23 00:43:59 -05:00

58 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:url_launcher/url_launcher.dart';
class TextLink extends StatelessWidget {
final String title;
final String url;
final Color color;
final double paddingHorizontal;
final double paddingVertical;
final FontWeight fontWeight;
final bool selected;
TextLink(this.title, this.url, {
this.color,
this.paddingHorizontal,
this.paddingVertical,
this.fontWeight,
this.selected
});
@override
Widget build(BuildContext context) {
return MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
child: Container(
padding: EdgeInsets.symmetric(
vertical: paddingVertical ?? 0.0,
horizontal: paddingHorizontal ?? 0.0
),
child: Text(
title,
style: TextStyle(
color: color ?? Colors.blue,
fontWeight: fontWeight ?? FontWeight.normal,
),
),
decoration: BoxDecoration(
border: (selected != null && selected) ? Border(
bottom: BorderSide(
color: color ?? Colors.blue,
width: 3.0,
)
) : null,
),
),
onTap: () async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
),
);
}
}