# Flutter SDK Public Beta

This release includes both frontend ([`clerk_flutter`](https://pub.dev/packages/clerk_flutter)) and backend ([`clerk_backend_api`](https://pub.dev/packages/clerk_backend_api), [`clerk_auth`](https://pub.dev/packages/clerk_auth)) packages, enabling developers to build secure, cross-platform applications with ease.

## Key Features

- **Complete Authentication Flow**: Sign up, sign in, and manage user profiles directly from your Flutter code
- **Organization Support**: Full implementation of Clerk's organization features for managing multi-tenant applications
- **Cross-Platform Compatibility**: Works seamlessly across iOS, Android, and web platforms
- **Type-Safe API**: Built with Dart's strong typing system for better development experience
- **Secure Backend Integration**: Separate backend package for secure server-side operations

## Getting Started

Add the package to your `pubspec.yaml`:

```yaml
dependencies:
  clerk_flutter: ^0.0.8-beta
```

### Flutter Implementation

Here's an example for how to initialize Clerk in your Flutter app:

```dart
class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key, required this.publishableKey});

  final String publishableKey;

  @override
  Widget build(BuildContext context) {
    return ClerkAuth(
      config: ClerkAuthConfig(publishableKey: publishableKey),
      child: MaterialApp(
        theme: ThemeData.light(),
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          body: SafeArea(
            child: ClerkErrorListener(
              child: ClerkAuthBuilder(
                signedInBuilder: (context, authState) {
                  return const ClerkUserButton();
                },
                signedOutBuilder: (context, authState) {
                  return const ClerkAuthentication();
                },
              ),
            ),
          ),
        ),
      ),
    );
  }
}
```

### Server-side Usage

The `clerk_auth` package also allows interaction with Clerk via dart on the server side, if necessary:

```dart
import 'dart:io';

import 'package:clerk_auth/clerk_auth.dart';

Future<void> main() async {
  final auth = Auth(
    config: const AuthConfig(
      publishableKey: '<YOUR-PUBLISHABLE-KEY>',
    ),
    persistor: await DefaultPersistor.create(
      storageDirectory: Directory.current,
    ),
  );

  await auth.initialize();

  await auth.attemptSignIn(
    strategy: Strategy.password,
    identifier: '<USER-EMAIL>',
    password: '<PASSWORD>',
  );

  print('Signed in as ${auth.user}');

  await auth.signOut();

  auth.terminate();
}
```

## Requirements

- Flutter >= 3.10.0
- Dart >= 3.0.0

## Beta Status

This SDK is currently in beta. While we're confident in its functionality, we recommend:

- Hard pinning to the patch version in your `pubspec.yaml`
- Exercising caution before deploying to production
- Testing thoroughly in your development environment

## Feedback

We welcome your feedback during this beta period. Please share your thoughts, report issues, or suggest improvements on our [GitHub repository](https://github.com/clerk/clerk-sdk-flutter/issues).

## Acknowledgments

Special thanks to [DevAngels](https://www.devangels.london/) for their exceptional work in developing this SDK. Their expertise in Flutter development has been instrumental in bringing Clerk's authentication capabilities to the Flutter ecosystem.
