Skip to content

Commit

Permalink
docs: Constrain Flutter SDK version (#4919)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolodato authored Dec 13, 2024
1 parent 4bdff0a commit aab7d31
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
12 changes: 7 additions & 5 deletions docs/docs/clients/client-side/flutter.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ 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).

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:
```
<CodeBlock>
{`dependencies:
flagsmith: ^`}<FlutterVersion />
</CodeBlock>

## Basic Usage

Expand Down
18 changes: 16 additions & 2 deletions docs/plugins/flagsmith-versions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const fetchJSON = async (url, options) => {
return response.json();
};

const userAgent = 'Flagsmith-Docs <support@flagsmith.com>';

const fallback = (value) => (promise) => {
if (!process.env.CI)
return promise.catch((e) => {
Expand Down Expand Up @@ -53,7 +55,7 @@ const fetchDotnetVersions = async () => {
const fetchRustVersions = async () => {
// https://crates.io/data-access#api
const headers = new Headers({
'User-Agent': 'Flagsmith-Docs <support@flagsmith.com>',
'User-Agent': userAgent,
});
const data = await fetchJSON('https://crates.io/api/v1/crates/flagsmith', { headers });
return data.versions.map((version) => version.num);
Expand All @@ -69,11 +71,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, nodejs, java, android, swiftpm, cocoapods, dotnet, rust, elixir] = await Promise.all(
const [js, nodejs, java, android, swiftpm, cocoapods, dotnet, rust, elixir, flutter] = await Promise.all(
[
fetchNpmVersions('flagsmith'),
fetchNpmVersions('flagsmith-nodejs'),
Expand All @@ -84,6 +96,7 @@ export default async function fetchFlagsmithVersions(context, options) {
fetchDotnetVersions(),
fetchRustVersions(),
fetchElixirVersions(),
fetchFlutterVersions(),
].map(fallback([])),
);
return {
Expand All @@ -96,6 +109,7 @@ export default async function fetchFlagsmithVersions(context, options) {
dotnet,
rust,
elixir,
flutter,
};
},
async contentLoaded({ content, actions }) {
Expand Down
1 change: 1 addition & 0 deletions docs/src/components/SdkVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ 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 NodejsVersion = ({ spec } = { spec: '~5' }) => Version({ sdk: 'nodejs', spec });
export const FlutterVersion = ({ spec = '~6' }) => Version({ sdk: 'flutter', spec });

0 comments on commit aab7d31

Please sign in to comment.