This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
457 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:api_client/api_client.dart'; | ||
|
||
Future<void> main() async { | ||
final apiClient = ApiClient( | ||
baseUrl: 'http://development', | ||
idTokenStream: const Stream.empty(), | ||
refreshIdToken: () async => Future.value(), | ||
); | ||
final questionsResource = apiClient.questionsResource; | ||
final answer = await questionsResource.getVertexResponse('random'); | ||
// ignore: avoid_print | ||
print(answer); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'vertex_document.dart'; | ||
export 'vertex_metadata.dart'; | ||
export 'vertex_response.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:api_client/api_client.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'vertex_document.g.dart'; | ||
|
||
/// {@template vertex_document} | ||
/// Vertex document | ||
/// {@endtemplate} | ||
@JsonSerializable(createToJson: false) | ||
class VertexDocument extends Equatable { | ||
/// {@macro vertex_document} | ||
const VertexDocument({ | ||
required this.metadata, | ||
}); | ||
|
||
/// Convert from Map<String, dynamic> to [VertexDocument] | ||
factory VertexDocument.fromJson(Map<String, dynamic> json) => | ||
_$VertexDocumentFromJson(json); | ||
|
||
/// Metadata. | ||
final VertexMetadata metadata; | ||
|
||
@override | ||
List<Object?> get props => [metadata]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:api_client/api_client.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'vertex_metadata.g.dart'; | ||
|
||
/// {@template vertex_metadata} | ||
/// Vertex metadata inside a [VertexDocument] | ||
/// {@endtemplate} | ||
@JsonSerializable(createToJson: false) | ||
class VertexMetadata extends Equatable { | ||
/// {@macro vertex_metadata} | ||
const VertexMetadata({ | ||
required this.url, | ||
required this.title, | ||
required this.description, | ||
}); | ||
|
||
/// Convert from Map<String, dynamic> to [VertexMetadata] | ||
factory VertexMetadata.fromJson(Map<String, dynamic> json) => | ||
_$VertexMetadataFromJson(json); | ||
|
||
/// Url | ||
final String url; | ||
|
||
/// Title | ||
final String title; | ||
|
||
/// Description | ||
final String description; | ||
|
||
@override | ||
List<Object?> get props => [url, title, description]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:api_client/api_client.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'vertex_response.g.dart'; | ||
|
||
/// {@template vertex_response} | ||
/// Vertex response | ||
/// {@endtemplate} | ||
@JsonSerializable(createToJson: false) | ||
class VertexResponse extends Equatable { | ||
/// {@macro vertex_response} | ||
const VertexResponse({ | ||
required this.summary, | ||
required this.documents, | ||
}); | ||
|
||
/// Convert from Map<String, dynamic> to [VertexResponse] | ||
factory VertexResponse.fromJson(Map<String, dynamic> json) => | ||
_$VertexResponseFromJson(json); | ||
|
||
/// Summary. | ||
final String summary; | ||
|
||
/// Documents. | ||
final List<VertexDocument> documents; | ||
|
||
@override | ||
List<Object?> get props => [ | ||
summary, | ||
documents, | ||
]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
168 changes: 168 additions & 0 deletions
168
packages/api_client/lib/src/resources/fake_response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
{ | ||
"summary": "Hot reload loads code changes into the VM and re-builds the widget tree, preserving the app state [1]. Hot restart loads code changes into the VM, and restarts the Flutter app, losing the app state [1].", | ||
"total_size": 701, | ||
"attribution_token": "W_BaCgwIiN6vqgYQ5O6q0AMSJDY1NDNiODJhLTAwMDAtMjA3NS05YmQyLTE0YzE0ZWY0ZWVmMCIHR0VORVJJQyocpovvF8XL8xecho4iooaOIsLwnhXUsp0Vjr6dFQ", | ||
"next_page_token": "AjZlVGNmVGNxMGNx0iMkJWOtUzNwITLwADMw0SOygjYzQTN2QiGCEM9JyMEGo6vHrICMIBMxIgC", | ||
"documents": [ | ||
{ | ||
"id": "fee364b1-5b75-4042-9669-2bd123364094", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/tools/hot-reload", | ||
"title": "Hot reload | Flutter", | ||
"tags": "missing", | ||
"keywords": "", | ||
"description": "Speed up development using Flutter's hot reload feature.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/tools/hot-reload", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-tools-hot-reload.html", | ||
"snippets": [ | ||
"... <b>What is the difference between hot reload</b>, <b>hot restart</b>, and full restart? Hot reload loads code changes into the VM and re-builds the widget tree ..." | ||
] | ||
}, | ||
{ | ||
"id": "8fec71e3-4dbb-4948-b3ca-ec13af65691e", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/tools/vs-code", | ||
"title": "Visual Studio Code | Flutter", | ||
"tags": "fake", | ||
"keywords": "", | ||
"description": "How to develop Flutter apps in Visual Studio Code.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/tools/vs-code", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-tools-vs-code.html", | ||
"snippets": [ | ||
"... <b>with a</b> placeholder Play ... command from the Command Palette. <b>Hot reload</b> vs. <b>hot restart Hot reload</b> works by injecting updated source code files into the running ..." | ||
] | ||
}, | ||
{ | ||
"id": "e5e6bfd4-6da8-44a9-8ced-5a9493960087", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/tools/android-studio", | ||
"title": "Android Studio and IntelliJ | Flutter", | ||
"tags": "missing", | ||
"keywords": "", | ||
"description": "How to develop Flutter apps in Android Studio or other IntelliJ products.\n", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/tools/android-studio", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-tools-android-studio.html", | ||
"snippets": [ | ||
"... <b>between</b> Android Studio and IntelliJ. In Android Studio: <b>In the</b> IDE, click ... <b>Hot reload</b> vs. <b>hot restart Hot reload</b> works by injecting updated source code files ..." | ||
] | ||
}, | ||
{ | ||
"id": "b5103539-2e8f-4450-952b-b21428972bb5", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/platform-integration/web/faq", | ||
"title": "Web FAQ | Flutter", | ||
"tags": "unknown", | ||
"keywords": "", | ||
"description": "Some gotchas and differences when writing or running web apps in Flutter.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/platform-integration/web/faq", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-platform-integration-web-faq.html", | ||
"snippets": [ | ||
"See building a web app with Flutter. Does <b>hot reload</b> work <b>with a</b> web app? No ... feature for Flutter mobile development. The only <b>difference</b> is that <b>hot reload</b> ..." | ||
] | ||
}, | ||
{ | ||
"id": "aa9bb7db-a635-4a85-b7ca-239a9386b53f", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/add-to-app/debugging", | ||
"title": "Debug your add-to-app module | Flutter", | ||
"tags": "fake", | ||
"keywords": "", | ||
"description": "How to run, debug, and hot reload your add-to-app Flutter module.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/add-to-app/debugging", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-add-to-app-debugging.html", | ||
"snippets": [ | ||
"... <b>with a</b> placeholder Play and pause a video Navigation & routing Overview Add ... <b>Hot reload</b> Profiling Install Flutter DevTools Cookbook Codelabs Get started ..." | ||
] | ||
}, | ||
{ | ||
"id": "b3559279-c9a9-4349-9fa6-5afbb30b572e", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/testing/build-modes", | ||
"title": "Flutter's build modes | Flutter", | ||
"tags": "missing", | ||
"keywords": "", | ||
"description": "Describes Flutter's build modes and when you should use debug, release, or profile mode.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/testing/build-modes", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-testing-build-modes.html", | ||
"snippets": [ | ||
"... <b>with a</b> placeholder Play and pause a video Navigation & routing ... <b>Hot reload</b> Profiling Install Flutter DevTools Cookbook Codelabs Get started Flutter 3.13 ..." | ||
] | ||
}, | ||
{ | ||
"id": "c0c9df6a-7f18-439b-b55a-269230829dc7", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/packages-and-plugins/using-packages", | ||
"title": "Using packages | Flutter", | ||
"tags": "unknown", | ||
"keywords": "", | ||
"description": "How to use packages in your Flutter app.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/packages-and-plugins/using-packages", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-packages-and-plugins-using-packages.html", | ||
"snippets": [ | ||
"scratch. <b>What is the difference between</b> a package and a plugin? A plugin is a ... <b>Hot reload and hot restart</b> only update the Dart code, so a full <b>restart</b> of ..." | ||
] | ||
}, | ||
{ | ||
"id": "f1652580-ef94-4620-9b9f-e012cef86977", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/resources/faq", | ||
"title": "FAQ | Flutter", | ||
"tags": "missing", | ||
"keywords": "", | ||
"description": "Frequently asked questions and answers about Flutter.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/resources/faq", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-resources-faq.html", | ||
"snippets": [ | ||
"<b>between</b> edit and refresh? How is <b>hot reload</b> different from <b>hot restart</b>? Where can I deploy my Flutter app? What devices and OS versions does Flutter run on ..." | ||
] | ||
}, | ||
{ | ||
"id": "9b8c10b0-0d70-4cc8-ba5c-f85237350ab2", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/get-started/test-drive", | ||
"title": "Test drive | Flutter", | ||
"tags": "missing", | ||
"keywords": "", | ||
"description": "How to create a templated Flutter app and use hot reload.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/get-started/test-drive", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-get-started-test-drive.html", | ||
"snippets": [ | ||
"... <b>How to</b> use \u201c<b>hot reload</b>\u201d after you make changes to the app. Details for these ... <b>restart</b> it for VS Code's Flutter plugin to detect the Flutter SDK ..." | ||
] | ||
}, | ||
{ | ||
"id": "407b18f1-c655-438c-a033-2d42df430def", | ||
"metadata": { | ||
"url": "https://docs.flutter.dev/ui/interactivity", | ||
"title": "Add interactivity to your Flutter app | Flutter", | ||
"tags": "missing", | ||
"keywords": "", | ||
"description": "How to implement a stateful widget that responds to taps.", | ||
"image_uri": "/assets/images/shared/brand/flutter/logo+text/horizontal/default.svg" | ||
}, | ||
"link": "https://docs.flutter.dev/ui/interactivity", | ||
"doc_link": "gs://alanblount-sandbox-flutter-docs/docs-flutter-dev-ui-interactivity.html", | ||
"snippets": [ | ||
"Flutter Understanding constraints Flutter's build modes <b>Hot reload</b> ... <b>How to</b> create a custom widget. The <b>difference between</b> stateless and stateful widgets." | ||
] | ||
} | ||
] | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/api_client/lib/src/resources/questions_resource.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:api_client/api_client.dart'; | ||
|
||
/// {@template questions_resource} | ||
/// An api resource to get response to question from the VERTEX api | ||
/// {@endtemplate} | ||
class QuestionsResource { | ||
/// {@macro questions_resource} | ||
const QuestionsResource(); | ||
|
||
/// Get /game/prompt/terms | ||
/// | ||
/// Returns a [List<String>]. | ||
Future<VertexResponse> getVertexResponse(String query) async { | ||
const path = 'lib/src/resources/fake_response.json'; | ||
final fakeResponse = await File(path).readAsString(); | ||
|
||
final json = jsonDecode(fakeResponse) as Map<String, dynamic>; | ||
return VertexResponse.fromJson(json); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'questions_resource.dart'; |
Oops, something went wrong.