Skip to content

Commit

Permalink
Merge pull request #6 from Mastersam07/main
Browse files Browse the repository at this point in the history
Chore: Add tests for flutter tagger
  • Loading branch information
Crazelu authored Jul 9, 2024
2 parents 898a77d + a28f8e5 commit 914d01c
Show file tree
Hide file tree
Showing 7 changed files with 465 additions and 16 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
flutter_version: "3.22.x"
java_version: "17.x"

jobs:
format-and-lint:
name: Linting and tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: ${{ env.java_version }}
- name: Cache Flutter dependencies
uses: actions/cache@v1
with:
path: /opt/hostedtoolcache/flutter
key: ${{ runner.OS }}-flutter-install-cache-${{ env.flutter_version }}
- uses: subosito/flutter-action@v1
with:
flutter-version: ${{ env.flutter_version }}
- name: Install dependencies
run: flutter pub get
- name: Format code
run: dart format . --set-exit-if-changed
- name: Lint analysis
run: flutter analyze --no-pub
- name: Run tests
run: flutter test --coverage
- name: Upload coverage to codecov
uses: codecov/[email protected]
with:
file: ./coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<a href="https://pub.dev/packages/fluttertagger/score"><img src="https://img.shields.io/pub/likes/fluttertagger" alt="likes"></a>
<a href="https://pub.dev/packages/fluttertagger/score"><img src="https://img.shields.io/pub/popularity/fluttertagger" alt="popularity"></a>
<a href="https://pub.dev/packages/fluttertagger/score"><img src="https://img.shields.io/pub/points/fluttertagger" alt="pub points"></a>
<a href="https://codecov.io/gh/crazelu/fluttertagger"><img src="https://codecov.io/gh/crazelu/fluttertagger/graph/badge.svg" alt="code coverage"/></a>
</p>


FlutterTagger is a Flutter package that allows for the extension of TextFields to provide tagging capabilities. A typical use case is in social apps where user mentions and hashtags features are desired.

## Install 🚀
Expand Down
1 change: 1 addition & 0 deletions example/lib/views/widgets/custom_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:linkify/linkify.dart';
import 'package:url_launcher/url_launcher.dart';

// ignore: must_be_immutable
class CustomText extends StatelessWidget {
final String text;
final double? fontSize;
Expand Down
4 changes: 2 additions & 2 deletions example/lib/views/widgets/loading_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class LoadingWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Row(
return const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
children: [
Text(
"Loading",
),
Expand Down
24 changes: 12 additions & 12 deletions lib/src/tagger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -918,16 +918,16 @@ class FlutterTaggerController extends TextEditingController {
Function? _formatTagsCallback;

/// {@template formatTags}
///Extracts tags from [FlutterTaggerController]'s [text] and formats the textfield to display them as tags.
///This should be called after [FlutterTaggerController] is constructed with a non-null
///text value that contain unformatted tags.
/// Extracts tags from [FlutterTaggerController]'s [text] and formats the textfield to display them as tags.
/// This should be called after [FlutterTaggerController] is constructed with a non-null
/// text value that contain unformatted tags.
///
///[pattern] -> Pattern to match tags.
///Specify this if you supply your own [FlutterTagger.tagTextFormatter].
/// [pattern] -> Pattern to match tags.
/// Specify this if you supply your own [FlutterTagger.tagTextFormatter].
///
///[parser] -> Parser to extract id and tag name for regex matches.
///Returned list should have this structure: `[id, tagName]`.
///{@endtemplate}
/// [parser] -> Parser to extract id and tag name for regex matches.
/// Returned list should have this structure: `[id, tagName]`.
/// {@endtemplate}
void formatTags({
RegExp? pattern,
List<String> Function(String)? parser,
Expand All @@ -952,10 +952,10 @@ class FlutterTaggerController extends TextEditingController {
parser ??= (value) {
final split = value.split("#");
if (split.length == 4) {
//default hashtag group match (tag and id)
// default hashtag group match (tag and id)
return [split[1].trim(), split[2].trim()];
}
//default user mention group match (name and id)
// default user mention group match (name and id)
final id = split.first.trim().replaceFirst("@", "");
return [id, split[split.length - 2].trim()];
};
Expand Down Expand Up @@ -1030,7 +1030,7 @@ class FlutterTaggerController extends TextEditingController {
}

/// Registers callback for clearing [FlutterTagger]'s
///internal tags state.
/// internal tags state.
void _onClear(Function callback) {
_clearCallback = callback;
}
Expand All @@ -1040,7 +1040,7 @@ class FlutterTaggerController extends TextEditingController {
_dismissOverlayCallback = callback;
}

/// Updates [_text] with updated amd formatted text from [FlutterTagger].
/// Updates [_text] with updated and formatted text from [FlutterTagger].
void _onTextChanged(String newText) {
_text = newText;
}
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies:
sdk: flutter

dev_dependencies:
flutter_lints: ^2.0.0
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0

Loading

0 comments on commit 914d01c

Please sign in to comment.