Build a Teleprompter App in Flutter
DEV Community

Build a Teleprompter App in Flutter

When I built CueScript: Teleprompter Video, the problem was familiar to anyone who has ever recorded a video: memorizing lines means losing eye contact, reading off cue cards means endless retakes, and either way the delivery sounds stiff.

The finished app puts the script right on the camera screen and scrolls it over the camera preview, close to the lens, so your eyes stay on the viewer while you record video and audio in one tap. It imports scripts from PDF or DOCX files, tunes the scroll speed in words per minute, and manages unlimited scripts with word count and estimated read time.

You can see the finished app in the CueScript case study. This guide shows how to build the same feature in your own Flutter app: a camera preview with a scrolling script overlay, speed in words per minute, one-tap video recording, and a script library with word count and estimated read time.

What is a teleprompter app in Flutter?

A teleprompter app in Flutter is an app that displays a script scrolling over a live camera preview while the phone records video. The script is a normal Flutter widget drawn on top of the camera feed, which means it scrolls smoothly, stays readable, and is never mirrored, even when you record with the front camera.

The phone records the video and the audio while the script moves at the reader's speaking pace, so the speaker keeps eye contact with the lens instead of looking down at notes. CueScript works exactly this way: the script scrolls close to the lens while video and audio are captured in a single tap.

Which packages do I need for a teleprompter app?

Four packages cover the whole feature:

  • camera - Camera preview and video recording. Without it: No preview, no recording.
  • wakelock_plus - Keeps the screen awake while recording. Without it: The screen locks mid-take and the recording stops.
  • file_picker - Lets the user pick PDF, DOCX or TXT files. Without it: No script import.
  • path_provider - Finds a safe folder for recorded videos. Without it: Recordings have nowhere to live.

Add them to pubspec.yaml and run flutter pub get.

The camera package is the only one that needs platform setup: add the camera permission to AndroidManifest.xml and the NSCameraUsageDescription and NSMicrophoneUsageDescription keys to Info.plist, or the app will crash the first time it opens the camera. If you have not used the camera plugin before, the camera guide covers the full setup, and the official Flutter camera cookbook shows the same flow from the docs.

How do I show the camera preview in Flutter?

Show the camera preview in Flutter with a CameraController wrapped in a FutureBuilder: create the controller from the front camera, await initialize, and render a CameraPreview once initialization completes. The front camera is the right default for a teleprompter, because the speaker reads the script while facing the lens.

Guard the preview with an isInitialized check, and dispose the controller when the screen closes, or the camera stays locked for other apps.

import 'package:camera/camera.dart';

class TeleprompterCamera extends StatefulWidget {
  const TeleprompterCamera({super.key});
  @override
  State createState() => _TeleprompterCameraState();
}

class _TeleprompterCameraState extends State {
  CameraController? _controller;
  Future? _initializeFuture;
  @override
  void initState() {
    super.initState();
    _initializeFuture = _initCamera();
  }

  Future _initCamera() async {
    final cameras = await availableCameras();
    final front = cameras.firstWhere(
      (c) => c.lensDirection == CameraLensDirection.front,
      orElse: () => cameras.first,
    );
    _controller = CameraController(
      front,
      ResolutionPreset.high,
      enableAudio: true,
    );
    await _controller!.initialize();
  }

  @override
  void dispose() {
    _controller?.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: _initializeFuture,
      builder: (context, snapshot) {
        if (snapshot.connectionState != ConnectionState.done) {
          return const Center(child: CircularProgressIndicator());
        }
        if (_controller == null || !_controller!.value.isInitialized) {
          return const Center(child: Text('Camera unavailable'));
        }
        return CameraPreview(_controller!);
      },
    );
  }
}

Two details matter. First, availableCameras throws a CameraException when no camera is available, so wrap the call in try/catch. Second, pass enableAudio: true, or the recording will be silent.

The preview is the bottom layer of the screen: the script overlay goes on top of it in a Stack.

How do I scroll the script at a set words per minute?

Scroll the script at a set words per minute by converting the word count into a total read time, then advancing a ScrollController by a fixed number of pixels every 50 milliseconds until the text is finished.

Words per minute is a speaking pace, not a pixel speed, so the conversion is the heart of the feature: divide the word count by the words per minute and multiply by 60 to get the total seconds, then divide the scrollable distance by that time to get pixels per second.

CueScript uses exactly this model: the speed is set in words per minute and the estimated read time is shown for every script before recording starts.

Start with a small script model that derives the word count and read time from the text:

class Script {
  const Script({
    required this.title,
    required this.text,
    required this.updatedAt,
  });
  final String title;
  final String text;
  final DateTime updatedAt;
  int get wordCount => text.split(' ').where((word) => word.isNotEmpty).length;
  Duration estimatedReadTime(int wordsPerMinute) {
    final seconds = wordCount / wordsPerMinute * 60;
    return Duration(seconds: seconds.round());
  }
}

Then drive the scrolling with a timer-based controller. Use a Timer.periodic rather than animateTo, because a timer can be paused and resumed mid-take while an animation cannot. Jump the scroll offset in small steps - 50 milliseconds is smooth enough that the eye reads it as continuous motion - and stop the timer when the offset reaches the bottom:

class PrompterController {
  PrompterController({required ScrollController scrollController})
      : _scrollController = scrollController;
  final ScrollController _scrollController;
  Timer? _timer;
  double _pixelsPerSecond = 0;
  void start({required int wordCount, required int wordsPerMinute}) {
    final totalSeconds = wordCount / wordsPerMinute * 60;
    pixelsPerSecond = _scrollController.position.maxScrollExtent / totalSeconds;
    _timer?.cancel();
    _timer = Timer.periodic(const Duration(milliseconds: 50), ( ) {
      if (!_scrollController.hasClients) return;
      final next = _scrollController.offset + _pixelsPerSecond * 0.05;
      if (next >= _scrollController.position.maxScrollExtent) {
        stop();
        return;
      }
      _scrollController.jumpTo(next);
    });
  }
  void pause() => _timer?.cancel();
  void stop() => _timer?.cancel();
  void restart() => _scrollController.jumpTo(0);
}

One more detail: add bottom padding to the script list equal to most of the screen height, so the final line can scroll to the top of the screen instead of stopping at the bottom edge. A typical speaking pace is 130 to 150 words per minute, so use 140 as the default.

How do I record video while the script scrolls?

Record video while the script scrolls by starting the camera controller's video recording and the scroller from the same button tap. The camera package records independently of the UI, so the script can keep scrolling while the controller writes the video file.

Start both in one method, and stop both in one method, so the recording and the script never drift out of sync:

Future startTake() async {
  if (_controller == null || !_controller!.value.isInitialized) return;
  if (_controller!.value.isRecordingVideo) return;
  await WakelockPlus.enable();
  await _controller!.startVideoRecording();
  _prompter.start(
    wordCount: _script.wordCount,
    wordsPerMinute: _wordsPerMinute,
  );
}

Future stopTake() async {
  if (_controller == null || !_controller!.value.isRecordingVideo) {
    return null;
  }
  _prompter.stop();
  await WakelockPlus.disable();
  return _controller!.stopVideoRecording();
}

Save the returned XFile to the app documents directory with path_provider. The recording continues even if the script reaches the end - the scroller stops, the camera keeps going - so stop the recording explicitly when the speaker finishes.

How do I make the script readable over the camera?

Make the script readable over the camera by drawing the text on a semi-transparent dark background with adjustable font size, side margins and overlay opacity. The camera feed behind the text is bright and busy, so plain white text on a live preview is unreadable; a dark scrim behind the text fixes that without hiding the speaker's face.

CueScript exposes all four controls - scroll speed, font size, side margins and overlay opacity - plus dark and light modes, because no single setting works for every face, room and lighting setup:

Container(
  color: Colors.black.withOpacity(opacity),
  padding: EdgeInsets.symmetric(horizontal: sideMargin),
  child: Text(
    script.text,
    style: TextStyle(fontSize: fontSize, color: Colors.white),
  ),
)

Bind the opacity slider directly to the scrim color so the speaker can tune it while looking at their own face on screen. The overlay is a Flutter widget drawn over the preview, not part of the video file, so sliders and buttons never appear in the finished video. And the script is never mirrored - it is a widget, not camera pixels - so it reads correctly on the front camera.

How do I import scripts from PDF and Word files?

Import scripts from PDF and Word files by letting the user pick a file with file_picker and then extracting the text with a parser package. Most speakers write in Word or Google Docs and export a PDF, so typing scripts by hand is the slow path.

CueScript imports from PDF and DOCX in one tap, and also accepts pasted text from notes, docs, email or AI writing tools, with a built-in editor for last-minute fixes before tapping Start:

Future<String?> pickScriptFile() async {
  final result = await FilePicker.platform.pickFiles(
    type: FileType.custom,
    allowedExtensions: ['pdf', 'docx', 'txt'],
  );
  return result?.files.single.path;
}

For extraction, use a PDF text-extraction package such as syncfusion_flutter_pdf for PDF files and docx_to_text for Word files, then store the plain text in the script model. Plain text files need no extraction. Always show the imported text in the editor before saving, because extraction can drop line breaks or footnotes.

How do I manage a library of scripts?

Manage a library of scripts by storing each script as a model with its title, text and last-edited date, and deriving the word count and estimated read time from the text instead of storing them. Derived values never go stale: edit the text and the read time updates itself.

CueScript saves unlimited scripts this way, finds them fast with search, and shows word count, last edit and estimated read time for every script, so the speaker knows how long the video will be before pressing record:

List<Script> searchScripts(List<Script> scripts, String query) {
  final q = query.trim().toLowerCase();
  if (q.isEmpty) return scripts;
  return scripts
      .where((s) => s.title.toLowerCase().contains(q) || s.text.toLowerCase().contains(q))
      .toList();
}

Store the scripts on device with no account - CueScript keeps everything in on-device storage - and sort the list by last edit so the current script is always at the top. The privacy-first offline app guide covers the same on-device pattern.

What mistakes should I avoid when building a teleprompter app?

Most teleprompter apps fail on the same handful of details:

  • Scrolling with animateTo - Pause does not work mid-take - Drive scrolling with a Timer and jumpTo
  • Forgetting wakelock - Screen locks mid-sentence - Enable wakelock_plus while recording
  • No bottom padding on the script - The last lines stop at the bottom edge - Pad the list by most of the screen height
  • Fixed font size and opacity - Text unreadable in bright rooms - Expose font size, margins and opacity controls
  • Storing the read time - Read time goes stale after an edit - Derive word count and read time from the text
  • Recording without audio - A silent video - Pass enableAudio: true to the CameraController

A teleprompter app is a small feature with an outsized payoff: one camera preview, one scrolling widget and one recording call turn a phone into a studio that keeps eye contact. Build it with the camera package, drive the scroll from words per minute, and keep the scripts on device - then record your next video in one take instead of ten.

Get in touch and let's talk about your project.

Originally published at uzairxdev.online

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.