refactor: example app, docs: added gif
This commit is contained in:
parent
1f9bd54c4f
commit
9d2863089f
|
@ -1,3 +1,7 @@
|
|||
## 1.0.2
|
||||
|
||||
- Updated documentation and fixed some minor bugs
|
||||
|
||||
## 1.0.1
|
||||
|
||||
- Released `v1.0.1`
|
||||
|
|
|
@ -4,8 +4,7 @@ A lightweight flutter package to linkify texts containing urls, emails and hasht
|
|||
|
||||
[](https://pub.dev/packages/linkfy_text)
|
||||
|
||||
<!-- 
|
||||
-->
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -45,11 +44,11 @@ Container(
|
|||
```
|
||||
|
||||
| Parameters | Default | Description |
|
||||
| ----------- | -------------- | ------------------------------------------------------------------------------- |
|
||||
| ----------- | -------------- | ------------------------------------------------------------------------------------------------------------ |
|
||||
| `textStyle` | `null` | Style applied to the text |
|
||||
| `linkStyle` | `null` | Style applied to the linkified text, defaults to the textStyle |
|
||||
| `linkTypes` | `LinkType.url` | A list of `LinkTypes` to be linkified in the text either a hashtag,email or url |
|
||||
| `onTap` | `null` | function with a `Link` paramater called when a link is pressed |
|
||||
| `linkTypes` | `LinkType.url` | A list of `LinkTypes` used to override the links to be linkified in the text either a hashtag, email or url. |
|
||||
| `onTap` | `null` | Callback function with a `Link` paramater called when a link is pressed |
|
||||
|
||||
# Contributions
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "Generated.xcconfig"
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "Generated.xcconfig"
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Uncomment this line to define a global platform for your project
|
||||
# platform :ios, '9.0'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
||||
project 'Runner', {
|
||||
'Debug' => :debug,
|
||||
'Profile' => :release,
|
||||
'Release' => :release,
|
||||
}
|
||||
|
||||
def flutter_root
|
||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
|
||||
unless File.exist?(generated_xcode_build_settings_path)
|
||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
|
||||
end
|
||||
|
||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
||||
return matches[1].strip if matches
|
||||
end
|
||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
|
||||
end
|
||||
|
||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
||||
|
||||
flutter_ios_podfile_setup
|
||||
|
||||
target 'Runner' do
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
flutter_additional_ios_build_settings(target)
|
||||
end
|
||||
end
|
|
@ -1,17 +1,19 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:linkfy_text/linkfy_text.dart';
|
||||
|
||||
var scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
void main() {
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
var _msgKey = GlobalKey<ScaffoldMessengerState>();
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'linkify_text Demo',
|
||||
scaffoldMessengerKey: scaffoldMessengerKey,
|
||||
scaffoldMessengerKey: _msgKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: App(),
|
||||
);
|
||||
|
@ -24,13 +26,36 @@ class App extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _AppState extends State<App> {
|
||||
void showSnackbar(String msg) {
|
||||
scaffoldMessengerKey.currentState!.removeCurrentSnackBar();
|
||||
scaffoldMessengerKey.currentState!
|
||||
.showSnackBar(SnackBar(content: Text("$msg")));
|
||||
}
|
||||
final _textStyle =
|
||||
GoogleFonts.jetBrainsMono(fontSize: 14, fontWeight: FontWeight.w500);
|
||||
|
||||
final space = SizedBox(height: 8);
|
||||
final List<Map<String, dynamic?>> _texts = [
|
||||
{
|
||||
"text": "O1. This text contains a url: https://flutter.dev",
|
||||
"types": null
|
||||
},
|
||||
{
|
||||
"text": "O2. This text contains an email address: example@app.com",
|
||||
"types": [LinkType.email]
|
||||
},
|
||||
{
|
||||
"text": "O3. This text contains an #hashtag",
|
||||
"types": [LinkType.hashTag]
|
||||
},
|
||||
{
|
||||
"text":
|
||||
"O4. This text contains a url: https://flutter.dev, An email example@app.com and #hashtag",
|
||||
"types": [LinkType.email, LinkType.url, LinkType.hashTag]
|
||||
},
|
||||
];
|
||||
|
||||
void showSnackbar(String msg) {
|
||||
_msgKey.currentState!.removeCurrentSnackBar();
|
||||
_msgKey.currentState!.showSnackBar(SnackBar(
|
||||
content: Text("$msg", style: _textStyle),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -42,42 +67,24 @@ class _AppState extends State<App> {
|
|||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
"LinkifyText",
|
||||
style: _textStyle.copyWith(
|
||||
fontSize: 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
for (var i = 0; i < _texts.length; i++)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: LinkifyText(
|
||||
"01. This text contains a url: https://flutter.dev",
|
||||
linkStyle: TextStyle(color: Colors.blue, fontSize: 16),
|
||||
onTap: (link) {
|
||||
showSnackbar(link.value!);
|
||||
},
|
||||
)),
|
||||
space,
|
||||
Center(
|
||||
child: LinkifyText(
|
||||
"02. This text contains an email hello@flutter.dev",
|
||||
linkTypes: [LinkType.email],
|
||||
linkStyle: TextStyle(color: Colors.blue, fontSize: 16),
|
||||
onTap: (link) {
|
||||
showSnackbar(link.value!);
|
||||
},
|
||||
)),
|
||||
space,
|
||||
Center(
|
||||
child: LinkifyText(
|
||||
"03. This contains an #hashtag",
|
||||
linkTypes: [LinkType.hashTag],
|
||||
linkStyle: TextStyle(color: Colors.blue, fontSize: 16),
|
||||
onTap: (link) {
|
||||
showSnackbar(link.value!);
|
||||
},
|
||||
)),
|
||||
space,
|
||||
Center(
|
||||
child: LinkifyText(
|
||||
"04. Flutter is #trending, goto https://flutter.dev to check it out. hey@pub.dev",
|
||||
_texts[i]['text'],
|
||||
textAlign: TextAlign.center,
|
||||
linkTypes: [LinkType.hashTag, LinkType.url, LinkType.email],
|
||||
linkStyle: TextStyle(color: Colors.blue, fontSize: 16),
|
||||
linkTypes: _texts[i]['types'],
|
||||
textStyle: _textStyle,
|
||||
linkStyle: _textStyle.copyWith(color: Colors.blue),
|
||||
onTap: (link) {
|
||||
showSnackbar(link.value!);
|
||||
showSnackbar("link tapped: ${link.value!}");
|
||||
},
|
||||
)),
|
||||
],
|
||||
|
|
|
@ -43,6 +43,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -57,6 +64,20 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
@ -67,13 +88,34 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
google_fonts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_fonts
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.13.3"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
linkfy_text:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.1"
|
||||
version: "1.0.2"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -95,6 +137,69 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
path_provider_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.11.0"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.2.1"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -156,6 +261,20 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
sdks:
|
||||
dart: ">=2.12.0 <3.0.0"
|
||||
flutter: ">=1.17.0"
|
||||
flutter: ">=1.20.0"
|
||||
|
|
|
@ -23,6 +23,7 @@ environment:
|
|||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
google_fonts: ^2.1.0
|
||||
linkfy_text:
|
||||
path: ../
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 936 KiB |
|
@ -180,7 +180,7 @@ TextSpan _linkify({
|
|||
style: linkStyle,
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
onTap!(link);
|
||||
if (onTap != null) onTap(link);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
name: linkfy_text
|
||||
description: A lightweight flutter package to linkify texts containing urls, emails and hashtags.
|
||||
version: 1.0.1
|
||||
version: 1.0.2
|
||||
homepage: https://github.com/Iamstanlee/linkfy_text
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
flutter: ">=1.17.0"
|
||||
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in New Issue