Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,42 @@ class FirebaseOptions {
iosBundleId = options.iosBundleId,
appGroupId = options.appGroupId;

/// Returns a copy of this FirebaseOptions with the given fields replaced with
/// the new values.
FirebaseOptions copyWith({
String? apiKey,
String? appId,
String? messagingSenderId,
String? projectId,
String? authDomain,
String? databaseURL,
String? storageBucket,
String? measurementId,
String? trackingId,
String? deepLinkURLScheme,
String? androidClientId,
String? iosClientId,
String? iosBundleId,
String? appGroupId,
}) {
return FirebaseOptions(
apiKey: apiKey ?? this.apiKey,
appId: appId ?? this.appId,
messagingSenderId: messagingSenderId ?? this.messagingSenderId,
projectId: projectId ?? this.projectId,
authDomain: authDomain ?? this.authDomain,
databaseURL: databaseURL ?? this.databaseURL,
storageBucket: storageBucket ?? this.storageBucket,
measurementId: measurementId ?? this.measurementId,
trackingId: trackingId ?? this.trackingId,
deepLinkURLScheme: deepLinkURLScheme ?? this.deepLinkURLScheme,
androidClientId: androidClientId ?? this.androidClientId,
iosClientId: iosClientId ?? this.iosClientId,
iosBundleId: iosBundleId ?? this.iosBundleId,
appGroupId: appGroupId ?? this.appGroupId,
);
}

/// An API key used for authenticating requests from your app to Google
/// servers.
final String apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,52 @@ void main() {
expect(options1 == options2, isTrue);
});

test('should copyWith new values', () {
const options = FirebaseOptions(
apiKey: 'apiKey',
appId: 'appId',
messagingSenderId: 'messagingSenderId',
projectId: 'projectId',
);

final newOptions = options.copyWith(
apiKey: 'newApiKey',
appId: 'newAppId',
messagingSenderId: 'newMessagingSenderId',
projectId: 'newProjectId',
authDomain: 'newAuthDomain',
databaseURL: 'newDatabaseURL',
storageBucket: 'newStorageBucket',
measurementId: 'newMeasurementId',
trackingId: 'newTrackingId',
deepLinkURLScheme: 'newDeepLinkURLScheme',
androidClientId: 'newAndroidClientId',
iosClientId: 'newIosClientId',
iosBundleId: 'newIosBundleId',
appGroupId: 'newAppGroupId',
);

expect(
newOptions,
const FirebaseOptions(
apiKey: 'newApiKey',
appId: 'newAppId',
messagingSenderId: 'newMessagingSenderId',
projectId: 'newProjectId',
authDomain: 'newAuthDomain',
databaseURL: 'newDatabaseURL',
storageBucket: 'newStorageBucket',
measurementId: 'newMeasurementId',
trackingId: 'newTrackingId',
deepLinkURLScheme: 'newDeepLinkURLScheme',
androidClientId: 'newAndroidClientId',
iosClientId: 'newIosClientId',
iosBundleId: 'newIosBundleId',
appGroupId: 'newAppGroupId',
),
);
});

test('should return a Map', () {
const options = FirebaseOptions(
apiKey: 'apiKey',
Expand Down