首页 > 解决方案 > 我们如何使用颤振在firebase中添加表情符号

问题描述

我正在寻找一种方法,用户可以将键盘的表情符号存储到 firebasefirestore 中是否有你们向我推荐的库或功能。

标签: androidfirebaseflutterdart

解决方案


表情符号在技术上只是带有特定代码的 unicode 字符,您可以在此处找到完整的代码列表。您可以将这些 un​​icode 值保存在 FirebaseFirestore 上,您不需要任何库,flutter 开箱即用!

您可以稍后获取这些 un​​icode 并使用文本类在 Flutter 上渲染它们,方法是传递\u和大括号中的 4 个字母十六进制,{}如下所示:

Text("This is how you render unicode: \u{1f60e} ")

下面是一个示例实现:

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());


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

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: const Center(
          child: Text("This is how you render unicode: \u{1f60e} "), // This is the main part.
        ),
      ),
    );
  }
}

推荐阅读