V- Modal AI: Visual Video / Image Search - Flutter Video SDK
Dart android-sdkflutterflutter-appflutter-packageflutter-sdkflutter-videoflutter-video-editingflutter-video-playerflutter-video-sdkflutter-videosflutter-videosdkmobile-videomobile-video-editor-sdkmobile-video-sdkvideo-editingvideo-sdkvideo-searchvideo-search-enginevideo-streaming
Enhance Framebase with travel video search
Podyriako Bohdanbd0b02bcfc67
diff --git a/example/05_framebase/README.md b/example/05_framebase/README.mdindex e2f251a..ba53f06 100644--- a/example/05_framebase/README.md+++ b/example/05_framebase/README.md@@ -1,20 +1,20 @@# FramebaseFramebase is a product-style Flutter example for finding moments inside a-small video library with natural-language visual search. It demonstrates the-complete mobile flow: runtime authentication, streamed uploads, asynchronous-indexing, grouped frame results, and playback of the local source video at the-returned timestamp.+small travel-video library with natural-language or reference-photo search.+It demonstrates the complete mobile flow: runtime authentication,+metadata-aware streamed uploads, asynchronous indexing, trip-scoped grouped+results, and playback of the local source video at the returned timestamp.-The bundled library contains three short city-street recordings. Try searches-such as `A bus on a city street`, `People crossing the street`, or-`Cars at an intersection`.+The bundled library contains three short city-street recordings. Filter it by+city, try a query such as `A bus on a city street`, or choose a reference photo+to retrieve visually similar moments from the selected trip.## Screenshots-| Library | Grouped search results | Source playback |+| Travel library | Selected trip | Reference-photo results || --- | --- | --- |-|  |  |  |+|  |  |  |## Run the example@@ -52,9 +52,11 @@ than 100 MB and are copied into the app's support directory before upload.- `MutableApiKeyProvider` and `auth.me()` for runtime authentication.- `UploadSource.fromFile`, upload progress, and cancellation.+- Caller-selected filenames and searchable title/place upload metadata.- Image-index creation and status polling.- Collection-version discovery before search.-- Natural-language video search with an explicit distance cutoff.+- Text and base64 reference-image search with an explicit distance cutoff.+- Client-side trip scoping before frame retrieval.- One bulk URL lookup followed by cancellable image retrieval.- Defensive mapping of filenames, result indexes, and relative timestamps.- Grouping nearby matches from the same source video.@@ -81,10 +83,11 @@ bash build.sh analyzebash build.sh test```-Framebase has offline tests for result mapping, timestamp handling, cancellation,-cutoff enforcement, narrow layouts, grouped results, runtime-key error handling,-and navigation. Live upload, indexing, search, and playback require an API key-and a physical device or emulator.+Framebase has offline tests for result mapping, reference-image request mapping,+trip scoping, import validation, timestamp handling, cancellation, cutoff+enforcement, narrow layouts, grouped results, runtime-key error handling, and+navigation. Live upload, indexing, search, and playback require an API key and+a physical device or emulator.Android was validated on a physical device. The iOS project is included, butiOS runtime validation requires macOS and Xcode.diff --git a/example/05_framebase/lib/data/archive_controller.dart b/example/05_framebase/lib/data/archive_controller.dartindex 45ad6dc..09369ba 100644--- a/example/05_framebase/lib/data/archive_controller.dart+++ b/example/05_framebase/lib/data/archive_controller.dart@@ -265,16 +265,27 @@ class ArchiveController extends ChangeNotifier {return file;}- Future<void> importFile(String path, double duration) async {+ Future<void> importFile(+ String path,+ double duration, {+ String? title,+ String? place,+ }) async {_directory ??= await getApplicationSupportDirectory();final id = 'street_${DateTime.now().millisecondsSinceEpoch}';final file = await File(path).copy('${_directory!.path}/$id.mp4');final sourceName = basename(path);+ final displayTitle = title?.trim().isNotEmpty == true+ ? title!.trim()+ : sourceName;+ final displayPlace = place?.trim().isNotEmpty == true+ ? place!.trim()+ : 'Unsorted trip';clips.add(ArchiveClip(id: id,- title: sourceName,- location: 'Imported recording',+ title: displayTitle,+ location: '$displayPlace · Imported',duration: duration,asset: '',poster: '',@@ -284,7 +295,7 @@ class ArchiveController extends ChangeNotifier {);invalidateSearch();await save();- record('Recording added', '$sourceName · stored on device only');+ record('Recording added', '$displayTitle · $displayPlace');}ArchiveClip? clipFor(String filename) {@@ -316,7 +327,11 @@ class ArchiveController extends ChangeNotifier {emit();final file = await localFile(clip);token.throwIfCanceled();- final task = gateway.upload(file);+ final task = gateway.upload(+ file,+ title: clip.title,+ place: clip.location.split(' · ').first,+ );_upload = task;final watch = Stopwatch()..start();final subscription = task.progress.listen((p) {@@ -438,11 +453,16 @@ class ArchiveController extends ChangeNotifier {emit();}- Future<void> search(String query, {double maxDistance = 1.5}) async {+ Future<void> search(+ String query, {+ double maxDistance = 1.5,+ String? place,+ String? imageQuery,+ }) async {final gateway = _gateway;if (gateway == null ||indexVersion == null ||- query.trim().isEmpty ||+ (query.trim().isEmpty && imageQuery == null) ||busy) {return;}@@ -451,14 +471,21 @@ class ArchiveController extends ChangeNotifier {final token = CancellationToken();_queryToken = token;searching = true;- activeQuery = query.trim();+ activeQuery = query.trim().isEmpty ? 'Reference photo' : query.trim();notice = '';emit();try {final result = await gateway.search(- activeQuery,+ query.trim(),cancellation: token,maxDistance: maxDistance,+ imageQuery: imageQuery,+ allowedFilenames: place == null+ ? null+ : clips+ .where((clip) => clip.location.split(' · ').first == place)+ .expand((clip) => [clip.id, clip.filename])+ .toSet(),);if (_disposed || generation != _searchGeneration) return;batch = result;diff --git a/example/05_framebase/lib/data/search_gateway.dart b/example/05_framebase/lib/data/search_gateway.dartindex a04fd8b..7aa6413 100644--- a/example/05_framebase/lib/data/search_gateway.dart+++ b/example/05_framebase/lib/data/search_gateway.dart@@ -144,12 +144,20 @@ class SearchGateway {?.latestLancedbVersion;}- UploadTask<VideoUploadResponse> upload(File file) =>- client.collections.videoUpload(- UploadSource.fromFile(file),- collectionName: archiveCollection,- subCollectionName: archiveStream,- );+ UploadTask<VideoUploadResponse> upload(+ File file, {+ required String title,+ required String place,+ }) => client.collections.videoUpload(+ UploadSource.fromFile(file),+ collectionName: archiveCollection,+ subCollectionName: archiveStream,+ options: VideoUploadOptions(+ videoFilename: basename(file.path),+ metadataText: '$title $place',+ metadataTags: ['travel', place.toLowerCase()],+ ),+ );Future<IndexationSubmitResponse> createIndex(CancellationToken cancellation,@@ -175,6 +183,7 @@ class SearchGateway {CancellationToken? cancellation,String? imageQuery,double maxDistance = 1.5,+ Set<String>? allowedFilenames,}) async {final token = cancellation ?? CancellationToken();final timer = Stopwatch()..start();@@ -199,9 +208,14 @@ class SearchGateway {.toList();// Enforce the displayed cutoff defensively on returned rows as well.// A client-filtered result is distinct from the raw server result count.+ final allowed = allowedFilenames+ ?.map((name) => basename(name).toLowerCase())+ .toSet();final usable = rows.where((r) {final distance = num.tryParse('${r['score']}');- return hitFilename(r).isNotEmpty &&+ final filename = hitFilename(r);+ return filename.isNotEmpty &&+ (allowed == null || allowed.contains(filename.toLowerCase())) &&distance != null &&distance.isFinite &&distance <= maxDistance;diff --git a/example/05_framebase/lib/main.dart b/example/05_framebase/lib/main.dartindex 9dd93a5..0aefe95 100644--- a/example/05_framebase/lib/main.dart+++ b/example/05_framebase/lib/main.dart@@ -1,4 +1,5 @@import 'dart:async';+import 'dart:convert';import 'dart:io';import 'dart:ui';import 'package:file_selector/file_selector.dart';@@ -119,6 +120,13 @@ class LibraryPage extends StatefulWidget {class _LibraryPageState extends State<LibraryPage> {late final ArchiveController archive;+ String? selectedPlace;++ List<String> get places => archive.clips.map(city).toSet().toList()..sort();++ List<ArchiveClip> get visibleClips => selectedPlace == null+ ? archive.clips+ : archive.clips.where((clip) => city(clip) == selectedPlace).toList();@overridevoid initState() {super.initState();@@ -138,7 +146,9 @@ class _LibraryPageState extends State<LibraryPage> {void openSearch() => Navigator.push(context,- MaterialPageRoute<void>(builder: (_) => SearchPage(archive: archive)),+ MaterialPageRoute<void>(+ builder: (_) => SearchPage(archive: archive, place: selectedPlace),+ ),);Future<void> importVideo() async {@@ -161,11 +171,17 @@ class _LibraryPageState extends State<LibraryPage> {}player = VideoPlayerController.file(File(file.path));await player.initialize().timeout(const Duration(seconds: 15));+ if (!mounted) return;+ final details = await showImportDetails(context, basename(file.path));+ if (!mounted || details == null) return;await archive.importFile(file.path,player.value.duration.inMilliseconds / 1000,+ title: details.title,+ place: details.place,);if (mounted) {+ setState(() => selectedPlace = details.place);ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text(@@ -254,20 +270,29 @@ class _LibraryPageState extends State<LibraryPage> {children: [Row(children: [- const Expanded(+ Expanded(child: Text(- 'Street footage',- style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),+ selectedPlace ?? 'Travel footage',+ style: const TextStyle(+ fontSize: 16,+ fontWeight: FontWeight.w600,+ ),),),Text(- '${archive.clips.length} videos',+ '${visibleClips.length} ${visibleClips.length == 1 ? 'video' : 'videos'}',style: const TextStyle(color: secondary),),],),- const SizedBox(height: 12),- for (final clip in archive.clips)+ const SizedBox(height: 10),+ PlaceRail(+ places: places,+ selected: selectedPlace,+ onSelected: (place) => setState(() => selectedPlace = place),+ ),+ const SizedBox(height: 14),+ for (final clip in visibleClips)VideoRow(clip: clip,onTap: () => showRecording(context, archive, clip),@@ -308,7 +333,12 @@ class _LibraryPageState extends State<LibraryPage> {bottomNavigationBar: SafeArea(child: Padding(padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),- child: SearchDock(onTap: openSearch),+ child: SearchDock(+ label: selectedPlace == null+ ? 'Search all trips'+ : 'Search $selectedPlace',+ onTap: openSearch,+ ),),),),@@ -356,8 +386,75 @@ class _BrandPainter extends CustomPainter {bool shouldRepaint(covariant CustomPainter oldDelegate) => false;}+class PlaceRail extends StatelessWidget {+ const PlaceRail({+ super.key,+ required this.places,+ required this.selected,+ required this.onSelected,+ });+ final List<String> places;+ final String? selected;+ final ValueChanged<String?> onSelected;++ @override+ Widget build(BuildContext context) {+ final items = <String?>[null, ...places];+ return SizedBox(+ height: 42,+ child: ListView.separated(+ scrollDirection: Axis.horizontal,+ itemCount: items.length,+ separatorBuilder: (_, _) => const SizedBox(width: 7),+ itemBuilder: (_, index) {+ final place = items[index];+ final active = place == selected;+ return Material(+ color: active ? ink : const Color(0xFFDFDCD4),+ borderRadius: BorderRadius.circular(14),+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ key: Key(place == null ? 'place_all' : 'place_$place'),+ onTap: () => onSelected(place),+ child: AnimatedPadding(+ duration: const Duration(milliseconds: 160),+ padding: EdgeInsets.symmetric(+ horizontal: active ? 16 : 14,+ vertical: 10,+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ if (active) ...[+ const Icon(+ Icons.location_on_outlined,+ size: 16,+ color: Color(0xFFF2B28F),+ ),+ const SizedBox(width: 6),+ ],+ Text(+ place ?? 'All trips',+ style: TextStyle(+ color: active ? Colors.white : ink,+ fontSize: 13,+ fontWeight: FontWeight.w600,+ ),+ ),+ ],+ ),+ ),+ ),+ );+ },+ ),+ );+ }+}+class SearchDock extends StatelessWidget {- const SearchDock({super.key, required this.onTap});+ const SearchDock({super.key, required this.label, required this.onTap});+ final String label;final VoidCallback onTap;@overrideWidget build(BuildContext context) => DecoratedBox(@@ -393,10 +490,12 @@ class SearchDock extends StatelessWidget {children: [const Icon(Icons.search, color: Colors.white, size: 23),const SizedBox(width: 12),- const Expanded(+ Expanded(child: Text(- 'Search your videos',- style: TextStyle(+ label,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(fontSize: 16,fontWeight: FontWeight.w500,color: Colors.white,@@ -426,6 +525,103 @@ class SearchDock extends StatelessWidget {);}+class PlaceContext extends StatelessWidget {+ const PlaceContext({super.key, required this.place});+ final String place;++ @override+ Widget build(BuildContext context) => DecoratedBox(+ decoration: BoxDecoration(+ color: const Color(0xFFFFE2D2),+ borderRadius: BorderRadius.circular(14),+ border: Border.all(color: const Color(0x33AA4F2D)),+ ),+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 10),+ child: Row(+ children: [+ const Icon(Icons.location_on_outlined, size: 18, color: green),+ const SizedBox(width: 8),+ Expanded(+ child: Text(+ 'Searching in $place',+ style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600),+ ),+ ),+ ],+ ),+ ),+ );+}++class ReferenceImageContext extends StatelessWidget {+ const ReferenceImageContext({+ super.key,+ required this.name,+ required this.onRemove,+ });++ final String name;+ final VoidCallback onRemove;++ @override+ Widget build(BuildContext context) => DecoratedBox(+ decoration: BoxDecoration(+ color: const Color(0xFFDFDCD4),+ borderRadius: BorderRadius.circular(14),+ border: Border.all(color: const Color(0x24706F67)),+ ),+ child: Padding(+ padding: const EdgeInsets.fromLTRB(13, 8, 5, 8),+ child: Row(+ children: [+ Container(+ width: 34,+ height: 34,+ decoration: BoxDecoration(+ color: const Color(0xFFFFE2D2),+ borderRadius: BorderRadius.circular(10),+ ),+ child: const Icon(+ Icons.image_search_outlined,+ size: 19,+ color: green,+ ),+ ),+ const SizedBox(width: 10),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ const Text(+ 'Reference photo',+ style: TextStyle(fontSize: 12, color: secondary),+ ),+ const SizedBox(height: 2),+ Text(+ name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(+ fontSize: 14,+ fontWeight: FontWeight.w600,+ ),+ ),+ ],+ ),+ ),+ IconButton(+ key: const Key('remove_reference_image'),+ tooltip: 'Remove reference photo',+ onPressed: onRemove,+ icon: const Icon(Icons.close, size: 19),+ ),+ ],+ ),+ ),+ );+}+class VideoRow extends StatelessWidget {const VideoRow({super.key, required this.clip, required this.onTap});final ArchiveClip clip;@@ -591,8 +787,9 @@ Map<String, List<FrameMatch>> groupMoments(List<FrameMatch> hits) {}class SearchPage extends StatefulWidget {- const SearchPage({super.key, required this.archive});+ const SearchPage({super.key, required this.archive, this.place});final ArchiveController archive;+ final String? place;@overrideState<SearchPage> createState() => _SearchPageState();}@@ -600,6 +797,8 @@ class SearchPage extends StatefulWidget {class _SearchPageState extends State<SearchPage> {final query = TextEditingController();bool broad = false;+ String? imageName;+ String? imageQuery;final expandedVideos = <String>{};ArchiveController get archive => widget.archive;@override@@ -618,7 +817,7 @@ class _SearchPageState extends State<SearchPage> {expandedVideos.clear();if (text != null) query.text = text;FocusManager.instance.primaryFocus?.unfocus();- if (query.text.trim().isEmpty) return;+ if (query.text.trim().isEmpty && imageQuery == null) return;if (archive.connecting) return;if (!archive.connected) {await showConnection(context, archive);@@ -628,7 +827,41 @@ class _SearchPageState extends State<SearchPage> {await prepareArchive(context, archive);return;}- await archive.search(query.text, maxDistance: broad ? 1.5 : .85);+ await archive.search(+ query.text,+ maxDistance: broad ? 1.5 : .85,+ place: widget.place,+ imageQuery: imageQuery,+ );+ }++ Future<void> chooseReferenceImage() async {+ final file = await openFile(+ acceptedTypeGroups: [+ const XTypeGroup(+ label: 'Reference image',+ extensions: ['jpg', 'jpeg', 'png', 'webp'],+ mimeTypes: ['image/jpeg', 'image/png', 'image/webp'],+ uniformTypeIdentifiers: ['public.image'],+ ),+ ],+ );+ if (file == null) return;+ final bytes = await file.readAsBytes();+ if (bytes.length > 10 * 1024 * 1024) {+ if (mounted) {+ ScaffoldMessenger.of(context).showSnackBar(+ const SnackBar(content: Text('Choose an image smaller than 10 MB.')),+ );+ }+ return;+ }+ if (!mounted) return;+ setState(() {+ imageName = basename(file.path);+ imageQuery = base64Encode(bytes);+ });+ archive.invalidateSearch();}void options() => showModalBottomSheet<void>(@@ -687,6 +920,16 @@ class _SearchPageState extends State<SearchPage> {onChanged: (_) => archive.invalidateSearch(),onSubmitted: (_) => search(),trailing: [+ IconButton(+ key: const Key('image_search'),+ tooltip: 'Search with a photo',+ onPressed: archive.searching ? null : chooseReferenceImage,+ icon: Icon(+ imageQuery == null+ ? Icons.add_photo_alternate_outlined+ : Icons.image_outlined,+ ),+ ),IconButton(key: const Key('run_search'),tooltip: archive.searching ? 'Cancel search' : 'Search',@@ -714,6 +957,25 @@ class _SearchPageState extends State<SearchPage> {child: ListView(padding: const EdgeInsets.fromLTRB(16, 12, 16, 32),children: [+ if (widget.place != null)+ Padding(+ padding: const EdgeInsets.only(bottom: 14),+ child: PlaceContext(place: widget.place!),+ ),+ if (imageQuery != null)+ Padding(+ padding: const EdgeInsets.only(bottom: 14),+ child: ReferenceImageContext(+ name: imageName ?? 'Reference photo',+ onRemove: () {+ setState(() {+ imageName = null;+ imageQuery = null;+ });+ archive.invalidateSearch();+ },+ ),+ ),if (archive.busy) WorkStatus(archive: archive),if (batch == null && !archive.searching) ...[const Padding(@@ -1198,6 +1460,133 @@ class PlaybackControls extends StatelessWidget {}}+class ImportDetails {+ const ImportDetails({required this.title, required this.place});+ final String title;+ final String place;+}++String readableFilename(String path) {+ final name = basename(path).replaceFirst(RegExp(r'\.[^.]+$'), '');+ if (name.isEmpty) return 'Travel recording';+ return name+ .replaceAll(RegExp(r'[_-]+'), ' ')+ .split(' ')+ .where((part) => part.isNotEmpty)+ .map((part) => '${part[0].toUpperCase()}${part.substring(1)}')+ .join(' ');+}++Future<ImportDetails?> showImportDetails(+ BuildContext context,+ String sourceName,+) => showModalBottomSheet<ImportDetails>(+ context: context,+ isScrollControlled: true,+ useSafeArea: true,+ builder: (_) => ImportDetailsSheet(sourceName: sourceName),+);++class ImportDetailsSheet extends StatefulWidget {+ const ImportDetailsSheet({super.key, required this.sourceName});+ final String sourceName;++ @override+ State<ImportDetailsSheet> createState() => _ImportDetailsSheetState();+}++class _ImportDetailsSheetState extends State<ImportDetailsSheet> {+ late final TextEditingController title;+ final place = TextEditingController();+ bool showErrors = false;++ @override+ void initState() {+ super.initState();+ title = TextEditingController(text: readableFilename(widget.sourceName));+ }++ @override+ void dispose() {+ title.dispose();+ place.dispose();+ super.dispose();+ }++ void add() {+ final cleanTitle = title.text.trim();+ final cleanPlace = place.text.trim();+ if (cleanTitle.isEmpty || cleanPlace.isEmpty) {+ setState(() => showErrors = true);+ return;+ }+ Navigator.pop(context, ImportDetails(title: cleanTitle, place: cleanPlace));+ }++ @override+ Widget build(BuildContext context) => Padding(+ padding: EdgeInsets.fromLTRB(+ 20,+ 0,+ 20,+ MediaQuery.viewInsetsOf(context).bottom + 20,+ ),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ const Text(+ 'Add to a trip',+ style: TextStyle(fontSize: 22, fontWeight: FontWeight.w600),+ ),+ const SizedBox(height: 6),+ const Text(+ 'The place stays with the recording and can be used to narrow search.',+ style: TextStyle(color: secondary),+ ),+ const SizedBox(height: 20),+ TextField(+ key: const Key('import_title'),+ controller: title,+ textCapitalization: TextCapitalization.sentences,+ decoration: InputDecoration(+ labelText: 'Recording name',+ errorText: showErrors && title.text.trim().isEmpty+ ? 'Enter a name'+ : null,+ border: const OutlineInputBorder(),+ ),+ ),+ const SizedBox(height: 12),+ TextField(+ key: const Key('import_place'),+ controller: place,+ autofocus: true,+ textCapitalization: TextCapitalization.words,+ onSubmitted: (_) => add(),+ decoration: InputDecoration(+ labelText: 'City or trip',+ hintText: 'Lisbon',+ errorText: showErrors && place.text.trim().isEmpty+ ? 'Enter a place'+ : null,+ border: const OutlineInputBorder(),+ ),+ ),+ const SizedBox(height: 18),+ SizedBox(+ width: double.infinity,+ child: FilledButton(+ key: const Key('add_to_trip'),+ onPressed: add,+ child: const Text('Add recording'),+ ),+ ),+ ],+ ),+ );+}+Future<void> showConnection(BuildContext context, ArchiveController archive) =>showModalBottomSheet<void>(context: context,diff --git a/example/05_framebase/pubspec.yaml b/example/05_framebase/pubspec.yamlindex 441f535..ee4d5ee 100644--- a/example/05_framebase/pubspec.yaml+++ b/example/05_framebase/pubspec.yaml@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html# In Windows, build-name is used as the major, minor, and patch parts# of the product and file versions while build-number is used as the build suffix.-version: 1.2.1+4+version: 1.3.0+5environment:sdk: ^3.12.2diff --git a/example/05_framebase/readme_assets/library.png b/example/05_framebase/readme_assets/library.pngindex 0d69fe2..f85fceb 100644Binary files a/example/05_framebase/readme_assets/library.png and b/example/05_framebase/readme_assets/library.png differdiff --git a/example/05_framebase/readme_assets/photo_search.png b/example/05_framebase/readme_assets/photo_search.pngnew file mode 100644index 0000000..df3be43Binary files /dev/null and b/example/05_framebase/readme_assets/photo_search.png differdiff --git a/example/05_framebase/readme_assets/trip.png b/example/05_framebase/readme_assets/trip.pngnew file mode 100644index 0000000..57eefa4Binary files /dev/null and b/example/05_framebase/readme_assets/trip.png differdiff --git a/example/05_framebase/test/search_gateway_test.dart b/example/05_framebase/test/search_gateway_test.dartindex 3ac6805..d16771d 100644--- a/example/05_framebase/test/search_gateway_test.dart+++ b/example/05_framebase/test/search_gateway_test.dart@@ -143,6 +143,63 @@ void main() {await gateway.close();});+ test(+ 'reference photo search keeps only recordings from the selected trip',+ () async {+ const route = '/api/external/v1/image/get_image';+ final transport = QueueTransport([+ {+ 'data': [+ {+ 'filename': 'downtown_traffic.mp4',+ 'ts_unix': '0000000008000',+ 'score': .62,+ },+ {+ 'filename': 'evening_junction.mp4',+ 'ts_unix': '0000000010000',+ 'score': .58,+ },+ ],+ 'cnt_total': 2,+ },+ {+ 'records': [+ {+ 'input_index': 0,+ 'found': true,+ 'url_pre_signed': '$route?test=singapore',+ },+ ],+ },+ {+ 'records': [+ {+ 'url_pre_signed': '$route?test=singapore',+ 'content_base64': base64Encode([7, 8, 9]),+ },+ ],+ },+ ]);+ final gateway = SearchGateway(+ 'test-only-placeholder',+ transport: transport,+ );+ final result = await gateway.search(+ '',+ imageQuery: 'base64-reference',+ allowedFilenames: {'downtown_traffic.mp4'},+ );+ expect(result.matches, hasLength(1));+ expect(result.matches.single.filename, 'downtown_traffic.mp4');+ expect(result.matches.single.imageBytes, [7, 8, 9]);+ final body = transport.requests.first.jsonBody as Map;+ expect(body['query_text'], '');+ expect(body['image_query'], 'base64-reference');+ await gateway.close();+ },+ );+test('client cutoff rejects out-of-threshold beta results before downloading',() async {diff --git a/example/05_framebase/test/widget_test.dart b/example/05_framebase/test/widget_test.dartindex 625e2e0..2c4cee2 100644--- a/example/05_framebase/test/widget_test.dart+++ b/example/05_framebase/test/widget_test.dart@@ -78,6 +78,36 @@ void main() {expect(input.enableSuggestions, isFalse);c.dispose();});+ testWidgets('trip selection narrows the library and carries into search', (+ tester,+ ) async {+ final c = ArchiveController(persist: false);+ await tester.pumpWidget(FramebaseApp(controller: c));+ await tester.pumpAndSettle();+ await tester.tap(find.byKey(const Key('place_Singapore')));+ await tester.pumpAndSettle();+ expect(find.byType(VideoRow), findsOneWidget);+ expect(find.text('Downtown traffic'), findsOneWidget);+ expect(find.text('Neighborhood crossing'), findsNothing);+ expect(find.text('Search Singapore'), findsOneWidget);+ await tester.tap(find.byKey(const Key('open_search')));+ await tester.pumpAndSettle();+ expect(find.text('Searching in Singapore'), findsOneWidget);+ c.dispose();+ });+ testWidgets('import details require a human title and trip', (tester) async {+ await tester.pumpWidget(+ const MaterialApp(+ home: Scaffold(+ body: ImportDetailsSheet(sourceName: 'old_town-walk.mp4'),+ ),+ ),+ );+ expect(find.widgetWithText(TextField, 'Old Town Walk'), findsOneWidget);+ await tester.tap(find.byKey(const Key('add_to_trip')));+ await tester.pump();+ expect(find.text('Enter a place'), findsOneWidget);+ });testWidgets('320px layout and secondary history route', (tester) async {tester.view.physicalSize = const Size(320, 680);tester.view.devicePixelRatio = 1;