twemoji 0.4.3 copy "twemoji: ^0.4.3" to clipboard
twemoji: ^0.4.3 copied to clipboard

Twitter Emojis for Flutter, this package supports svg and png 72x72 emojis

example/lib/main.dart

import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:twemoji/twemoji.dart';

void main() {
  runApp(MyApp());
}

// ignore: use_key_in_widget_constructors
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const MyHomePage(),
      );
}

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

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;
  final _emojis = '☺️ πŸ• πŸ” 🌭 πŸ‘©β€πŸ³ ✈️ 0️⃣ 1️⃣ 2️⃣ 3️⃣';

  @override
  void initState() {
    super.initState();

    _controller =
        AnimationController(vsync: this, duration: const Duration(seconds: 5))
          ..repeat();
  }

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: const Text('Twemoji'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              RichText(
                text: TextSpan(
                  children: [
                     TextSpan(
                      text: '$_emojis :Device\n',
                      style: const TextStyle(
                        color: Colors.black,
                        fontSize: 20,
                      ),
                    ),
                    TwemojiTextSpan(
                      text:
                          '$_emojis :Twemoji.png\n',
                      twemojiFormat: TwemojiFormat.png,
                      style: const TextStyle(
                        color: Colors.black,
                        fontSize: 20,
                      ),
                    ),
                    TwemojiTextSpan(
                      text: '$_emojis :Twemoji.svg x 1.3\n',
                      twemojiFormat: TwemojiFormat.svg,
                      emojiFontMultiplier: 1.3,
                      style: const TextStyle(
                        color: Colors.black,
                        fontSize: 20,
                      ),
                    ),
                    TwemojiTextSpan(
                      text: '$_emojis  :Twemoji.networkSvg x 1.5\n',
                      twemojiFormat: TwemojiFormat.networkSvg,
                      emojiFontMultiplier: 1.5,
                      style: const TextStyle(
                        color: Colors.black,
                        fontSize: 20,
                      ),
                    ),
                  ],
                ),
              ),
              const TwemojiText(
                text: 'πŸ’»πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» :auto format',
                emojiFontMultiplier: 2,
              ),
              const SizedBox(height: 20),
              AnimatedBuilder(
                animation: _controller,
                builder: (context, child) => Transform.rotate(
                  angle: _controller.value * 2 * math.pi,
                  child: SizedBox(
                    height: 105,
                    width: 105,
                    child: Stack(
                      children: List.generate(
                        4,
                        (index) => Align(
                          alignment: _getAlign(index),
                          child: RotationTransition(
                            turns: AlwaysStoppedAnimation(index * 90 / 360),
                            child: const Twemoji(
                              emoji: 'πŸ•',
                              height: 50,
                              width: 50,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      );

  AlignmentGeometry _getAlign(int index) {
    switch (index) {
      case 0:
        return Alignment.topCenter;
      case 1:
        return Alignment.centerRight;
      case 2:
        return Alignment.bottomCenter;
      case 3:
        return Alignment.centerLeft;
      default:
        return Alignment.topCenter;
    }
  }
}
31
likes
140
points
203
downloads

Publisher

verified publisherhadi.wtf

Weekly Downloads

Twitter Emojis for Flutter, this package supports svg and png 72x72 emojis

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

characters, flutter, flutter_svg, io, path, yaml

More

Packages that depend on twemoji