Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelogs

## 0.2.14 - 3-January-2024

* Upgrade markdown: ^7.1.1
* Upgrade flutter_markdown: ^0.6.18+2

## 0.2.13 - 10-July-2022

* Added shortcut Ctrl+B: Bold text
Expand Down
8 changes: 4 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void main() {
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -18,7 +18,7 @@ class MyApp extends StatelessWidget {
}

class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
const HomeScreen({super.key});

@override
State<HomeScreen> createState() => _HomeScreenState();
Expand All @@ -31,9 +31,9 @@ class _HomeScreenState extends State<HomeScreen> {
appBar: AppBar(
title: const Text("Home Screen"),
),
body: Column(
body: const Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
children: [
MarkdownAutoPreview(
decoration: InputDecoration(
hintText: 'Markdown Auto Preview',
Expand Down
139 changes: 82 additions & 57 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,66 @@ packages:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.4.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.8.2"
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.3.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.16.0"
version: "1.18.0"
expandable:
dependency: transitive
description:
name: expandable
url: "https://pub.dartlang.org"
sha256: "9604d612d4d1146dafa96c6d8eec9c2ff0994658d6d09fed720ab788c7f5afc2"
url: "https://pub.dev"
source: hosted
version: "5.0.1"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -73,16 +74,18 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.1"
flutter_markdown:
dependency: transitive
description:
name: flutter_markdown
url: "https://pub.dartlang.org"
sha256: "35108526a233cc0755664d445f8a6b4b61e6f8fe993b3658b80b4a26827fc196"
url: "https://pub.dev"
source: hosted
version: "0.6.12"
version: "0.6.18+2"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -92,58 +95,65 @@ packages:
dependency: transitive
description:
name: font_awesome_flutter
url: "https://pub.dartlang.org"
sha256: "52671aea66da73b58d42ec6d0912b727a42248dd9a7c76d6c20f275783c48c08"
url: "https://pub.dev"
source: hosted
version: "10.2.1"
version: "10.6.0"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "2.0.0"
version: "3.0.0"
markdown:
dependency: transitive
description:
name: markdown
url: "https://pub.dartlang.org"
sha256: acf35edccc0463a9d7384e437c015a3535772e09714cf60e07eeef3a15870dcd
url: "https://pub.dev"
source: hosted
version: "6.0.0"
version: "7.1.1"
markdown_editor_plus:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.2.13"
version: "0.2.14"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.11"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.1.4"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.7.0"
version: "1.10.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.1"
version: "1.8.3"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -153,51 +163,66 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.8.2"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.4.9"
version: "0.6.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.3.0"
sdks:
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.10.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
flutter_lints: ^3.0.1

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
23 changes: 8 additions & 15 deletions lib/src/emoji_parser.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'dart:convert';

import 'package:flutter/material.dart';

///
/// Constants defined for Emoji.
///
Expand All @@ -24,8 +22,7 @@ class EmojiUtil {
/// Strip colons for emoji name.
/// So, ':heart:' will become 'heart'.
///
static String stripColons(String name,
[void Function(String message)? onError]) {
static String stripColons(String name, [void Function(String message)? onError]) {
Iterable<Match> matches = EmojiParser.regexName.allMatches(name);
if (matches.isEmpty) {
if (onError != null) {
Expand Down Expand Up @@ -57,8 +54,7 @@ class EmojiUtil {
/// When processing emojis, we don't need to store the graphical byte
/// which is 0xfe0f, or so-called 'Non-Spacing Mark'.
///
static String stripNSM(String name) => name.replaceAll(
RegExp(EmojiConst.charNonSpacingMark), EmojiConst.charEmpty);
static String stripNSM(String name) => name.replaceAll(RegExp(EmojiConst.charNonSpacingMark), EmojiConst.charEmpty);
}

///
Expand Down Expand Up @@ -93,7 +89,7 @@ class Emoji {
}

@override
int get hashCode => hashValues(name.hashCode, code.hashCode);
int get hashCode => Object.hash(name.hashCode, code.hashCode);

Emoji clone() {
return Emoji(name, code);
Expand All @@ -119,8 +115,8 @@ class EmojiParser {
// r'(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*');

/// A tweak regexp to pass all Emoji Unicode 11.0
static final RegExp regexEmoji = RegExp(
r'(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])');
static final RegExp regexEmoji =
RegExp(r'(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])');

static final RegExp regexName = RegExp(r":([\w-+]+):");

Expand All @@ -143,12 +139,10 @@ class EmojiParser {
});
}

Emoji get(String name) =>
_emojisByName[EmojiUtil.stripColons(name)] ?? Emoji.none;
Emoji get(String name) => _emojisByName[EmojiUtil.stripColons(name)] ?? Emoji.none;

Emoji getName(String name) => get(name);
bool hasName(String name) =>
_emojisByName.containsKey(EmojiUtil.stripColons(name));
bool hasName(String name) => _emojisByName.containsKey(EmojiUtil.stripColons(name));

///
/// Get info for an emoji.
Expand Down Expand Up @@ -224,8 +218,7 @@ class EmojiParser {
result = result.replaceAll(m0, getEmoji(m0).full);

/// Just a quick hack to clear graphical byte from emoji.
result = result.replaceAll(
EmojiConst.charNonSpacingMark, EmojiConst.charEmpty);
result = result.replaceAll(EmojiConst.charNonSpacingMark, EmojiConst.charEmpty);
}
}
});
Expand Down
Loading