@@ -125,5 +125,66 @@ void main() {
125125 .isFalse ();
126126 assert (! BoolGlobalSetting .placeholderIgnore.default_);
127127 });
128+
129+ group ('set avoids redundant updates' , () {
130+ int notifiedCount = 0 ;
131+ tearDown (() => notifiedCount = 0 );
132+
133+ test ('null to null -> no update' , () async {
134+ final globalSettings = eg.globalStore (boolGlobalSettings: {}).settings;
135+ globalSettings.addListener (() => notifiedCount++ );
136+
137+ await globalSettings.setBool (BoolGlobalSetting .placeholderIgnore, null );
138+ check (notifiedCount).equals (0 );
139+ });
140+
141+ test ('true to true -> no update' , () async {
142+ final globalSettings = eg.globalStore (boolGlobalSettings: {
143+ BoolGlobalSetting .placeholderIgnore: true ,
144+ }).settings;
145+ globalSettings.addListener (() => notifiedCount++ );
146+
147+ await globalSettings.setBool (BoolGlobalSetting .placeholderIgnore, true );
148+ check (notifiedCount).equals (0 );
149+ });
150+
151+ test ('false to false -> no update' , () async {
152+ final globalSettings = eg.globalStore (boolGlobalSettings: {
153+ BoolGlobalSetting .placeholderIgnore: false ,
154+ }).settings;
155+ globalSettings.addListener (() => notifiedCount++ );
156+
157+ await globalSettings.setBool (BoolGlobalSetting .placeholderIgnore, false );
158+ check (notifiedCount).equals (0 );
159+ });
160+
161+ test ('null to false -> does the update' , () async {
162+ final globalSettings = eg.globalStore (boolGlobalSettings: {}).settings;
163+ globalSettings.addListener (() => notifiedCount++ );
164+
165+ await globalSettings.setBool (BoolGlobalSetting .placeholderIgnore, false );
166+ check (notifiedCount).equals (1 );
167+ });
168+
169+ test ('true to null -> does the update' , () async {
170+ final globalSettings = eg.globalStore (boolGlobalSettings: {
171+ BoolGlobalSetting .placeholderIgnore: true ,
172+ }).settings;
173+ globalSettings.addListener (() => notifiedCount++ );
174+
175+ await globalSettings.setBool (BoolGlobalSetting .placeholderIgnore, null );
176+ check (notifiedCount).equals (1 );
177+ });
178+
179+ test ('false to true -> does the update' , () async {
180+ final globalSettings = eg.globalStore (boolGlobalSettings: {
181+ BoolGlobalSetting .placeholderIgnore: false ,
182+ }).settings;
183+ globalSettings.addListener (() => notifiedCount++ );
184+
185+ await globalSettings.setBool (BoolGlobalSetting .placeholderIgnore, true );
186+ check (notifiedCount).equals (1 );
187+ });
188+ });
128189 });
129190}
0 commit comments