Skip to content

Instantly share code, notes, and snippets.

@BarryDaBee
Created August 17, 2025 22:05
Show Gist options
  • Select an option

  • Save BarryDaBee/ae360e008ebe15b09b349ced7e939e8b to your computer and use it in GitHub Desktop.

Select an option

Save BarryDaBee/ae360e008ebe15b09b349ced7e939e8b to your computer and use it in GitHub Desktop.
Simple blinking cursor widget using Flutter Hooks, mimicking the internal cursor animation from EditableText. It uses an AnimationController with a CurvedAnimation (fastOutSlowIn) and a FadeTransition to smoothly animate the opacity back and forth, giving a natural caret blink effect.
class AppAnimatedCursor extends HookWidget {
const AppAnimatedCursor({super.key, this.height = 40});
final double height;
@override
Widget build(BuildContext context) {
final controller = useAnimationController(
duration: const Duration(milliseconds: 500),
)..repeat(reverse: true);
final animation = useMemoized(
() => CurvedAnimation(parent: controller, curve: Curves.fastOutSlowIn),
[controller],
);
return FadeTransition(
opacity: animation,
child: Container(
width: 1,
height: height,
color: Colors.black,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment