From 49f32b574ef8c373896f0012d6fd5b31d979c1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20L=C3=B3pez=20Dato?= Date: Fri, 13 Dec 2024 11:18:48 -0300 Subject: [PATCH] Constrain Flutter SDK version --- docs/docs/clients/client-side/flutter.md | 12 +++++++----- docs/plugins/flagsmith-versions/index.js | 18 ++++++++++++++++-- docs/src/components/SdkVersions.js | 1 + 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/docs/clients/client-side/flutter.md b/docs/docs/clients/client-side/flutter.md index 737acd2041cb..b019eb2bcac7 100644 --- a/docs/docs/clients/client-side/flutter.md +++ b/docs/docs/clients/client-side/flutter.md @@ -5,6 +5,8 @@ description: Manage your Feature Flags and Remote Config in your Flutter applica slug: /clients/flutter --- +import CodeBlock from '@theme/CodeBlock'; import { FlutterVersion } from '@site/src/components/SdkVersions.js'; + This SDK can be used for Flutter applications. The source code for the client is available on [GitHub](https://github.com/flagsmith/flagsmith-flutter-client). @@ -12,12 +14,12 @@ The Flagsmith Flutter SDK supports iOS, Android and Web targets. ## Getting Started -The client library is available from the [https://pub.dev/packages/flagsmith](https://pub.dev/packages/flagsmith): +Install the [client library](https://pub.dev/packages/flagsmith) by adding it to your application's pubspec.yaml file: -```dart -dependencies: - flagsmith: -``` + +{`dependencies: + flagsmith: ^`} + ## Basic Usage diff --git a/docs/plugins/flagsmith-versions/index.js b/docs/plugins/flagsmith-versions/index.js index 03608ea3f0d7..4a7076b71673 100644 --- a/docs/plugins/flagsmith-versions/index.js +++ b/docs/plugins/flagsmith-versions/index.js @@ -4,6 +4,8 @@ const fetchJSON = async (url, options) => { return response.json(); }; +const userAgent = 'Flagsmith-Docs '; + const fallback = (value) => (promise) => { if (!process.env.CI) return promise.catch((e) => { @@ -45,7 +47,7 @@ const fetchDotnetVersions = async () => { const fetchRustVersions = async () => { // https://crates.io/data-access#api const headers = new Headers({ - 'User-Agent': 'Flagsmith-Docs ', + 'User-Agent': userAgent, }); const data = await fetchJSON('https://crates.io/api/v1/crates/flagsmith', { headers }); return data.versions.map((version) => version.num); @@ -61,11 +63,21 @@ const fetchNpmVersions = async (pkg) => { return Object.keys(data.versions); }; +const fetchFlutterVersions = async () => { + const data = await fetchJSON('https://pub.dev/api/packages/flagsmith', { + headers: { + Accept: 'application/vnd.pub.v2+json', + 'User-Agent': userAgent, + }, + }); + return data.versions.map((v) => v.version); +}; + export default async function fetchFlagsmithVersions(context, options) { return { name: 'flagsmith-versions', async loadContent() { - const [js, java, android, ios, dotnet, rust, elixir] = await Promise.all( + const [js, java, android, ios, dotnet, rust, elixir, flutter] = await Promise.all( [ fetchNpmVersions('flagsmith'), fetchJavaVersions(), @@ -74,6 +86,7 @@ export default async function fetchFlagsmithVersions(context, options) { fetchDotnetVersions(), fetchRustVersions(), fetchElixirVersions(), + fetchFlutterVersions(), ].map(fallback([])), ); return { @@ -84,6 +97,7 @@ export default async function fetchFlagsmithVersions(context, options) { dotnet, rust, elixir, + flutter, }; }, async contentLoaded({ content, actions }) { diff --git a/docs/src/components/SdkVersions.js b/docs/src/components/SdkVersions.js index 41c0daccd305..f3516242d8fc 100644 --- a/docs/src/components/SdkVersions.js +++ b/docs/src/components/SdkVersions.js @@ -26,3 +26,4 @@ export const DotnetVersion = ({ spec = '~5' }) => Version({ sdk: 'dotnet', spec export const ElixirVersion = ({ spec = '~2' }) => Version({ sdk: 'elixir', spec }); export const RustVersion = ({ spec = '~2' }) => Version({ sdk: 'rust', spec }); export const JsVersion = ({ spec = '~7' }) => Version({ sdk: 'js', spec }); +export const FlutterVersion = ({ spec = '~6' }) => Version({ sdk: 'flutter', spec });