Skip to content

Commit cbf9f97

Browse files
Hides configuration from public interface and make isBuild final
- The purpose of these changes is because having both configuration and isBuilt publicly mutable is misleading, since changing those attributes will have no impact.
1 parent 3e349e0 commit cbf9f97

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/amplitude.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'events/base_event.dart';
1010
import 'events/group_identify_event.dart';
1111

1212
class Amplitude {
13-
Configuration configuration;
13+
final Configuration _configuration;
1414
MethodChannel _channel = const MethodChannel('amplitude_flutter');
1515

1616
/// Whether the Amplitude instance has been successfully initialized
@@ -20,7 +20,7 @@ class Amplitude {
2020
/// // If care about init complete
2121
/// await amplitude.isBuilt;
2222
/// ```
23-
late Future<bool> isBuilt;
23+
late final Future<bool> isBuilt;
2424

2525
/// Returns an Amplitude instance
2626
///
@@ -29,15 +29,16 @@ class Amplitude {
2929
/// // If care about init complete
3030
/// await amplitude.isBuilt;
3131
/// ```
32-
Amplitude(this.configuration, [MethodChannel? methodChannel]) {
32+
Amplitude(Configuration configuration, [MethodChannel? methodChannel])
33+
: _configuration = configuration {
3334
_channel = methodChannel ?? _channel;
3435
isBuilt = _init();
3536
}
3637

3738
/// Private method to initialize and return a `Future<bool>`
3839
Future<bool> _init() async {
3940
try {
40-
await _channel.invokeMethod('init', configuration.toMap());
41+
await _channel.invokeMethod('init', _configuration.toMap());
4142
return true; // Initialization successful
4243
} catch (e) {
4344
print('Error initializing Amplitude: $e');

0 commit comments

Comments
 (0)