From 260e00f30af82caa1682cbd660df583ea5b74f16 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 12 Aug 2024 01:08:02 -0700 Subject: [PATCH] add test to enforce mutable lists --- .../integration_test/shared_preferences_test.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/shared_preferences/shared_preferences/example/integration_test/shared_preferences_test.dart b/packages/shared_preferences/shared_preferences/example/integration_test/shared_preferences_test.dart index 07cd53e4d818..504ad899e187 100644 --- a/packages/shared_preferences/shared_preferences/example/integration_test/shared_preferences_test.dart +++ b/packages/shared_preferences/shared_preferences/example/integration_test/shared_preferences_test.dart @@ -218,6 +218,15 @@ void main() { expect(await preferences.getStringList(listKey), testList); }); + testWidgets('getStringList returns mutable list', (WidgetTester _) async { + final SharedPreferencesAsync preferences = await getPreferences(); + + await preferences.setStringList(listKey, testList); + final List? list = await preferences.getStringList(listKey); + list?.add('value'); + expect(list?.length, testList.length + 1); + }); + testWidgets('getAll', (WidgetTester _) async { final SharedPreferencesAsync preferences = await getPreferences(); await Future.wait(>[