Skip to content

Commit

Permalink
fix: Correct timeout handling in example. (#97)
Browse files Browse the repository at this point in the history
Update the timeout handling in the example.

Also make a few minor documentation updates.
  • Loading branch information
kinyoklion committed Jan 29, 2024
1 parent 1de6079 commit dc18529
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/flutter_client_sdk/example/lib/main.dart
Expand Up @@ -93,7 +93,9 @@ class _MyHomePageState extends State<MyHomePage> {
FutureBuilder(
future: Provider.of<LDClient>(context, listen: false)
.start()
.timeout(const Duration(seconds: 5))
// In this case we do not have special handling for a failed
// initialization or timeout.
.timeout(const Duration(seconds: 5), onTimeout: () => true)
.then((value) => true),
builder: (context, loaded) => loaded.data ?? false
? Center(
Expand Down
10 changes: 7 additions & 3 deletions packages/flutter_client_sdk/lib/src/ld_client.dart
Expand Up @@ -9,17 +9,19 @@ import 'platform_env_reporter.dart';

/// The main interface for the LaunchDarkly Flutter SDK.
///
/// To setup the SDK before use, build an [LDConfig] with [LDConfigBuilder] and
/// To setup the SDK before use, construct an [LDConfig] and
/// an initial [LDContext] with [LDContextBuilder].
/// These should be passed to [LDClient(config, context)] and then [start]
/// should be called. A basic example:
/// ```dart
/// final config = LDConfig(CredentialSource.fromEnvironment(),
/// AutoEnvAttributes.enabled);
/// final context = LDContextBuilder()
/// .kind("user", <USER_KEY>)
/// .kind("company", <COMP_KEY>)
/// .build();
/// final client = LDClient(config, context);
/// await client.start();
/// await client.start().timeout(const Duration(seconds: 5), onTimeout: () => false);
/// ```
///
/// After initialization, the SDK can evaluate feature flags from the
Expand Down Expand Up @@ -55,7 +57,9 @@ interface class LDClient {
return _client.flagChanges;
}

/// TODO: Comments
/// Construct the client instance.
///
/// For detailed instructions please refer to the class [LDClient] documentation.
LDClient(LDConfig config, LDContext context) {
final platformImplementation = CommonPlatform(
persistence: SharedPreferencesPersistence(),
Expand Down

0 comments on commit dc18529

Please sign in to comment.