TypeWriter Text

0

A simple typewriter text animation wrapper for flutter.

Miscellaneous

dart
flutter
flutter-package
pub-dev

TypeWeriter Text Dall-E Logo

Type Writer Text

test

A simple typewriter text animation wrapper for flutter, supports iOS, Android, web, Windows, macOS, and Linux.

Preview

TypeWriterText Preview

Install

Add this line to your pubspec.yaml.

dependencies:
  typewritertext: ^3.0.8

Usage

First, import the typewriter package.

import 'package:typewritertext/typewritertext.dart';

And use it like this

TypeWriter.text(
  'lorem ipsum dolot sit amet ...',
  duration: const Duration(milliseconds: 50),
);

And for the builder, you need to initiate a controller like this one.

final controller = TypeWriterController(text: 'Hello World',
  duration: const Duration(milliseconds: 50),
);

// also if you want the typewriter to not only changing
// the character but also words, you can use this controller.

final valueController = TypeWriterController.fromValue(
  TypeWriterValue([
    'First Paragraph',
    'Next Paragraph',
    'Last Paragraph',
  ]),
  duration: const Duration(milliseconds: 50),
);

// you can also integrate the controller with Stream<String> like this one.

final streamController = TypeWriterController.fromStream(
  StreamController<String>().stream
);

TypeWriter(
  controller: controller, // valueController // streamController
  builder: (context, value) {
    return Text(
      value.text,
      maxLines: 2,
      minFontSize: 2.0,
    );
  }
);

Documentation

TypeWriter.text

PropertyPurpose
repeatSpecifies whether the animation should repeat once completed (default is false).
enabledIs the flag to play the animation or not.
maintainSizeSpecifies whether the size of the layout text should be maintained.
durationDelay time between each character.
alignmentAlignment of the text layout.
textThe text to be displayed during the typewriter animation.
onChangedCallback function for when the text is changed.
textAlignAlignment of the text.
styleStyle of the text.
maxLinesMaximum number of lines to be displayed.
overflowOverflow behavior of the text.
semanticsLabelSemantics label of the text.
softWrapSpecifies whether the text should break at soft line breaks.
strutStyleStrut style of the text.
localeLocale of the text.
textDirectionText direction of the text.
textHeightBehaviorText height behavior of the text.
textWidthBasisText width basis of the text.
selectionColorColor of the selection.
onFinishedIs a callback that triggered when the animation is done. This requires [enabled] as true and repeat as false.

TypeWriter

PropertyPurpose
controllerController that manage the animation. You can use TypeWriterController or TypeWriterController.fromValue.
enabledIs the flag to play the animation or not.
builderBuilder that contains TypeWriterValue in sequence.
onFinishedIs a callback that triggered when the animation is done. This requires [enabled] as true and repeat as false.

Example