Skip to content

feat: add the data bundle sample #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions packages/firebase_snippets_app/lib/snippets/firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
// ignore_for_file: non_constant_identifier_names, avoid_print

import 'dart:math';
import 'dart:typed_data';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_snippets_app/model/firestore_add_data_custom_objects_snippet.dart';
import 'package:firebase_snippets_app/model/restaurant.dart';
import 'package:firebase_snippets_app/snippets/snippet_base.dart';
import 'package:http/http.dart' as http;

class FirestoreSnippets extends DocSnippet {
@override
Expand Down Expand Up @@ -102,9 +104,26 @@ class FirestoreSnippets extends DocSnippet {
// [END data_model_sub_collections]
}

void dataBundles_loadingClientBundles() {
void dataBundles_loadingClientBundles() async {
// [START data_bundles_loading_client_bundles]
// TODO - currently in scratch file
// Get a bundle from a server
final url = Uri.https('example.com', '/create-bundle');
final response = await http.get(url);
String body = response.body;
final buffer = Uint8List.fromList(body.codeUnits);

// Load a bundle from a buffer
LoadBundleTask task = FirebaseFirestore.instance.loadBundle(buffer);
await task.stream.toList();

// Use the cached named query
final results = await FirebaseFirestore.instance.namedQueryGet(
"latest-stories-query",
options: const GetOptions(
source: Source.cache,
),
);

// [END data_bundles_loading_client_bundles]
}

Expand Down
6 changes: 3 additions & 3 deletions packages/firebase_snippets_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,13 @@ packages:
source: hosted
version: "2.3.0"
http:
dependency: transitive
dependency: "direct main"
description:
name: http
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.2.2"
http_multi_server:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions packages/firebase_snippets_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies:
crypto: ^3.0.1
firebase_crashlytics: ^3.3.0
firebase_auth_platform_interface: ^7.3.0
http: ^1.2.2
win32: ^5.5.4

dev_dependencies:
Expand Down
Loading