|
| 1 | +import 'package:flutter/foundation.dart'; |
| 2 | + |
1 | 3 | import '../responsive_wrapper.dart'; |
2 | 4 |
|
3 | 5 | /// Util functions for the Responsive Framework. |
@@ -38,11 +40,43 @@ class ResponsiveUtils { |
38 | 40 |
|
39 | 41 | /// Print a visual view of [breakpointSegments] |
40 | 42 | /// for debugging purposes. |
41 | | - static String debugLogBreakpoints( |
| 43 | + static String debugLogBreakpointSegments( |
42 | 44 | List<ResponsiveBreakpointSegment> responsiveBreakpointSegments) { |
43 | | - responsiveBreakpointSegments.forEach((element) { |
44 | | - print(element); |
45 | | - }); |
46 | | - return responsiveBreakpointSegments.toString(); |
| 45 | + var stringBuffer = new StringBuffer(); |
| 46 | + stringBuffer.write('|'); |
| 47 | + for (int i = 0; i < responsiveBreakpointSegments.length; i++) { |
| 48 | + // Convenience variable. |
| 49 | + ResponsiveBreakpointSegment segment = responsiveBreakpointSegments[i]; |
| 50 | + print(segment); |
| 51 | + stringBuffer.write(segment.breakpoint.round()); |
| 52 | + List<dynamic> attributes = []; |
| 53 | + String name = segment.responsiveBreakpoint.name; |
| 54 | + if (name != null) attributes.add(name); |
| 55 | + double scaleFactor = segment.responsiveBreakpoint.scaleFactor; |
| 56 | + if (scaleFactor != 1) attributes.add(scaleFactor); |
| 57 | + if (attributes.isNotEmpty) { |
| 58 | + stringBuffer.write('('); |
| 59 | + for (int i = 0; i < attributes.length; i++) { |
| 60 | + stringBuffer.write(attributes[i]); |
| 61 | + if (i != attributes.length - 1) stringBuffer.write('|'); |
| 62 | + } |
| 63 | + stringBuffer.write(')'); |
| 64 | + } |
| 65 | + stringBuffer.write(' ----- '); |
| 66 | + if (segment.segmentType == ResponsiveBreakpointBehavior.AUTOSCALEDOWN && |
| 67 | + segment.breakpoint < segment.responsiveBreakpoint.breakpoint) { |
| 68 | + stringBuffer.write(describeEnum(segment.segmentType) + |
| 69 | + ' from ' + |
| 70 | + segment.responsiveBreakpoint.breakpoint.round().toString()); |
| 71 | + } else { |
| 72 | + stringBuffer |
| 73 | + .write('${describeEnum(segment.responsiveBreakpoint.behavior)}'); |
| 74 | + } |
| 75 | + if (i != responsiveBreakpointSegments.length - 1) |
| 76 | + stringBuffer.write(' ----- '); |
| 77 | + } |
| 78 | + stringBuffer.write(' ----- ∞ |'); |
| 79 | + print(stringBuffer.toString()); |
| 80 | + return stringBuffer.toString(); |
47 | 81 | } |
48 | 82 | } |
0 commit comments