Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,42 @@ Row(

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

## Flicker

<img src="https://github.com/aagarwal1012/Animated-Text-Kit/blob/master/display/flicker.gif?raw=true" align = "right" height = "300px">

```dart
const _flickerTextStyle = TextStyle(fontSize: 35, shadows: [
Shadow(
blurRadius: 7.0,
color: Colors.white,
offset: Offset(0, 0),
),
]);
return SizedBox(
width: 250.0,
child: AnimatedTextKit(
animatedTexts: [
FlickerAnimatedText(
'Flicker Frenzy',
textStyle: _flickerTextStyle,
),
FlickerAnimatedText(
'Night Vibes On',
textStyle: _flickerTextStyle,
),
FlickerAnimatedText(
"C'est La Vie !",
textStyle: _flickerTextStyle,
),
],
onTap: () {
print("Tap Event");
},
),
);
```

## Fade

<img src="https://github.com/aagarwal1012/Animated-Text-Kit/blob/master/display/fade.gif?raw=true" align = "right" height = "300px">
Expand Down
Binary file added display/flicker.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ const _colorizeTextStyle = TextStyle(
fontFamily: 'Horizon',
);

const _flickerTextStyle = TextStyle(fontSize: 35, shadows: [
Shadow(
blurRadius: 7.0,
color: Colors.white,
offset: Offset(0, 0),
),
]);

// Colorize Colors
const _colorizeColors = [
Colors.purple,
Expand Down Expand Up @@ -168,6 +176,18 @@ List<AnimatedTextExample> animatedTextExamples({VoidCallback? onTap}) =>
],
),
),
AnimatedTextExample(
label: 'Flicker',
color: Colors.pink[300],
child: AnimatedTextKit(
animatedTexts: [
FlickerAnimatedText('Flicker Frenzy', textStyle: _flickerTextStyle),
FlickerAnimatedText('Night Vibes On', textStyle: _flickerTextStyle),
FlickerAnimatedText("C'est La Vie !", textStyle: _flickerTextStyle),
],
onTap: onTap,
),
),
AnimatedTextExample(
label: 'Fade',
color: Colors.brown[600],
Expand Down
1 change: 1 addition & 0 deletions lib/animated_text_kit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export 'src/colorize.dart';
export 'src/scale.dart';
export 'src/text_liquid_fill.dart';
export 'src/wavy.dart';
export 'src/flicker.dart';
98 changes: 98 additions & 0 deletions lib/src/flicker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import 'package:flutter/material.dart';
import 'animated_text.dart';

/// Animated Text that displays a [Text] element, as a flickering glow text.
///
/// ![Flicker example](https://raw.githubusercontent.com/aagarwal1012/Animated-Text-Kit/master/display/flicker.gif)
class FlickerAnimatedText extends AnimatedText {
/// Marks ending of flickering entry interval of text
final double entryEnd;
final Duration speed;

FlickerAnimatedText(
String text, {
TextAlign textAlign = TextAlign.start,
TextStyle? textStyle,
this.speed = const Duration(milliseconds: 1600),
this.entryEnd = 0.5,
}) : super(
text: text,
textStyle: textStyle,
duration: speed,
);

late Animation<double> _entry;

@override
void initAnimation(AnimationController controller) {
_entry = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: controller,
curve: Interval(0.0, entryEnd, curve: Curves.bounceIn),
),
);
}

@override
Widget completeText(BuildContext context) => SizedBox.shrink();

@override
Widget animatedBuilder(BuildContext context, Widget? child) {
return Opacity(
opacity: _entry.value != 1.0 ? _entry.value : _entry.value,
child: textWidget(text),
);
}
}

@Deprecated('Use AnimatedTextKit with FlickerAnimatedText instead.')
class FlickerAnimatedTextKit extends AnimatedTextKit {
FlickerAnimatedTextKit({
Key? key,
required List<String> text,
TextAlign textAlign = TextAlign.start,
TextStyle? textStyle,
TextDirection textDirection = TextDirection.ltr,
Duration speed = const Duration(milliseconds: 1600),
double entryEnd = 0.5,
VoidCallback? onTap,
void Function(int, bool)? onNext,
void Function(int, bool)? onNextBeforePause,
VoidCallback? onFinished,
bool isRepeatingAnimation = true,
int totalRepeatCount = 3,
bool repeatForever = false,
bool displayFullTextOnTap = false,
bool stopPauseOnTap = false,
}) : super(
key: key,
animatedTexts:
_animatedTexts(text, textAlign, textStyle, speed, entryEnd),
onTap: onTap,
onNext: onNext,
onNextBeforePause: onNextBeforePause,
onFinished: onFinished,
isRepeatingAnimation: isRepeatingAnimation,
totalRepeatCount: totalRepeatCount,
repeatForever: repeatForever,
displayFullTextOnTap: displayFullTextOnTap,
stopPauseOnTap: stopPauseOnTap,
);

static List<AnimatedText> _animatedTexts(
List<String> text,
TextAlign textAlign,
TextStyle? textStyle,
Duration speed,
double entryEnd,
) =>
text
.map((_) => FlickerAnimatedText(
_,
textAlign: textAlign,
textStyle: textStyle,
speed: speed,
entryEnd: entryEnd,
))
.toList();
}
10 changes: 10 additions & 0 deletions test/smoke_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ void main() {
var tapped = false;

final tapableWidgets = <Widget>[
// ignore: deprecated_member_use_from_same_package
FlickerAnimatedTextKit(
text: tripleText,
textStyle: textStyle,
displayFullTextOnTap: true,
onTap: () {
tapped = true;
},
),

// ignore: deprecated_member_use_from_same_package
ColorizeAnimatedTextKit(
text: tripleText,
Expand Down