forked from Cretezy/flutter_linkify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
60 lines (56 loc) · 1.74 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import 'package:flutter/material.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:linkify/linkify.dart';
import 'dart:async';
import 'package:url_launcher/url_launcher.dart';
void main() => runApp(LinkifyExample());
class LinkifyExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'flutter_linkify example',
home: Scaffold(
appBar: AppBar(
title: Text('flutter_linkify example'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Center(
child: Column(
children: [
Linkify(
onOpen: _onOpen,
text:
"Made by https://cretezy.com\n\nMail: [email protected]",
),
SizedBox(height: 64),
SelectableLinkify(
onOpen: _onOpen,
text:
"Made by https://cretezy.com\n\nMail: [email protected]",
),
SizedBox(height: 64),
Linkify(
onOpen: print,
text: "@Cretezy +123456789",
linkifiers: [
const UserTagLinkifier(),
const PhoneNumberLinkifier(),
],
),
],
),
),
],
),
),
);
}
Future<void> _onOpen(LinkableElement link) async {
if (!await launchUrl(Uri.parse(link.url))) {
throw Exception('Could not launch ${link.url}');
}
}
}