p-hatan/ mirror

pub repository

mirror.p-hatan.ir

animated_text_kit

4.1.0

A flutter package project which contains a collection of cool and beautiful text animations.

Download archive

Readme

Table of contents

Installing

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  animated_text_kit: ^4.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

3. Import it

Now in your Dart code, you can use:

import 'package:animated_text_kit/animated_text_kit.dart';

Usage

AnimatedTextKit is a Stateful Widget that produces text animations. Include it in your build method like:

AnimatedTextKit(
  animatedTexts: [
    TypewriterAnimatedText(
      'Hello world!',
      textStyle: const TextStyle(
        fontSize: 32.0,
        fontWeight: FontWeight.bold,
      ),
    ),
  ],
  speed: const Duration(milliseconds: 2000),
  totalRepeatCount: 4,
  pause: const Duration(milliseconds: 1000),
  displayFullTextOnTap: true,
  stopPauseOnTap: true,
)

It has many configurable properties, including:

  • pause – the time of the pause between animation texts
  • displayFullTextOnTap – tapping the animation will rush it to completion
  • isRepeatingAnimation – controls whether the animation repeats
  • repeatForever – controls whether the animation repeats forever
  • totalRepeatCount – number of times the animation should repeat (when repeatForever is false)

There are also custom callbacks:

  • onTap – This is called when a user taps the animated text
  • onNext(int index, bool isLast) – This is called before the next text animation, after the previous one's pause
  • onNextBeforePause(int index, bool isLast) – This is called before the next text animation, before the previous one's pause
  • onFinished - This is called at the end, when the parameter isRepeatingAnimation is set to false

New with Version 3

Version 3 refactored the code so that common animation controls were moved to AnimatedTextKit and all animations, except for TextLiquidFill, extend from AnimatedText. This saved hundreds of lines of duplicate code, increased consistency across animations, and makes it easier to create new animations.

It also makes the animations more flexible because multiple animations may now be easily combined. For example:

AnimatedTextKit(
  animatedTexts: [
    FadeAnimatedText(
      'Fade First',
      textStyle: TextStyle(fontSize: 32.0, fontWeight: FontWeight.bold),
    ),
    ScaleAnimatedText(
      'Then Scale',
      textStyle: TextStyle(fontSize: 70.0, fontFamily: 'Canterbury'),
    ),
  ],
),

Using the legacy FadeAnimatedTextKit is equivalent to using AnimatedTextKit with FadeAnimatedText. An advantage of AnimatedTextKit is that the animatedTexts may be any subclass of AnimatedText, while using FadeAnimatedTextKit essentially restricts you to using just FadeAnimatedText.

Legacy AnimatedTextKit classes

Have you noticed that animation classes come in pairs? For example, there is FadeAnimatedText and FadeAnimatedTextKit. The significant refactoring with Version 3 split the original FadeAnimatedTextKit into FadeAnimatedText and a re-usable AnimatedTextKit, then FadeAnimatedTextKit was adjusted for backwards compatibility.

When introducing a new AnimationText subclass, you may wonder if you also need to also introduce an additional Kit class. The answer is NO. :tada:

Going forward, we are championing the adoption of the Version 3 approach, and have deprecated the legacy Kit classes. This will make creating new animations easier. We know it makes some legacy code more verbose, but the flexibility and simplicity is a conscious trade-off.

Animations

Many animations are provided, but you can also create your own animations.

Rotate

Row(
  mainAxisSize: MainAxisSize.min,
  children: <Widget>[
    const SizedBox(width: 20.0, height: 100.0),
    const Text(
      'Be',
      style: TextStyle(fontSize: 43.0),
    ),
    const SizedBox(width: 20.0, height: 100.0),
    DefaultTextStyle(
      style: const TextStyle(
        fontSize: 40.0,
        fontFamily: 'Horizon',
      ),
      child: AnimatedTextKit(
        animatedTexts: [
          RotateAnimatedText('AWESOME'),
          RotateAnimatedText('OPTIMISTIC'),
          RotateAnimatedText('DIFFERENT'),
        ]
        onTap: () {
          print("Tap Event");
        },
      ),
    ),
  ],
);

Note: You can override transition height by setting the value of parameter transitionHeight for RotateAnimatedTextKit class.

Fade

return SizedBox(
  width: 250.0,
  child: DefaultTextStyle(
    style: const TextStyle(
      fontSize: 32.0,
      fontWeight: FontWeight.bold,
    ),
    child: AnimatedTextKit(
      animatedTexts: [
        FadeAnimatedText('do IT!'),
        FadeAnimatedText('do it RIGHT!!'),
        FadeAnimatedText('do it RIGHT NOW!!!'),
      ],
      onTap: () {
        print("Tap Event");
      },
    ),
  ),
);

Typer

return SizedBox(
  width: 250.0,
  child: DefaultTextStyle(
    style: const TextStyle(
      fontSize: 30.0,
      fontFamily: 'Bobbers',
    ),
    child: AnimatedTextKit(
      animatedTexts: [
        TyperAnimatedText('It is not enough to do your best,'),
        TyperAnimatedText('you must know what to do,'),
        TyperAnimatedText('and then do your best'),
        TyperAnimatedText('- W.Edwards Deming'),
      ]
      onTap: () {
        print("Tap Event");
      },
    ),
  ),
);

Typewriter

return SizedBox(
  width: 250.0,
  child: DefaultTextStyle(
    style: const TextStyle(
      fontSize: 30.0,
      fontFamily: 'Agne',
    ),
    child: AnimatedTextKit(
      animatedTexts: [
        TypewriterAnimatedText('Discipline is the best tool'),
        TypewriterAnimatedText('Design first, then code'),
        TypewriterAnimatedText('Do not patch bugs out, rewrite them'),
        TypewriterAnimatedText('Do not test bugs out, design them out'),
      ],
      onTap: () {
        print("Tap Event");
      },
    ),
  ),
);

Scale

return SizedBox(
  width: 250.0,
  child: DefaultTextStyle(
    style: const TextStyle(
      fontSize: 70.0,
      fontFamily: 'Canterbury',
    ),
    child: AnimatedTextKit(
      animatedTexts: [
        ScaleAnimatedText('Think'),
        ScaleAnimatedText('Build'),
        ScaleAnimatedText('Ship'),
      ],
      onTap: () {
        print("Tap Event");
      },
    ),
  ),
);

Colorize

const colorizeColors = [
  Colors.purple,
  Colors.blue,
  Colors.yellow,
  Colors.red,
];

const colorizeTextStyle = TextStyle(
  fontSize: 50.0,
  fontFamily: 'Horizon',
);

return SizedBox(
  width: 250.0,
  child: AnimatedTextKit(
    animatedTexts: [
      ColorizeAnimatedText(
        'Larry Page',
        textStyle: colorizeTextStyle,
        colors: colorizeColors,
      ),
      ColorizeAnimatedText(
        'Bill Gates',
        textStyle: colorizeTextStyle,
        colors: colorizeColors,
      ),
      ColorizeAnimatedText(
        'Steve Jobs',
        textStyle: colorizeTextStyle,
        colors: colorizeColors,
      ),
    ],
    isRepeatingAnimation: true,
    onTap: () {
      print("Tap Event");
    },
  ),
);

Note: colors list should contains at least two values.

TextLiquidFill

return SizedBox(
  width: 250.0,
  child: TextLiquidFill(
    text: 'LIQUIDY',
    waveColor: Colors.blueAccent,
    boxBackgroundColor: Colors.redAccent,
    textStyle: TextStyle(
      fontSize: 80.0,
      fontWeight: FontWeight.bold,
    ),
    boxHeight: 300.0,
  ),
);

To get more information about how the animated text made from scratch by @HemilPanchiwala, visit the Medium blog.

Wavy

return DefaultTextStyle(
  style: const TextStyle(
    fontSize: 20.0,
  ),
  child: AnimatedTextKit(
    animatedTexts: [
      WavyAnimatedText('Hello World'),
      WavyAnimatedText('Look at the waves'),
    ],
    isRepeatingAnimation: true,
    onTap: () {
      print("Tap Event");
    },
  ),
);

Create your own Animations

You can easily create your own animations by creating new classes that extend AnimatedText, just like most animations in this package. You will need to implement:

  • Class constructor – Initializes animation parameters.
  • initAnimation – Initializes Animation instances and binds them to the given AnimationController.
  • animatedBuilder – Builder method to return a Widget based on Animation values.
  • completeText – Returns the Widget to display once the animation is complete. (The default implementation returns a styled Text widget.)

Then use AnimatedTextKit to display the custom animated text class like:

AnimatedTextKit(
  animatedTexts: [
    CustomAnimatedText(
      'Insert Text Here',
      textStyle: const TextStyle(
        fontSize: 32.0,
        fontWeight: FontWeight.bold,
      ),
    ),
  ],
),

Bugs or Requests

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on GitHub and I'll look into it. Pull request are also welcome.

See Contributing.md.

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind are welcome! See Contributing.md.

Changelog

4.1.0

  • Legacy Kit classes are now marked as deprecated
  • DefaultTextStyle may be used to set a common text style across AnimatedText instances
  • textStyle is no longer required for AnimatedText subclasses (except for ColorizeAnimatedText)
  • FadeAnimatedText may now be customized to adjust the fade-in and fade-out interval
  • BREAKING CHANGE: AnimatedText.completeText now has a BuildContext parameter

4.0.0

  • Migrated to nnbd(null-safety)

3.1.2

  • Fixed insecure links in readme.

3.1.1

  • Added Flutter Favorite badge to readme.

3.1.0

  • Added rotateOut flag to RotateAnimatedText so that one may optionally disable the rotation-out animation.
  • Updated the example app to demonstrate RotateAnimatedText with rotateOut disabled.

3.0.2

  • Fixed major bug #168, introduced with version 3
  • Updated the example app to show a Tap Count
  • Optimized the dispose for AnimatedTextKit
  • Added missing return type to onNext function signatures

3.0.1

  • Optimized the initState for AnimatedTextKit.

3.0.0

  • Refactored code to reduce duplication, improve consistency, and simplify making new animations. Created AnimatedText and AnimatedTextKit. PR #157
  • Removed the unused alignment property from all except RotateAnimatedTextKit. Resolves #153
  • Added a textDirection property to ColorizeAnimatedTextKit to support RTL text. Resolves #109
  • Added a loadUntil property to TextLiquidFill to optionally show a partial fill. Resolves #75
  • Optimized TextLiquidFill. PR #165
  • Optimized ColorizeAnimatedTextKit. PR #155
  • Updated the Dart SDK constraint to be 2.10+.
  • Regenerated the example platform code. PR #162
  • Migrated from Travis CI to GitHub Actions.

2.5.4

  • Added missing dart documentation to the public classes and methods.

2.5.3

  • Updated the README to revert links to be pub.dev friendly.

2.5.2

Issue Fixed

  • Bug fix for ScaleAnimatedTextKit to check mounted before setState to avoid potential conflict with dispose. Resolves #105 -- PR #143

2.5.1

Bug Fixes and Enhancements

  • Minor bug fix to RotateAnimatedTextKit to properly handle alignment property, and introduced textDirection property #138
  • Increased test coverage #128

2.5.0

Bug Fixes and Enhancements

  • Increase test coverage #137 and #135.
  • Removed redundant _texts variables #133.
  • Added pedantic lint rules. #132.
  • Refactored code to move default logic from the State class to the StatefulWidget #131.
  • Revised _textKey to not be a global variable. Resolves #129 issue -- PR #130.
  • Other basic improvements #136 and #134.

2.4.1

Issue Fixed

2.4.0

Issues Fixed

2.3.0

New Animated Text

Issues Fixed

2.2.0

Issues Fixed

Code Review #81

  • Removed obsolete new keywords.
  • Added types to collection and function variables.
  • Added final and const keywords.
  • Replaced null guards with concise ?. and ?? operators.
  • Added missing null check on dispose for FadeAnimatedTextKit.
  • In fade.dart, renamed the _RotatingTextState class to _FadeTextState to be consistent with the overall pattern and avoid confusion with _RotatingTextState in rotate.dart.

Warning:

  • Removed onNextBeforePause from ColorizeAnimatedTextKit because it was not referenced.

2.1.0

Issues Fixed

Feature Enhancement

  • Add repeatForever option.

    repeatForever: true, //this will ignore [totalRepeatCount]
    

2.0.1

  • Minor updates.

2.0.0

  • TextLiquidFill animated text added to the package🎉🎉

  • Breaking Changes: Different arguments are included in the classes and duration has been broken into speed and pause in some classes as per their needs.

    • duration - Change the duration from the animation time of the complete list to single element animation time.
    • speed - Time between the display of characters.
    • pause - Delay between the animation of texts.
    • totalRepeatCount - Sets the number of times animation should repeat
    • displayFullTextOnTap - If true, tapping the screen will stop current animated text, and display it fully.
    • stopPauseOnTap - If true, tapping during a pause will stop it and start the next text animation.
  • Better control over Animated Texts: Callbacks added:

    • onNext(int index, bool isLast) - This callback will be called before the next text animation, after the previous ones pause.
    • onNextBeforePause(int index, bool isLast) - This callback will be called before the next text animation, before the previous one's pause.
    • onFinished - This callback is called at the end when the parameter isRepeatingAnimation is set to false.

1.3.1

  • Updated example app readme.
  • Added documentation for the various parameters of all the animated widgets.

1.3.0

Feature Enhancement

  • Added attribute to align text.
  • Updated Readme.

1.2.0

Feature Enhancement

  • Added attribute to check whether the animation should repeat or not.
  • Updated Readme.

1.1.1

  • Fixed flutter formatting issues.

1.1.0

Feature Enhancement

  • Added onTap callback for all AnimatedText widget.
  • Updated Readme.

1.0.3

  • General update.

1.0.2

  • Updated Readme.

1.0.1

  • Initial Release.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add animated_text_kit
pubspec.yaml
name: animated_text_kit
description: A flutter package project which contains a collection of cool and beautiful text animations.
version: 4.1.0
homepage: https://github.com/aagarwal1012/Animated-Text-Kit/
maintainer: Ayush Agarwal (@aagarwal1012)

dependencies:
  flutter:
    sdk: flutter
  characters: ^1.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  pedantic: ^1.11.0

flutter:

environment:
  sdk: ">=2.12.0-0 <3.0.0"
  flutter: ">=1.22.0"

Version history

VersionPublishedArchiveSHA-256
1.0.12018-08-10T09:39:43.665398ZDownload3b7cbc0a963c4b37fa5d15c5ba38c38bd2b5826c235553f2848701a947e8aea3
1.0.22018-08-10T13:33:26.977256ZDownload340776dc161c07984de0ba5d0bd93ec1ccdc1d724c9ab702e5c674474ba12870
1.0.32018-08-14T17:47:31.234835ZDownload076e8fc4527b615f6e8fb749c79d134c0c129ce886a085b887273140cd4e09a5
1.1.02018-09-19T14:12:28.995611ZDownload5dbe6a03ced907a81eb5c2bd43ad939a7fa15869ce13c05a3f0816108db91288
1.1.12018-10-25T22:10:13.689461ZDownload39301f90cc13f9a301bb743e3d1c32266cb4a31ae286d2e0dfe4f0f87a1e57c7
1.2.02018-11-21T17:50:28.082575ZDownloadedd23c6f8355dc7857af367b6128824f79b4dedd15225bdbdc71a975c859d48b
1.3.02019-01-30T22:37:50.240049ZDownload064b7f1a51a68f0a6824ed4291aa48060d4ed345d29707090db4b1b682e35a8a
1.3.12019-05-28T17:03:18.112518ZDownloadd566edbde35550271fb28511b9093b6bae53b8773b8df6fb5a4fe36534bde1c2
2.0.02019-12-25T20:41:58.677948ZDownload7d401646664f0566b531a026960af9f0bf6602d10039a3674637203db24b7889
2.0.12020-04-29T14:37:41.433462ZDownload27a9f2b77aab931bbc4939a47cf2626ade19b0621a93592aae2e3daf2fcde772
2.1.02020-05-22T20:56:13.585044ZDownloada3ec787b7c9500a08c40d269ca1479f568cd505b57a5ff0c3b43a29cb06e8008
2.2.02020-05-30T19:07:34.848275ZDownloadb8772b1a91326d6307f73649a23c589bf802e87153f4f9515b72e07e7c75ee6a
2.3.02020-10-03T22:21:31.644523ZDownload4688bcd5d3f59d7d7ec24f194f9bbbc639380de9128ad49b7d1f7f315cbe8efa
2.4.02020-10-14T05:30:43.633749ZDownloada8051390c26e48e39eecef3ce0b04448f6cdf3a05c37f75af1adba405f875d4e
2.4.12020-10-18T09:41:38.503362ZDownload1774e554677971d8d0765c25ccba9d614d357a8ff15b5549908a39e4c2d34def
2.5.02020-10-24T19:13:57.752100ZDownloadf94371011447009e7242ed77447eda07d08b15d323b29d831222d9ff7d2cc5cf
2.5.12020-10-26T05:43:54.402953ZDownload10c0bb77c1054421c618704acbb22fb75ed53bb190b738c805a57a06970195e8
2.5.22020-11-01T19:46:21.406148ZDownload49d9508fbb1292805fc81c863aa11553eacbd3345ee8ce082ae2c78037535234
2.5.32020-11-01T20:53:22.832046ZDownload0e9ab1f7e7f892aca7ffe8b53311f23d1f0f2094cb03aa42de7fed21c6c796bb
2.5.42020-11-06T21:01:11.038690ZDownload41c615f94edfdde93324d8f80ff915bcfc933f368574b6737c8b9f2856741d2d
3.0.02020-12-07T12:55:10.618024ZDownloadc34a7454639f3e68164fe78adc6e185c08ff12bf21aa4e8ab3c744e39f272ece
3.0.12020-12-11T10:51:14.455033ZDownload91232e2c6f64319701664a4e72b98a6bed556609917d27a40c5e7ad93d86e0a1
3.0.22020-12-15T17:49:37.989413ZDownload84343cc195224dfca7135cff4293e8e8efa4f448cfd187d25aefc551abc98629
3.1.02020-12-17T17:08:40.198307ZDownload8e2d38cfa3687cb2ffeee8f4a9bdc7aaa5e838970de74b5d24201b20bfafdfcc
3.1.12021-02-17T12:39:16.638599ZDownload4bbb0b0e356985f01551070d1924c03a5def2a97cf261dbd06d1621e945ef242
3.1.22021-02-17T19:32:58.363292ZDownload617b93ac2e54be590c49b863afcef1a21f983376e55538d12e8028b83f3fe8aa
4.0.02021-02-22T18:49:24.688248ZDownloadecc5f3120d5ffd0c9b6e6cbdb3435292555cb5db339269841fb9834394071bb7
4.1.02021-03-24T17:25:06.739018ZDownload17c098e65eb1f710e17af3e72fda88e87f036072292485fa5d2c5fc721b2d353
4.1.12021-03-26T08:55:54.354106ZDownload3eacf7861eacbb65ca715e0dc61dac90c4e843c19c7c0347241e30a397dad2bd
4.2.02021-04-14T17:33:44.369504ZDownloadea637054b3f9858a11976c27c7a91c0a412994b02d304e1350ff41ad3d7809b8
4.2.12021-04-24T08:50:56.332060ZDownload5e6bf696c1db94fae17ef0527a17cef82f3100daebb53a3bdeb1c34f6b2ccdcc
4.2.22022-06-05T14:54:43.629507ZDownload37392a5376c9a1a503b02463c38bc0342ef814ddbb8f9977bc90f2a84b22fa92
4.2.32025-01-25T16:07:24.487704ZDownloadadba517adb7e6adeb1eb5e1c8a147dd7bc664dfdf2f5e92226b572a91393a93d
4.3.02025-10-04T13:50:52.907320ZDownload1d41486860885321972dd332179357a535d50d4780fc2ba5e1805bde085c81f2

Dependencies

characters "^1.1.0"

flutter { "sdk": "flutter" }