flutter_text_anchor 0.0.1 flutter_text_anchor: ^0.0.1 copied to clipboard
A flutter package that helps in creating an anchored text. Widget provides freedom to attach multiple link in a text.
import 'package:flutter/material.dart';
import 'package:flutter_text_anchor/flutter_text_anchor.dart';
void main() {
runApp(ExampleScreen());
}
class ExampleScreen extends StatelessWidget {
final GlobalKey<ScaffoldState> key = GlobalKey<ScaffoldState>();
final String text = '''
Hello, this is (Rana)[https://medium.com/@ranaranvijaysingh9].
This is my (YouTube)[https://www.youtube.com/channel/UCl7ETvRjLZsm9qXcxAKCd4w] channel.
You can find this repository here: https://github.com/RanaRanvijaySingh/flutter_text_anchor.
''';
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
key: key,
appBar: AppBar(
title: Text('Text Anchor'),
),
body: Container(
padding: EdgeInsets.all(24.0),
child: Column(
children: <Widget>[
Divider(),
Text('Simple text'),
Divider(),
Text(text),
Divider(),
Text('Text Anchor'),
Divider(),
/// Using TextAnchor widget.
TextAnchor(
text: text,
onTapLink: (link) {
key.currentState.showSnackBar(SnackBar(content: Text(link)));
},
),
],
),
),
),
);
}
}