Skip to content
Draft
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
12 changes: 12 additions & 0 deletions flipt-client-dart-android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/

# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock
*.h

# Native libraries (will be added during build)
native/
android/src/main/jniLibs/
7 changes: 7 additions & 0 deletions flipt-client-dart-android/.pubignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/

# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock
21 changes: 21 additions & 0 deletions flipt-client-dart-android/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Flipt Software Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
84 changes: 84 additions & 0 deletions flipt-client-dart-android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Flipt Client SDK for Android

The official Flipt client SDK for Android applications.

## Overview

The `flipt_client_android` package provides a Dart/Flutter SDK specifically optimized for Android platforms. It's a lightweight wrapper around the Flipt evaluation engine, enabling feature flag evaluation directly on Android devices.

## Installation

Add this to your package's `pubspec.yaml` file:

```yaml
dependencies:
flipt_client_android: ^0.1.0
```

Then run:

```bash
flutter pub get
```

## Usage

```dart
import 'package:flipt_client_android/flipt_client_android.dart';

// Initialize the client
final client = FliptClient(
options: Options(
url: 'https://your-flipt-instance.com',
updateInterval: 120,
),
);

// Evaluate a boolean flag
final boolResult = client.evaluateBoolean(
flagKey: 'my-flag',
entityId: 'user-123',
context: {'role': 'admin'},
);
print('Flag enabled: ${boolResult.enabled}');

// Evaluate a variant flag
final variantResult = client.evaluateVariant(
flagKey: 'my-variant-flag',
entityId: 'user-123',
context: {'plan': 'premium'},
);
print('Variant: ${variantResult.variantKey}');

// Don't forget to close the client when done
client.close();
```

## Features

- 🎯 **Zero-latency evaluation**: All flag evaluation happens locally on the device
- 📱 **Android optimized**: Specifically packaged for Android with minimal size (~12MB)
- 🔄 **Auto-polling**: Automatically fetches latest flag state at configurable intervals
- 🎨 **Type-safe**: Full Dart type safety with generated models

## Configuration Options

- `url`: Your Flipt instance URL
- `updateInterval`: How often to fetch updated flag state (in seconds, default: 120)
- `authentication`: Optional authentication configuration

## Platform Support

This package is specifically for Android. For other platforms, use:
- iOS: `flipt_client_ios`
- Desktop/Server: `flipt_client`

## Documentation

For more detailed documentation, visit:
- [Flipt Documentation](https://www.flipt.io/docs)
- [Client SDKs Documentation](https://www.flipt.io/docs/integration/client-sdks)

## License

This project is licensed under the MIT License.
29 changes: 29 additions & 0 deletions flipt-client-dart-android/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
10 changes: 10 additions & 0 deletions flipt-client-dart-android/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
targets:
$default:
sources:
exclude:
- "example/**"
builders:
json_serializable:
options:
explicit_to_json: true
field_rename: snake
11 changes: 11 additions & 0 deletions flipt-client-dart-android/ffigen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output: "lib/src/ffi/bindings.dart"
headers:
entry-points:
- "ffi/flipt_engine.h"
include-directives:
- "ffi/flipt_engine.h"

name: FliptEngine
description: Auto-generated FFI bindings for flipt_engine
compiler-opts:
- "-Iffi"
5 changes: 5 additions & 0 deletions flipt-client-dart-android/lib/flipt_client_android.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library flipt_client_android;

export 'src/models.dart';
export 'src/flipt_client.dart';
export 'src/plugin_registration.dart';
17 changes: 17 additions & 0 deletions flipt-client-dart-android/lib/src/errors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// Base class for all Flipt errors.
class FliptError implements Exception {
final String message;
FliptError(this.message);
@override
String toString() => 'FliptError: $message';
}

/// Thrown when a validation error occurs.
class ValidationError extends FliptError {
ValidationError(String message) : super(message);
}

/// Thrown when an evaluation error occurs.
class EvaluationError extends FliptError {
EvaluationError(String message) : super(message);
}
Loading
Loading