Commit ed0874a3 authored by Amir Mohammadi's avatar Amir Mohammadi 👦🏻
Browse files

complite readme

parent d0b00f8b
## [0.0.1] - TODO: Add release date.
## [0.0.1] - Release.
* TODO: Describe initial release.
* Find Hashtag and Mention seperately and both together
# clickabletext
A new Flutter package project.
Find Hashtag and Mention seperately and both together.
This package work for both android and IOS just use it as child of richtext.
## Getting Started
This project is a starting point for a Dart
[package](https://flutter.dev/developing-packages/),
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
## Screenshot
<img src="ss1.png" height="300em" />
## Usage
To use this package just add it to pubspec.yaml and like example use it.
[Example](https://gitlab.com/Amirmhmdi/clickabletextpackage)
```yaml
dependencies:
flutter:
sdk: flutter
clickabletext:
```
### How to Use
```dart
import 'package:flutter/material.dart';
import 'package:clickabletext/clickabletext.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Make Clickable Text',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Make Clickable Text'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
TextEditingController controller = TextEditingController();
List<TextSpan> richText = List<TextSpan>();
@override
void dispose() {
controller.dispose();
super.dispose();
}
void hashtagAction() {
print("action clicked");
}
void mentionAction() {
print("mention clicked");
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
controller: controller,
style: TextStyle(),
decoration: InputDecoration(
hintText: 'Write some text with #, @ ',
),
),
RaisedButton(
child: Text("Put it Down"),
onPressed: () {
setState(() {
richText = FindSympol(controller.text)
.makeHashtagAndMention(hashtagAction, mentionAction);
});
},
),
RichText(
text: TextSpan(
text: "",
style: TextStyle(color: Colors.black),
children: richText,
),
)
],
),
),
);
}
}
```
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
......
import 'package:flutter/material.dart';
import 'package:clickabletext/clickabletext.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Make Clickable Text',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Make Clickable Text'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
TextEditingController controller = TextEditingController();
List<TextSpan> richText = List<TextSpan>();
@override
void dispose() {
controller.dispose();
super.dispose();
}
void hashtagAction() {
print("action clicked");
}
void mentionAction() {
print("mention clicked");
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
controller: controller,
style: TextStyle(),
decoration: InputDecoration(
hintText: 'Write some text with #, @ ',
),
),
RaisedButton(
child: Text("Put it Down"),
onPressed: () {
setState(() {
richText = FindSympol(controller.text)
.makeHashtagAndMention(hashtagAction, mentionAction);
});
},
),
RichText(
text: TextSpan(
text: "",
style: TextStyle(color: Colors.black),
children: richText,
),
)
],
),
),
);
}
}
name: clickabletext
description: A new Flutter package project.
description: Find Hashtag and Mention in Text and return List <TextSpan>.
version: 0.0.1
author:
homepage:
author: Amir Mohammadi <Amirmhmdi95@gmail.com>
homepage: https://gitlab.com/Amirmhmdi/clickabletextpackage
environment:
sdk: ">=2.1.0 <3.0.0"
......
ss1.png

157 KB

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment