diff --git a/example/lib/main.dart b/example/lib/main.dart index 1453380..b7300be 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -114,7 +114,7 @@ class MyAppState extends State { emojiSizeMax: 28 * (foundation.defaultTargetPlatform == TargetPlatform.iOS - ? 1.30 + ? 1.2 : 1.0), ), swapCategoryAndBottomBar: false, diff --git a/example/lib/main_custom_font.dart b/example/lib/main_custom_font.dart index 98204db..8139436 100644 --- a/example/lib/main_custom_font.dart +++ b/example/lib/main_custom_font.dart @@ -30,7 +30,7 @@ class MyAppState extends State { ); // 2. Use EmojiTextEditingController - _controller = EmojiTextEditingController(emojiStyle: _textStyle); + _controller = EmojiTextEditingController(emojiTextStyle: _textStyle); super.initState(); } @@ -129,7 +129,7 @@ class MyAppState extends State { emojiSizeMax: _fontSize * (foundation.defaultTargetPlatform == TargetPlatform.iOS - ? 1.30 + ? 1.2 : 1.0), ), swapCategoryAndBottomBar: false, diff --git a/example/lib/main_whatsapp.dart b/example/lib/main_whatsapp.dart index 2db8f02..010109a 100644 --- a/example/lib/main_whatsapp.dart +++ b/example/lib/main_whatsapp.dart @@ -2,6 +2,7 @@ import 'package:emoji_picker_flutter/emoji_picker_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:flutter/foundation.dart' as foundation; const accentColor = Color(0xFF4BA586); const accentColorDark = Color(0xFF377E6A); @@ -26,18 +27,20 @@ class MyAppState extends State { late final ScrollController _scrollController; late final FocusNode _focusNode; late final TextStyle _textStyle; + final bool isApple = [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(foundation.defaultTargetPlatform); bool _emojiShowing = false; - final _fontSize = 24.0; @override void initState() { + final fontSize = 24 * (isApple ? 1.2 : 1.0); // Define Custom Emoji Font & Text Style _textStyle = emojiTextStyle.copyWith( - fontFamily: GoogleFonts.notoColorEmoji().fontFamily, - fontSize: _fontSize, + fontFamily: isApple ? null : GoogleFonts.notoColorEmoji().fontFamily, + fontSize: fontSize, ); - _controller = EmojiTextEditingController(emojiStyle: _textStyle); + _controller = EmojiTextEditingController(emojiTextStyle: _textStyle); _scrollController = ScrollController(); _focusNode = FocusNode(); @@ -179,8 +182,7 @@ class MyAppState extends State { height: 256, checkPlatformCompatibility: true, emojiTextStyle: _textStyle, - emojiViewConfig: EmojiViewConfig( - emojiSizeMax: _fontSize, + emojiViewConfig: const EmojiViewConfig( backgroundColor: Colors.white, ), swapCategoryAndBottomBar: true, diff --git a/lib/src/emoji_text_editing_controller.dart b/lib/src/emoji_text_editing_controller.dart index 3b722aa..62f04d2 100644 --- a/lib/src/emoji_text_editing_controller.dart +++ b/lib/src/emoji_text_editing_controller.dart @@ -8,14 +8,14 @@ const delimiter = '|'; /// a particular style to emoji characters. class EmojiTextEditingController extends TextEditingController { /// Constructor, requres emojiStyle, since otherwise this class has no effect - EmojiTextEditingController({String? text, required this.emojiStyle}) + EmojiTextEditingController({String? text, required this.emojiTextStyle}) : super(text: text) { final utils = EmojiPickerUtils(); _regex = utils.getEmojiRegex(); } /// The style used for the emoji characters - final TextStyle emojiStyle; + final TextStyle emojiTextStyle; /// Cached Regex for emoji late final RegExp _regex; @@ -46,7 +46,7 @@ class EmojiTextEditingController extends TextEditingController { _addTextSpan( textSpanChildren, textPart, - style?.merge(emojiStyle), + style?.merge(emojiTextStyle), ); return ''; diff --git a/lib/src/emoji_text_style.dart b/lib/src/emoji_text_style.dart index f86b365..db05518 100644 --- a/lib/src/emoji_text_style.dart +++ b/lib/src/emoji_text_style.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; /// Emoji text style providing commonly available fallback fonts final emojiTextStyle = const TextStyle( + inherit: true, // Commonly available fallback fonts. fontFamilyFallback: [ // iOS and MacOs.