A coach puts a phone on a tripod, selects a five-second delay and starts a training session. After each jump, the athlete turns around to watch the landing. When a jump is worth keeping, the coach taps “Save last clip”. Next time the app opens, the coach expects the five-second setting to be there.
From the coach’s perspective, this is one feature. For the developer, it involves three different jobs: deciding what “the last five seconds” means, remembering the setting, and getting footage from the camera. Those jobs explain the difference between a package, a plugin and a native feature in Flutter.
- A package is reusable code that a project can depend on. It might provide a calculation, a set of widgets or a networking library.
- A plugin is a package that gives Dart code access to a platform-specific implementation. It might open the camera or save a preference using the phone’s storage service.
- A native feature is a capability supplied by the platform, such as camera capture on a phone. A plugin is one way for Flutter to use that capability.
What is a Flutter package, and when do you need one?
Suppose a recording has been running for 12 seconds and the coach wants the most recent five. The interval starts at second 7 and ends at second 12. If only three seconds have been recorded, the earliest available start is zero. Dart can calculate both answers using the elapsed time and the requested duration. It needs no camera permission to do the arithmetic.
For one app, that calculation can live in an ordinary Dart function. If several apps need the same trimming rules and tests, putting them in a package lets each app use the same implementation. A package can stay private to a team or be published on pub.dev, the package registry for Dart and Flutter. Each app lists its dependencies in a file called pubspec.yaml.
“Written in Dart” describes the language. To know where a package runs, look at what it imports. A calculation using numbers and durations works across Flutter targets. A Dart utility that reads a desktop file using dart:io cannot use that same code path in a browser. The http package shows how a library can support both environments: it offers a common interface and selects a browser client on the web and an I/O client on other platforms.
What makes a package a plugin?
Now the coach closes the app. The number 5 in the running app’s memory is gone. To restore it tomorrow, the app needs somewhere to write the value and a way to read it back. The shared_preferences plugin gives Flutter a Dart interface for this job and uses the storage implementation available on each supported platform.
This is a useful example because it involves no sensor or camera. Plugins can also provide access to operating-system services. The developer asks to save a setting. The plugin handles how that request reaches the underlying store.
From the Flutter project directory, add the dependency with:
flutter pub add shared_preferences
These two functions illustrate the Dart side of the integration. A settings screen can call the first when the coach chooses a delay and the second when it needs to restore that choice.
import 'package:shared_preferences/shared_preferences.dart';
const replayDelayKey = 'replay_delay_seconds';
final preferences = SharedPreferencesAsync();
Future<void> saveReplayDelay(int seconds) async {
if (seconds != 5 && seconds != 10) {
throw ArgumentError.value(seconds, 'seconds', 'Choose 5 or 10 seconds');
}
await preferences.setInt(replayDelayKey, seconds);
}
Future<int> loadReplayDelay() async {
final saved = await preferences.getInt(replayDelayKey);
return saved == 10 ? 10 : 5;
}
On a first launch, there is no saved value, so the app uses five seconds. If the coach previously chose ten, it restores ten. The app defines which delays it offers. The plugin reads and writes the number. That small preference is a good fit for this storage API. Video clips belong in media or file storage, and the plugin documentation advises against using preferences for critical records. See the shared_preferences package documentation.
What happens when Flutter asks for the camera?
When the coach taps “Start camera”, a button changes on screen, but drawing a button gives the app no access to the lens. The app must request camera access, handle the answer, and initialise a camera that is actually available. Only then can it show a live preview.
The Flutter camera plugin provides operations for camera preview, still photos, video recording and image streaming. It lists Android, iOS and web support. On Android, its default endorsed implementation uses CameraX. On the web, the browser controls camera access and ordinarily requires a secure context such as HTTPS. A browser user can therefore face a different setup problem from someone using the installed Android app.
You may see several camera-related packages in the dependency list even though you added only camera. This is called a federated plugin. Your app uses the public Dart interface. Separate packages can implement that interface for Android, iOS or the browser. This matters when investigating a problem: if a capture option behaves differently on two phones, the documentation for the relevant platform implementation may explain why. Start with the camera plugin’s supported operations and setup.
Does “supports video recording” cover delayed replay?
Consider two acceptance tests. In the first, the coach presses Record, films a jump, presses Stop and plays the finished file. In the second, the athlete watches footage from five seconds ago while the camera keeps recording the next movement. Passing the first test leaves the hardest part of the second untested.
Delayed replay needs somewhere to hold recent footage, a way to play from an earlier point, and a way to export a clip while capture continues. A plugin might cover several of those operations. Its platform badge alone tells you little about whether they work together at the frame rate, resolution and session length your users need.
Before writing a custom integration, test the smallest version of the actual promise. Start capture, wait for the chosen delay, watch the replay, and save a clip while someone is still moving. Play back the exported file. Did it contain the landing the athlete just saw? That answer is more valuable than a successful recording demo.
When do you use a platform channel or direct native interop?
If a suitable plugin already exposes the operation and passes the device test, the team can use it. If the operating system or a camera manufacturer offers the operation but the plugin leaves it out, the team can connect Flutter to that API. Two common approaches are platform channels and direct native interoperability.
Use a platform channel for commands and events
A MethodChannel lets Dart send a named request to a handler on the host platform and receive a result or error. For example, a team could define a command called exportRecentClip. Dart would send the requested duration. The Android or iOS handler would call the relevant media API and return a reference to the saved file. Both sides must agree on the command, the unit of time and how failures are reported.
For a continuing sequence of updates, such as changes in capture status, an EventChannel provides a stream of events to Dart. In a replay app, one practical design is to send small commands and status updates across that boundary while the media implementation handles the video data. The Flutter platform channel guide shows how the Dart and host sides communicate.
Use direct bindings when an existing native library does the work
Suppose a supplier already has a clip-processing library. A binding describes its functions and data types so Dart can call them. On native targets, dart:ffi can call functions exposed through a C-compatible interface. A library written in C++ or Rust can expose such an interface, but having its compiled binary alone does not tell Dart how to call it.
Flutter 3.50 made direct bindings for Objective-C with ffigen and for Java and Kotlin with jnigen stable. That gives teams another route to an existing platform SDK. The choice depends on what the supplier exposes. A handful of commands implemented by your own Android and iOS code can suit a channel. An existing library with a well-defined native interface is a reason to evaluate generated bindings. Neither approach removes camera permissions or the need to test each target. See the Flutter 3.50 native interop announcement.
How do you evaluate a plugin before committing to it?
- Write down the operation the user must complete. “Save the last five seconds without stopping capture” gives you something to test. “Needs camera support” leaves too much open.
- Check each target and its setup. Read the platform list, minimum operating-system versions, permission requirements and implementation notes. Include the oldest device you intend to support.
- Try the refusal and return paths. Deny camera permission, then leave and reopen the app. The screen should explain what is available. The camera plugin makes the app responsible for handling lifecycle changes and managing its camera resources.
- Build again after adding native code. Hot reload updates Dart code. If a newly added plugin reports
MissingPluginException, stop the app and run a fresh build so its native implementation is included. If the error persists, check whether that platform implements the operation. - Run a realistic session on a real phone. A ten-second test can prove that capture starts. A session closer to an actual practice reveals whether heat, battery use, storage or interruptions affect the replay the athlete sees.
How this applies to a mobile MVP
When I built Instant Replay, the central question was whether a real phone could keep capturing a training session and show delayed playback within acceptable heat and battery limits. I started with a focused prototype before designing the full application. The camera and preferences examples above illustrate how to evaluate a similar Flutter feature. The lesson from the project is which behaviour to prove first.
If your app idea depends on a camera, sensor or specialist SDK, bring one concrete example of what the user must be able to do on a real device. I can help identify what an existing Flutter plugin covers, what needs a native prototype, and what that means for the first release. Explore my mobile development expertise.