File tree Expand file tree Collapse file tree 6 files changed +16
-4
lines changed
Expand file tree Collapse file tree 6 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 1+ ## 0.0.4
2+
3+ * Add ` correctCharProbability ` and ` scrambleCycles ` parameters
4+
15## 0.0.3
26
37* Add [ Medium article] ( https://medium.com/@khlebobul/scramble-effect-for-text-flutter-widget-d92df44dd7a8 )
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ TextScramble(
1616 text: 'Hello World!',
1717 speed: Duration(milliseconds: 30),
1818 chars: '!<>-_\\/[]{}—=+*^?#________',
19+ correctCharProbability = 0.1, // Correct character probability in [0, 1]
20+ scrambleCycles = 4, // Number of times to scramble the text
1921 style: TextStyle(
2022 fontSize: 40,
2123 color: Colors.black,
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ class MainApp extends StatelessWidget {
1919 text: 'Hello World!' ,
2020 speed: Duration (milliseconds: 50 ),
2121 chars: '!<>-_\\ /[]{}—=+*^?#________' ,
22+ correctCharProbability = 0.1 , // Correct character probability in [0, 1]
23+ scrambleCycles = 4 , // Number of times to scramble the text
2224 style: TextStyle (
2325 fontSize: 40 ,
2426 color: Colors .green,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ environment:
99dependencies :
1010 flutter :
1111 sdk : flutter
12- use_scramble : ^0.0.1
12+ use_scramble : ^0.0.4
1313
1414dev_dependencies :
1515 flutter_test :
Original file line number Diff line number Diff line change @@ -7,13 +7,17 @@ class TextScramble extends StatefulWidget {
77 final Duration speed;
88 final String chars;
99 final TextStyle ? style;
10+ final double correctCharProbability; // Correct character probability in [0, 1]
11+ final int scrambleCycles; // Number of times to scramble the text
1012
1113 const TextScramble ({
1214 super .key,
1315 required this .text,
1416 this .speed = const Duration (milliseconds: 50 ),
1517 this .chars = '!<>-_\\ /[]{}—=+*^?#________' ,
1618 this .style,
19+ this .correctCharProbability = 0.1 ,
20+ this .scrambleCycles = 4 ,
1721 });
1822
1923 @override
@@ -38,7 +42,7 @@ class _TextScrambleState extends State<TextScramble> {
3842 int counter = 0 ;
3943 _timer = Timer .periodic (widget.speed, (timer) {
4044 // Check if it's time to end the animation
41- if (counter >= widget.text.length * 4 ) {
45+ if (counter >= widget.text.length * widget.scrambleCycles ) {
4246 timer.cancel ();
4347 setState (() {
4448 _displayText = widget.text;
@@ -52,7 +56,7 @@ class _TextScrambleState extends State<TextScramble> {
5256 if (_done[index]) return widget.text[index];
5357
5458 // With a 10% probability, set the correct character
55- if (_random.nextDouble () < 0.1 ) {
59+ if (_random.nextDouble () < widget.correctCharProbability ) {
5660 _done[index] = true ;
5761 return widget.text[index];
5862 }
Original file line number Diff line number Diff line change 11name : use_scramble
22description : " Lightweight package for random text animations inspired by useScramble"
3- version : 0.0.3
3+ version : 0.0.4
44homepage : https://github.com/khlebobul/use_scramble
55
66environment :
You can’t perform that action at this time.
0 commit comments