decoding_text_effect 1.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new70

This flutter package contains a widget called DecodingTextEffect which is having some cool Decode Effects for texts.


Installing #

1. Depend on it #

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

dependencies:
  decoding_text_effect: ^1.0.0

2. Install it #

You can install packages from the command line:

$ flutter pub get

3. Import it #

Now in your Dart code, you can use:

import 'package:decoding_text_effect/decoding_text_effect.dart';

Documentation #

Decoding effects occurs only for following two cases,

  1. When the widget is rendered for the very first time.
  2. When the value of originalString parameter gets changed.
DecodingTextEffect(
   this.originalString, {
   @required this.decodeEffect,
   Key key,
   this.textStyle,
   this.textAlign,
   this.refreshDuration,
   this.eachCount = 5,
   this.onTap,
   this.onFinished,
  })  : assert(
         originalString != null,
         'A non-null String must be provided to a Decoding Text Effect Widget.',
        ),
        super(key: key);

Usage #

List<String> myText = [
   'Decoding Text\nEffect',
   'Welcome to\nthe Dart Side!',
   'I have 50\nwatermelons',
   'Quick Maths,\n2 + 2 = 4'
  ];

1. DecodeEffect.fromStart #

Container(
   height: 200,
   width: 350,
   color: Colors.pink[100],
   padding: EdgeInsets.all(50),
   child: DecodingTextEffect(
      myText[index],
      decodeEffect: DecodeEffect.fromStart,
      textStyle: TextStyle(fontSize: 30),
   ),
),

2. DecodeEffect.fromEnd #

Container(
   height: 200,
   width: 350,
   color: Colors.yellow[100],
   padding: EdgeInsets.all(50),
   child: DecodingTextEffect(
      myText[index],
      decodeEffect: DecodeEffect.fromEnd,
      textStyle: TextStyle(fontSize: 30),
   ),
),

3. DecodeEffect.toMiddle #

Container(
   height: 200,
   width: 350,
   color: Colors.green[100],
   padding: EdgeInsets.all(50),
   child: DecodingTextEffect(
      myText[index],
      decodeEffect: DecodeEffect.to_middle,
      textStyle: TextStyle(fontSize: 30),
   ),
),

4. DecodeEffect.random #

Container(
   height: 200,
   width: 350,
   color: Colors.purple[100],
   padding: EdgeInsets.all(50),
   child: DecodingTextEffect(
      myText[index],
      decodeEffect: DecodeEffect.random,
      textStyle: TextStyle(fontSize: 30),
   ),
),

5. DecodeEffect.all #

Container(
   height: 200,
   width: 350,
   color: Colors.blue[100],
   padding: EdgeInsets.all(50),
   child: DecodingTextEffect(
      myText[index],
      decodeEffect: DecodeEffect.all,
      textStyle: TextStyle(fontSize: 30),
   ),
),

refreshDuration and eachCount #

The refreshDuration is an optional argument that is having a default value of Duration(milliseconds: 60). Shorter the value of refreshDuration, faster will be the effect and hence decreasing the duration of effect. refreshDuration is also the time gap between two consecutive setState() function calls.

The eachCount is also an optional argument that is having a default value of 5. It is the number of random characters that will be shown before showing the original character and then moving on to decode next character and this cycles repeat until the completion of effect.

Demo #

Source code of the below app is available in the example directory of this package's github repository.

Below are some other demonstration of DecoratingTextEffect widget. But the source code of below apps are not in this repository.

[1.1.1] #

  • Documentation update

[1.1.0] #

  • New feature: Added onTap and onFinished callback
  • Serious: Fixed memory leak issue

[1.0.1] #

  • Added Documentation
  • Bug fix for DecodeEffect.fromEnd

[1.0.0] #

  • Initial release

example/lib/main.dart

// Copyright (c) 2020, Aadarsh Patel
// All rights reserved.
// This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int index = 0;

  List<String> myText = [
    'Decoding Text\nEffect',
    'Welcome to\nthe Dart Side!',
    'I have 50\nwatermelons',
    'Quick Maths,\n2 + 2 = 4'
  ];

  void changeText() {
    setState(() {
      index++;
      if (index == myText.length) index = 0;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Decoding Text Effect Example'),
      ),
      body: SingleChildScrollView(
        child: Container(
          width: MediaQuery.of(context).size.width,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              SizedBox(height: 50),
              Text(
                'decodeEffect: DecodeEffect.fromStart',
                style: TextStyle(fontSize: 21),
              ),
              SizedBox(height: 8),
              Container(
                height: 200,
                width: 350,
                color: Colors.pink[100],
                padding: EdgeInsets.all(50),
                child: DecodingTextEffect(
                  myText[index],
                  decodeEffect: DecodeEffect.fromStart,
                  textStyle: TextStyle(fontSize: 30),
                ),
              ),
              SizedBox(height: 100),
              Text(
                'decodeEffect: DecodeEffect.fromEnd',
                style: TextStyle(fontSize: 21),
              ),
              SizedBox(height: 8),
              Container(
                height: 200,
                width: 350,
                color: Colors.yellow[100],
                padding: EdgeInsets.all(50),
                child: DecodingTextEffect(
                  myText[index],
                  decodeEffect: DecodeEffect.fromEnd,
                  textStyle: TextStyle(fontSize: 30),
                ),
              ),
              SizedBox(height: 100),
              Text(
                'decodeEffect: DecodeEffect.toMiddle',
                style: TextStyle(fontSize: 21),
              ),
              SizedBox(height: 8),
              Container(
                height: 200,
                width: 350,
                color: Colors.green[100],
                padding: EdgeInsets.all(50),
                child: DecodingTextEffect(
                  myText[index],
                  decodeEffect: DecodeEffect.toMiddle,
                  textStyle: TextStyle(fontSize: 30),
                ),
              ),
              SizedBox(height: 100),
              Text(
                'decodeEffect: DecodeEffect.random',
                style: TextStyle(fontSize: 21),
              ),
              SizedBox(height: 8),
              Container(
                height: 200,
                width: 350,
                color: Colors.purple[100],
                padding: EdgeInsets.all(50),
                child: DecodingTextEffect(
                  myText[index],
                  decodeEffect: DecodeEffect.random,
                  textStyle: TextStyle(fontSize: 30),
                ),
              ),
              SizedBox(height: 100),
              Text(
                'decodeEffect: DecodeEffect.all',
                style: TextStyle(fontSize: 21),
              ),
              SizedBox(height: 8),
              Container(
                height: 200,
                width: 350,
                color: Colors.blue[100],
                padding: EdgeInsets.all(50),
                child: DecodingTextEffect(
                  myText[index],
                  decodeEffect: DecodeEffect.all,
                  textStyle: TextStyle(fontSize: 30),
                ),
              ),
              SizedBox(height: 100),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.refresh),
        onPressed: changeText,
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  decoding_text_effect: ^1.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:decoding_text_effect/decoding_text_effect.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
39
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test