runWatchedWidgetApp function
Future<void>
runWatchedWidgetApp(
- ReloadWidgetBuilder builder, {
- required Iterable<
String> watchRoots, - ReloadController? controller,
- ReloadMode watchMode = ReloadMode.reload,
- Duration watchDebounce = const Duration(milliseconds: 150),
- bool watchRecursive = true,
- bool watchIgnoreHidden = true,
- Iterable<
String> watchExtensions = const <String>['.dart'], - ProgramOptions? options,
- ProgramHost? host,
- ImageAutoMode? imageAutoMode,
Runs a reloadable WidgetApp and watches filesystem roots for changes.
This is a convenience wrapper around ReloadController, ReloadHost, and ReloadFileWatcher for local development loops.
Implementation
Future<void> runWatchedWidgetApp(
ReloadWidgetBuilder builder, {
required Iterable<String> watchRoots,
ReloadController? controller,
ReloadMode watchMode = ReloadMode.reload,
Duration watchDebounce = const Duration(milliseconds: 150),
bool watchRecursive = true,
bool watchIgnoreHidden = true,
Iterable<String> watchExtensions = const <String>['.dart'],
runtime.ProgramOptions? options,
hosts.ProgramHost? host,
ImageAutoMode? imageAutoMode,
}) async {
final reloadController = controller ?? ReloadController();
final ownsController = controller == null;
final watcher = await ReloadFileWatcher.watch(
controller: reloadController,
roots: watchRoots,
mode: watchMode,
debounce: watchDebounce,
recursive: watchRecursive,
ignoreHidden: watchIgnoreHidden,
extensions: watchExtensions,
);
try {
await runReloadableWidgetApp(
builder,
controller: reloadController,
options: options,
host: host,
imageAutoMode: imageAutoMode,
);
} finally {
await watcher.dispose();
if (ownsController) {
await reloadController.dispose();
}
}
}