transform_text 1.0.1 copy "transform_text: ^1.0.1" to clipboard
transform_text: ^1.0.1 copied to clipboard

Helps you to animate transform text when text change.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:transform_text/transform_text.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Timer? timer;
  String currentTime = "";
  DateFormat f = DateFormat("yyyy-MM-dd h:mm:ss a");
  int counter = 0;
  bool isIncrement = true;
  bool isCheckin = true;

  void toggleCheckin() {
    setState(() {
      isCheckin = !isCheckin;
    });
  }

  void increment() {
    setState(() {
      isIncrement = true;
      counter++;
    });
  }

  void decrement() {
    setState(() {
      isIncrement = false;
      counter--;
    });
  }

  @override
  void initState() {
    timer = Timer.periodic(const Duration(), (timer) {
      setState(() {
        currentTime = f.format(DateTime.now());
      });
    });
    super.initState();
  }

  @override
  void dispose() {
    if (timer != null) {
      timer!.cancel();
    }
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text("TransformText"),
          backgroundColor: Colors.blue,
        ),
        body: SingleChildScrollView(
          child: Center(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                _buildRow(
                  "TransformTextType.scrollUp",
                  child: TransformText(currentTime),
                ),
                _buildRow(
                  "TransformTextType.scaleIn",
                  child: TransformText(
                    currentTime,
                    type: TransformTextType.scaleIn,
                  ),
                ),
                _buildRow(
                  "TransformTextType.scaleOut",
                  child: TransformText(
                    currentTime,
                    type: TransformTextType.scaleOut,
                  ),
                ),
                _buildRow(
                  "TransformTextType.scrollDown",
                  child: TransformText(
                    currentTime,
                    type: TransformTextType.scrollDown,
                  ),
                ),
                _buildRow(
                  "TransformTextType.fade",
                  child: TransformText(
                    currentTime,
                    type: TransformTextType.fade,
                  ),
                ),
                _buildRow(
                  "TransformTextType.fallDown",
                  child: TransformText(
                    currentTime,
                    type: TransformTextType.fallDown,
                  ),
                ),
                _buildRow(
                  "TransformTextType.up",
                  child: TransformText(
                    currentTime,
                    type: TransformTextType.up,
                  ),
                ),
                Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Column(
                      children: [
                        TransformText(
                          isIncrement ? "Increment" : "Decrement",
                          type: TransformTextType.fallDown,
                        ),
                        Row(
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            TransformText(
                              "$counter",
                              type: !isIncrement
                                  ? TransformTextType.scrollUp
                                  : TransformTextType.scrollDown,
                            ),
                            IconButton(
                              onPressed: decrement,
                              icon: const Icon(Icons.remove),
                            ),
                            IconButton(
                              onPressed: increment,
                              icon: const Icon(Icons.add),
                            ),
                          ],
                        ),
                      ],
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Widget _buildRow(String label, {required Widget child}) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 16),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text("$label: "),
          child,
        ],
      ),
    );
  }
}
1
likes
140
points
25
downloads
screenshot

Publisher

verified publisherrathadev.site

Weekly Downloads

Helps you to animate transform text when text change.

Repository (GitHub)
View/report issues

Topics

#animate-text #animation-text #animated

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on transform_text