@@ -124,13 +124,46 @@ void main() {
124124 goldenTest (
125125 'GitHub issue #2369 - same-length user IDs should have different colors' ,
126126 fileName: 'gradient_avatar_issue_2369' ,
127- builder: () => GoldenTestGroup (
127+ constraints: const BoxConstraints .tightFor (width: 600 , height: 1200 ),
128+ builder: () => _wrapWithMaterialApp (
129+ const AvatarComparisonTestWidget (),
130+ ),
131+ );
132+ }
133+
134+ /// Custom test widget for GitHub issue #2369 avatar comparison
135+ ///
136+ /// This widget creates a custom themed layout without using GoldenTestGroup
137+ /// to avoid theme conflicts with other tests in the package.
138+ class AvatarComparisonTestWidget extends StatelessWidget {
139+ const AvatarComparisonTestWidget ({super .key});
140+
141+ @override
142+ Widget build (BuildContext context) {
143+ final theme = StreamChatTheme .of (context);
144+
145+ return Column (
146+ mainAxisSize: MainAxisSize .min,
147+ crossAxisAlignment: CrossAxisAlignment .start,
128148 children: [
129- // Test case from GitHub issue #2369 - these numeric IDs have same length
130- // but should produce different gradient colors after the fix
131- GoldenTestScenario (
132- name: 'Numeric IDs (5 chars) - Should show different colors' ,
133- constraints: const BoxConstraints .tightFor (width: 450 , height: 180 ),
149+ Text (
150+ 'GitHub Issue #2369 - Gradient Avatar Color Fix' ,
151+ style: theme.textTheme.title,
152+ ),
153+ const SizedBox (height: 8 ),
154+ Text (
155+ 'Users with same-length IDs should have different colors' ,
156+ style: theme.textTheme.headline.copyWith (
157+ color: theme.colorTheme.textLowEmphasis,
158+ ),
159+ ),
160+ const SizedBox (height: 16 ),
161+
162+ // Test scenarios
163+ _buildTestSection (
164+ context,
165+ title: 'Numeric IDs (5 chars) - Should show different colors' ,
166+ description: 'Example IDs from the GitHub issue' ,
134167 child: const AvatarComparisonRow (
135168 users: [
136169 ('12133' , 'User One' ), // Example IDs from the issue
@@ -139,10 +172,13 @@ void main() {
139172 ],
140173 ),
141174 ),
142- // Additional test with alphabetic IDs of same length
143- GoldenTestScenario (
144- name: 'Alphabetic IDs (5 chars) - Should show different colors' ,
145- constraints: const BoxConstraints .tightFor (width: 450 , height: 180 ),
175+
176+ const SizedBox (height: 24 ),
177+
178+ _buildTestSection (
179+ context,
180+ title: 'Alphabetic IDs (5 chars) - Should show different colors' ,
181+ description: 'Additional test with same-length alphabetic IDs' ,
146182 child: const AvatarComparisonRow (
147183 users: [
148184 ('abcde' , 'User Alpha' ),
@@ -151,9 +187,13 @@ void main() {
151187 ],
152188 ),
153189 ),
154- GoldenTestScenario (
155- name: 'Mixed length IDs - For reference (should be different)' ,
156- constraints: const BoxConstraints .tightFor (width: 450 , height: 180 ),
190+
191+ const SizedBox (height: 24 ),
192+
193+ _buildTestSection (
194+ context,
195+ title: 'Mixed length IDs - For reference' ,
196+ description: 'Different length IDs should always be different' ,
157197 child: const AvatarComparisonRow (
158198 users: [
159199 ('a' , 'Short' ),
@@ -162,9 +202,13 @@ void main() {
162202 ],
163203 ),
164204 ),
165- GoldenTestScenario (
166- name: 'Same user ID - Should be identical' ,
167- constraints: const BoxConstraints .tightFor (width: 450 , height: 180 ),
205+
206+ const SizedBox (height: 24 ),
207+
208+ _buildTestSection (
209+ context,
210+ title: 'Same user ID - Should be identical' ,
211+ description: 'Consistency test - same ID should produce same colors' ,
168212 child: const AvatarComparisonRow (
169213 users: [
170214 ('test123' , 'Same User' ),
@@ -174,8 +218,47 @@ void main() {
174218 ),
175219 ),
176220 ],
177- ),
178- );
221+ );
222+ }
223+
224+ Widget _buildTestSection (
225+ BuildContext context, {
226+ required String title,
227+ required String description,
228+ required Widget child,
229+ }) {
230+ final theme = StreamChatTheme .of (context);
231+
232+ return Column (
233+ crossAxisAlignment: CrossAxisAlignment .start,
234+ children: [
235+ Text (
236+ title,
237+ style: theme.textTheme.headline.copyWith (
238+ color: theme.colorTheme.textHighEmphasis,
239+ ),
240+ ),
241+ const SizedBox (height: 4 ),
242+ Text (
243+ description,
244+ style: theme.textTheme.body.copyWith (
245+ color: theme.colorTheme.textLowEmphasis,
246+ ),
247+ ),
248+ const SizedBox (height: 16 ),
249+ Container (
250+ width: double .infinity,
251+ padding: const EdgeInsets .all (20 ),
252+ decoration: BoxDecoration (
253+ color: theme.colorTheme.barsBg,
254+ borderRadius: BorderRadius .circular (8 ),
255+ border: Border .all (color: theme.colorTheme.borders),
256+ ),
257+ child: child,
258+ ),
259+ ],
260+ );
261+ }
179262}
180263
181264/// A widget that displays a row of gradient avatars for comparison testing.
@@ -241,6 +324,8 @@ class _AvatarItem extends StatelessWidget {
241324
242325 @override
243326 Widget build (BuildContext context) {
327+ final theme = StreamChatTheme .of (context);
328+
244329 return Column (
245330 mainAxisSize: MainAxisSize .min,
246331 mainAxisAlignment: MainAxisAlignment .center,
@@ -256,18 +341,16 @@ class _AvatarItem extends StatelessWidget {
256341 const SizedBox (height: 8 ),
257342 Text (
258343 userId,
259- style: const TextStyle (
260- fontSize: 12 ,
261- fontWeight: FontWeight .w600,
344+ style: theme.textTheme.footnoteBold.copyWith (
345+ color: theme.colorTheme.textHighEmphasis,
262346 ),
263347 textAlign: TextAlign .center,
264348 ),
265349 const SizedBox (height: 2 ),
266350 Text (
267351 userName,
268- style: TextStyle (
269- fontSize: 10 ,
270- color: Colors .grey.shade600,
352+ style: theme.textTheme.footnote.copyWith (
353+ color: theme.colorTheme.textLowEmphasis,
271354 ),
272355 maxLines: 1 ,
273356 overflow: TextOverflow .ellipsis,
@@ -277,3 +360,24 @@ class _AvatarItem extends StatelessWidget {
277360 );
278361 }
279362}
363+
364+ Widget _wrapWithMaterialApp (
365+ Widget widget, {
366+ Brightness ? brightness,
367+ }) {
368+ return MaterialApp (
369+ home: StreamChatTheme (
370+ data: StreamChatThemeData (brightness: brightness),
371+ child: Builder (builder: (context) {
372+ final theme = StreamChatTheme .of (context);
373+ return Scaffold (
374+ backgroundColor: theme.colorTheme.appBg,
375+ body: Container (
376+ padding: const EdgeInsets .all (16 ),
377+ child: Center (child: widget),
378+ ),
379+ );
380+ }),
381+ ),
382+ );
383+ }
0 commit comments