Navaron Bracke

remove unused helpers from barcode utility

1 -import 'dart:math' as math;  
2 -  
3 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
4 import 'package:mobile_scanner/mobile_scanner.dart'; 2 import 'package:mobile_scanner/mobile_scanner.dart';
5 3
@@ -55,175 +53,3 @@ BarcodeFormat toFormat(int value) { @@ -55,175 +53,3 @@ BarcodeFormat toFormat(int value) {
55 return BarcodeFormat.unknown; 53 return BarcodeFormat.unknown;
56 } 54 }
57 } 55 }
58 -  
59 -CalendarEvent? toCalendarEvent(Map? data) {  
60 - if (data != null) {  
61 - return CalendarEvent.fromNative(data);  
62 - } else {  
63 - return null;  
64 - }  
65 -}  
66 -  
67 -DateTime? toDateTime(Map<String, dynamic>? data) {  
68 - if (data != null) {  
69 - final year = data['year'] as int;  
70 - final month = data['month'] as int;  
71 - final day = data['day'] as int;  
72 - final hour = data['hours'] as int;  
73 - final minute = data['minutes'] as int;  
74 - final second = data['seconds'] as int;  
75 - return data['isUtc'] as bool  
76 - ? DateTime.utc(year, month, day, hour, minute, second)  
77 - : DateTime(year, month, day, hour, minute, second);  
78 - } else {  
79 - return null;  
80 - }  
81 -}  
82 -  
83 -ContactInfo? toContactInfo(Map? data) {  
84 - if (data != null) {  
85 - return ContactInfo.fromNative(data);  
86 - } else {  
87 - return null;  
88 - }  
89 -}  
90 -  
91 -PersonName? toName(Map? data) {  
92 - if (data != null) {  
93 - return PersonName.fromNative(data);  
94 - } else {  
95 - return null;  
96 - }  
97 -}  
98 -  
99 -DriverLicense? toDriverLicense(Map? data) {  
100 - if (data != null) {  
101 - return DriverLicense.fromNative(data);  
102 - } else {  
103 - return null;  
104 - }  
105 -}  
106 -  
107 -Email? toEmail(Map? data) {  
108 - if (data != null) {  
109 - return Email.fromNative(data);  
110 - } else {  
111 - return null;  
112 - }  
113 -}  
114 -  
115 -GeoPoint? toGeoPoint(Map? data) {  
116 - if (data != null) {  
117 - return GeoPoint.fromNative(data);  
118 - } else {  
119 - return null;  
120 - }  
121 -}  
122 -  
123 -Phone? toPhone(Map? data) {  
124 - if (data != null) {  
125 - return Phone.fromNative(data);  
126 - } else {  
127 - return null;  
128 - }  
129 -}  
130 -  
131 -SMS? toSMS(Map? data) {  
132 - if (data != null) {  
133 - return SMS.fromNative(data);  
134 - } else {  
135 - return null;  
136 - }  
137 -}  
138 -  
139 -UrlBookmark? toUrl(Map? data) {  
140 - if (data != null) {  
141 - return UrlBookmark.fromNative(data);  
142 - } else {  
143 - return null;  
144 - }  
145 -}  
146 -  
147 -WiFi? toWiFi(Map? data) {  
148 - if (data != null) {  
149 - return WiFi.fromNative(data);  
150 - } else {  
151 - return null;  
152 - }  
153 -}  
154 -  
155 -Size applyBoxFit(BoxFit fit, Size input, Size output) {  
156 - if (input.height <= 0.0 ||  
157 - input.width <= 0.0 ||  
158 - output.height <= 0.0 ||  
159 - output.width <= 0.0) {  
160 - return Size.zero;  
161 - }  
162 -  
163 - Size destination;  
164 -  
165 - final inputAspectRatio = input.width / input.height;  
166 - final outputAspectRatio = output.width / output.height;  
167 -  
168 - switch (fit) {  
169 - case BoxFit.fill:  
170 - destination = output;  
171 - break;  
172 - case BoxFit.contain:  
173 - if (outputAspectRatio > inputAspectRatio) {  
174 - destination = Size(  
175 - input.width * output.height / input.height,  
176 - output.height,  
177 - );  
178 - } else {  
179 - destination = Size(  
180 - output.width,  
181 - input.height * output.width / input.width,  
182 - );  
183 - }  
184 - break;  
185 -  
186 - case BoxFit.cover:  
187 - if (outputAspectRatio > inputAspectRatio) {  
188 - destination = Size(  
189 - output.width,  
190 - input.height * (output.width / input.width),  
191 - );  
192 - } else {  
193 - destination = Size(  
194 - input.width * (output.height / input.height),  
195 - output.height,  
196 - );  
197 - }  
198 - break;  
199 - case BoxFit.fitWidth:  
200 - destination = Size(  
201 - output.width,  
202 - input.height * (output.width / input.width),  
203 - );  
204 - break;  
205 - case BoxFit.fitHeight:  
206 - destination = Size(  
207 - input.width * (output.height / input.height),  
208 - output.height,  
209 - );  
210 - break;  
211 - case BoxFit.none:  
212 - destination = Size(  
213 - math.min(input.width, output.width),  
214 - math.min(input.height, output.height),  
215 - );  
216 - break;  
217 - case BoxFit.scaleDown:  
218 - destination = input;  
219 - if (destination.height > output.height) {  
220 - destination = Size(output.height * inputAspectRatio, output.height);  
221 - }  
222 - if (destination.width > output.width) {  
223 - destination = Size(output.width, output.width / inputAspectRatio);  
224 - }  
225 - break;  
226 - }  
227 -  
228 - return destination;  
229 -}