From bcb09dbc121e5f886a37cf2808c0d95112276fcd Mon Sep 17 00:00:00 2001 From: Tarrin Neal Date: Tue, 27 Aug 2024 12:52:07 -0700 Subject: [PATCH] [shared_preferences] Add test to enforce mutable lists (#7369) Just a test :) --- .../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 07cd53e4d8188..504ad899e1874 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(>[