David PHAM-VAN

Add Flutter 3.7 compatibility

1 include: package:flutter_lints/flutter.yaml 1 include: package:flutter_lints/flutter.yaml
2 2
3 analyzer: 3 analyzer:
4 - strong-mode:  
5 - implicit-dynamic: false  
6 errors: 4 errors:
7 missing_required_param: warning 5 missing_required_param: warning
8 missing_return: warning 6 missing_return: warning
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 - Fix lints 10 - Fix lints
11 - Add options to customise border in Dataset widget [838] 11 - Add options to customise border in Dataset widget [838]
12 - Add Choice Field [Carsten Fregin] 12 - Add Choice Field [Carsten Fregin]
  13 +- Add Flutter 3.7 compatibility
13 14
14 ## 3.8.4 15 ## 3.8.4
15 16
1 include: package:flutter_lints/flutter.yaml 1 include: package:flutter_lints/flutter.yaml
2 2
3 analyzer: 3 analyzer:
4 - strong-mode:  
5 - implicit-dynamic: false  
6 errors: 4 errors:
7 missing_required_param: warning 5 missing_required_param: warning
8 missing_return: warning 6 missing_return: warning
@@ -76,7 +76,6 @@ class PdfBool extends PdfDataType { @@ -76,7 +76,6 @@ class PdfBool extends PdfDataType {
76 class PdfNum extends PdfDataType { 76 class PdfNum extends PdfDataType {
77 const PdfNum(this.value) 77 const PdfNum(this.value)
78 : assert(value != double.infinity), 78 : assert(value != double.infinity),
79 - assert(value != double.nan),  
80 assert(value != double.negativeInfinity); 79 assert(value != double.negativeInfinity);
81 80
82 static const int precision = 5; 81 static const int precision = 5;
@@ -85,6 +84,9 @@ class PdfNum extends PdfDataType { @@ -85,6 +84,9 @@ class PdfNum extends PdfDataType {
85 84
86 @override 85 @override
87 void output(PdfStream s, [int? indent]) { 86 void output(PdfStream s, [int? indent]) {
  87 + assert(!value.isNaN);
  88 + assert(!value.isInfinite);
  89 +
88 if (value is int) { 90 if (value is int) {
89 s.putString(value.toInt().toString()); 91 s.putString(value.toInt().toString());
90 } else { 92 } else {
@@ -11,7 +11,7 @@ environment: @@ -11,7 +11,7 @@ environment:
11 dependencies: 11 dependencies:
12 archive: ^3.1.0 12 archive: ^3.1.0
13 barcode: ">=2.2.3 <3.0.0" 13 barcode: ">=2.2.3 <3.0.0"
14 - bidi: ^2.0.2 14 + bidi: ^2.0.6
15 crypto: ^3.0.0 15 crypto: ^3.0.0
16 image: ^4.0.0 16 image: ^4.0.0
17 meta: ">=1.3.0 <2.0.0" 17 meta: ">=1.3.0 <2.0.0"
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 - Update Image dependency 7 - Update Image dependency
8 - Fix canChangeOrientation option not appearing bug [Bilal Raja] 8 - Fix canChangeOrientation option not appearing bug [Bilal Raja]
9 - Add Support cmaps option on printing web [Koji Wakamiya] 9 - Add Support cmaps option on printing web [Koji Wakamiya]
  10 +- Add Flutter 3.7 compatibility
10 11
11 ## 5.9.3 12 ## 5.9.3
12 13
1 include: package:flutter_lints/flutter.yaml 1 include: package:flutter_lints/flutter.yaml
2 2
3 analyzer: 3 analyzer:
4 - strong-mode:  
5 - implicit-dynamic: false  
6 errors: 4 errors:
7 missing_required_param: warning 5 missing_required_param: warning
8 missing_return: warning 6 missing_return: warning
@@ -25,8 +25,8 @@ import 'package:pdf/pdf.dart'; @@ -25,8 +25,8 @@ import 'package:pdf/pdf.dart';
25 import 'package:pdf/widgets.dart' as pw; 25 import 'package:pdf/widgets.dart' as pw;
26 26
27 /// ImageProvider that draws a Flutter Widget on a PDF document 27 /// ImageProvider that draws a Flutter Widget on a PDF document
28 -class WidgetWraper extends pw.ImageProvider {  
29 - WidgetWraper._( 28 +class WidgetWrapper extends pw.ImageProvider {
  29 + WidgetWrapper._(
30 this.bytes, 30 this.bytes,
31 int width, 31 int width,
32 int height, 32 int height,
@@ -51,7 +51,7 @@ class WidgetWraper extends pw.ImageProvider { @@ -51,7 +51,7 @@ class WidgetWraper extends pw.ImageProvider {
51 /// Future<Uint8List> _generatePdf(PdfPageFormat format) async { 51 /// Future<Uint8List> _generatePdf(PdfPageFormat format) async {
52 /// final pdf = pw.Document(); 52 /// final pdf = pw.Document();
53 /// 53 ///
54 - /// final image = await WidgetWraper.fromKey(key: rb); 54 + /// final image = await WidgetWrapper.fromKey(key: rb);
55 /// 55 ///
56 /// pdf.addPage( 56 /// pdf.addPage(
57 /// pw.Page( 57 /// pw.Page(
@@ -66,7 +66,7 @@ class WidgetWraper extends pw.ImageProvider { @@ -66,7 +66,7 @@ class WidgetWraper extends pw.ImageProvider {
66 /// return pdf.save(); 66 /// return pdf.save();
67 /// } 67 /// }
68 /// ``` 68 /// ```
69 - static Future<WidgetWraper> fromKey({ 69 + static Future<WidgetWrapper> fromKey({
70 required GlobalKey key, 70 required GlobalKey key,
71 int? width, 71 int? width,
72 int? height, 72 int? height,
@@ -82,7 +82,7 @@ class WidgetWraper extends pw.ImageProvider { @@ -82,7 +82,7 @@ class WidgetWraper extends pw.ImageProvider {
82 final byteData = await image.toByteData(format: ui.ImageByteFormat.rawRgba); 82 final byteData = await image.toByteData(format: ui.ImageByteFormat.rawRgba);
83 83
84 if (byteData == null) { 84 if (byteData == null) {
85 - return WidgetWraper._( 85 + return WidgetWrapper._(
86 Uint8List(0), 86 Uint8List(0),
87 0, 87 0,
88 0, 88 0,
@@ -92,7 +92,7 @@ class WidgetWraper extends pw.ImageProvider { @@ -92,7 +92,7 @@ class WidgetWraper extends pw.ImageProvider {
92 } 92 }
93 93
94 final imageData = byteData.buffer.asUint8List(); 94 final imageData = byteData.buffer.asUint8List();
95 - return WidgetWraper._( 95 + return WidgetWrapper._(
96 imageData, 96 imageData,
97 image.width, 97 image.width,
98 image.height, 98 image.height,
@@ -104,7 +104,7 @@ class WidgetWraper extends pw.ImageProvider { @@ -104,7 +104,7 @@ class WidgetWraper extends pw.ImageProvider {
104 /// Wrap a Flutter Widget to an ImageProvider. 104 /// Wrap a Flutter Widget to an ImageProvider.
105 /// 105 ///
106 /// ``` 106 /// ```
107 - /// final wrapped = await WidgetWraper.fromWidget( 107 + /// final wrapped = await WidgetWrapper.fromWidget(
108 /// widget: Container( 108 /// widget: Container(
109 /// color: Colors.white, 109 /// color: Colors.white,
110 /// child: Text( 110 /// child: Text(
@@ -125,7 +125,7 @@ class WidgetWraper extends pw.ImageProvider { @@ -125,7 +125,7 @@ class WidgetWraper extends pw.ImageProvider {
125 /// ), 125 /// ),
126 /// ); 126 /// );
127 /// ``` 127 /// ```
128 - static Future<WidgetWraper> fromWidget({ 128 + static Future<WidgetWrapper> fromWidget({
129 required Widget widget, 129 required Widget widget,
130 required BoxConstraints constraints, 130 required BoxConstraints constraints,
131 double pixelRatio = 1.0, 131 double pixelRatio = 1.0,
@@ -170,11 +170,7 @@ class WidgetWraper extends pw.ImageProvider { @@ -170,11 +170,7 @@ class WidgetWraper extends pw.ImageProvider {
170 configuration: ViewConfiguration( 170 configuration: ViewConfiguration(
171 size: Size(_constraints.maxWidth, _constraints.maxHeight), 171 size: Size(_constraints.maxWidth, _constraints.maxHeight),
172 devicePixelRatio: ui.window.devicePixelRatio), 172 devicePixelRatio: ui.window.devicePixelRatio),
173 - window: _FlutterView(  
174 - configuration: ui.ViewConfiguration(  
175 - devicePixelRatio: ui.window.devicePixelRatio,  
176 - ),  
177 - ), 173 + window: ui.window,
178 ); 174 );
179 175
180 final pipelineOwner = PipelineOwner()..rootNode = renderView; 176 final pipelineOwner = PipelineOwner()..rootNode = renderView;
@@ -204,7 +200,7 @@ class WidgetWraper extends pw.ImageProvider { @@ -204,7 +200,7 @@ class WidgetWraper extends pw.ImageProvider {
204 throw Exception('Unable to read image data'); 200 throw Exception('Unable to read image data');
205 } 201 }
206 202
207 - return WidgetWraper._( 203 + return WidgetWrapper._(
208 bytes.buffer.asUint8List(), 204 bytes.buffer.asUint8List(),
209 image.width, 205 image.width,
210 image.height, 206 image.height,
@@ -228,15 +224,51 @@ class WidgetWraper extends pw.ImageProvider { @@ -228,15 +224,51 @@ class WidgetWraper extends pw.ImageProvider {
228 } 224 }
229 } 225 }
230 226
231 -class _FlutterView extends ui.FlutterView {  
232 - _FlutterView({required this.configuration});  
233 -  
234 - final ui.ViewConfiguration configuration; 227 +/// ImageProvider that draws a Flutter Widget on a PDF document
  228 +@Deprecated('Use WidgetWrapper instead')
  229 +class WidgetWraper extends WidgetWrapper {
  230 + WidgetWraper._(
  231 + Uint8List bytes,
  232 + int width,
  233 + int height,
  234 + PdfImageOrientation orientation,
  235 + double? dpi,
  236 + ) : super._(bytes, width, height, orientation, dpi);
235 237
236 - @override  
237 - ui.PlatformDispatcher get platformDispatcher =>  
238 - ui.PlatformDispatcher.instance; 238 + /// Wrap a Flutter Widget identified by a GlobalKey to an ImageProvider.
  239 + @Deprecated('Use WidgetWrapper.fromKey instead')
  240 + static Future<WidgetWrapper> fromKey({
  241 + required GlobalKey key,
  242 + int? width,
  243 + int? height,
  244 + double pixelRatio = 1.0,
  245 + PdfImageOrientation? orientation,
  246 + double? dpi,
  247 + }) {
  248 + return WidgetWrapper.fromKey(
  249 + key: key,
  250 + width: width,
  251 + pixelRatio: pixelRatio,
  252 + orientation: orientation,
  253 + dpi: dpi,
  254 + );
  255 + }
239 256
240 - @override  
241 - ui.ViewConfiguration get viewConfiguration => configuration; 257 + /// Wrap a Flutter Widget to an ImageProvider.
  258 + @Deprecated('Use WidgetWrapper.fromWidget instead')
  259 + static Future<WidgetWrapper> fromWidget({
  260 + required Widget widget,
  261 + required BoxConstraints constraints,
  262 + double pixelRatio = 1.0,
  263 + PdfImageOrientation? orientation,
  264 + double? dpi,
  265 + }) {
  266 + return WidgetWrapper.fromWidget(
  267 + widget: widget,
  268 + constraints: constraints,
  269 + pixelRatio: pixelRatio,
  270 + orientation: orientation,
  271 + dpi: dpi,
  272 + );
  273 + }
242 } 274 }
@@ -14,13 +14,11 @@ @@ -14,13 +14,11 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -// @dart=2.9  
18 -  
19 import 'dart:io'; 17 import 'dart:io';
20 18
21 import 'package:markdown/markdown.dart' as md; 19 import 'package:markdown/markdown.dart' as md;
22 20
23 -Iterable<String> getCode(List<md.Node> nodes, [bool isCode = false]) sync* { 21 +Iterable<String> getCode(List<md.Node>? nodes, [bool isCode = false]) sync* {
24 if (nodes == null) { 22 if (nodes == null) {
25 return; 23 return;
26 } 24 }
@@ -14,8 +14,6 @@ @@ -14,8 +14,6 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -// @dart=2.9  
18 -  
19 import 'dart:io'; 17 import 'dart:io';
20 18
21 import 'package:pdf/pdf.dart'; 19 import 'package:pdf/pdf.dart';
@@ -154,15 +152,16 @@ Future<void> main() async { @@ -154,15 +152,16 @@ Future<void> main() async {
154 } 152 }
155 153
156 class SyntaxHighlighterStyle { 154 class SyntaxHighlighterStyle {
157 - const SyntaxHighlighterStyle(  
158 - {this.baseStyle,  
159 - this.numberStyle,  
160 - this.commentStyle,  
161 - this.keywordStyle,  
162 - this.stringStyle,  
163 - this.punctuationStyle,  
164 - this.classStyle,  
165 - this.constantStyle}); 155 + const SyntaxHighlighterStyle({
  156 + required this.baseStyle,
  157 + required this.numberStyle,
  158 + required this.commentStyle,
  159 + required this.keywordStyle,
  160 + required this.stringStyle,
  161 + required this.punctuationStyle,
  162 + required this.classStyle,
  163 + required this.constantStyle,
  164 + });
166 165
167 final TextStyle baseStyle; 166 final TextStyle baseStyle;
168 final TextStyle numberStyle; 167 final TextStyle numberStyle;
@@ -190,9 +189,7 @@ class SyntaxHighlighterStyle { @@ -190,9 +189,7 @@ class SyntaxHighlighterStyle {
190 } 189 }
191 190
192 class DartSyntaxHighlighter { 191 class DartSyntaxHighlighter {
193 - DartSyntaxHighlighter(this._style) {  
194 - _spans = <_HighlightSpan>[];  
195 - } 192 + DartSyntaxHighlighter(this._style);
196 193
197 final SyntaxHighlighterStyle _style; 194 final SyntaxHighlighterStyle _style;
198 195
@@ -259,10 +256,10 @@ class DartSyntaxHighlighter { @@ -259,10 +256,10 @@ class DartSyntaxHighlighter {
259 'bool' 256 'bool'
260 ]; 257 ];
261 258
262 - String _src;  
263 - StringScanner _scanner; 259 + late String _src;
  260 + late StringScanner _scanner;
264 261
265 - List<_HighlightSpan> _spans; 262 + final _spans = <_HighlightSpan>[];
266 263
267 TextSpan format(String source) { 264 TextSpan format(String source) {
268 _src = source; 265 _src = source;
@@ -306,18 +303,18 @@ class DartSyntaxHighlighter { @@ -306,18 +303,18 @@ class DartSyntaxHighlighter {
306 // Block comments 303 // Block comments
307 if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { 304 if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) {
308 _spans.add(_HighlightSpan(_HighlightType.comment, 305 _spans.add(_HighlightSpan(_HighlightType.comment,
309 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 306 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
310 continue; 307 continue;
311 } 308 }
312 309
313 // Line comments 310 // Line comments
314 if (_scanner.scan('//')) { 311 if (_scanner.scan('//')) {
315 - final int startComment = _scanner.lastMatch.start; 312 + final int startComment = _scanner.lastMatch!.start;
316 313
317 bool eof = false; 314 bool eof = false;
318 int endComment; 315 int endComment;
319 if (_scanner.scan(RegExp(r'.*\n'))) { 316 if (_scanner.scan(RegExp(r'.*\n'))) {
320 - endComment = _scanner.lastMatch.end - 1; 317 + endComment = _scanner.lastMatch!.end - 1;
321 } else { 318 } else {
322 eof = true; 319 eof = true;
323 endComment = _src.length; 320 endComment = _src.length;
@@ -336,78 +333,78 @@ class DartSyntaxHighlighter { @@ -336,78 +333,78 @@ class DartSyntaxHighlighter {
336 // Raw r"String" 333 // Raw r"String"
337 if (_scanner.scan(RegExp(r'r".*"'))) { 334 if (_scanner.scan(RegExp(r'r".*"'))) {
338 _spans.add(_HighlightSpan(_HighlightType.string, 335 _spans.add(_HighlightSpan(_HighlightType.string,
339 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 336 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
340 continue; 337 continue;
341 } 338 }
342 339
343 // Raw r'String' 340 // Raw r'String'
344 if (_scanner.scan(RegExp(r"r'.*'"))) { 341 if (_scanner.scan(RegExp(r"r'.*'"))) {
345 _spans.add(_HighlightSpan(_HighlightType.string, 342 _spans.add(_HighlightSpan(_HighlightType.string,
346 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 343 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
347 continue; 344 continue;
348 } 345 }
349 346
350 // Multiline """String""" 347 // Multiline """String"""
351 if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { 348 if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) {
352 _spans.add(_HighlightSpan(_HighlightType.string, 349 _spans.add(_HighlightSpan(_HighlightType.string,
353 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 350 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
354 continue; 351 continue;
355 } 352 }
356 353
357 // Multiline '''String''' 354 // Multiline '''String'''
358 if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { 355 if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) {
359 _spans.add(_HighlightSpan(_HighlightType.string, 356 _spans.add(_HighlightSpan(_HighlightType.string,
360 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 357 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
361 continue; 358 continue;
362 } 359 }
363 360
364 // "String" 361 // "String"
365 if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { 362 if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) {
366 _spans.add(_HighlightSpan(_HighlightType.string, 363 _spans.add(_HighlightSpan(_HighlightType.string,
367 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 364 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
368 continue; 365 continue;
369 } 366 }
370 367
371 // 'String' 368 // 'String'
372 if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { 369 if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) {
373 _spans.add(_HighlightSpan(_HighlightType.string, 370 _spans.add(_HighlightSpan(_HighlightType.string,
374 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 371 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
375 continue; 372 continue;
376 } 373 }
377 374
378 // Double 375 // Double
379 if (_scanner.scan(RegExp(r'\d+\.\d+'))) { 376 if (_scanner.scan(RegExp(r'\d+\.\d+'))) {
380 _spans.add(_HighlightSpan(_HighlightType.number, 377 _spans.add(_HighlightSpan(_HighlightType.number,
381 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 378 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
382 continue; 379 continue;
383 } 380 }
384 381
385 // Integer 382 // Integer
386 if (_scanner.scan(RegExp(r'\d+'))) { 383 if (_scanner.scan(RegExp(r'\d+'))) {
387 _spans.add(_HighlightSpan(_HighlightType.number, 384 _spans.add(_HighlightSpan(_HighlightType.number,
388 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 385 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
389 continue; 386 continue;
390 } 387 }
391 388
392 // Punctuation 389 // Punctuation
393 if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { 390 if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) {
394 _spans.add(_HighlightSpan(_HighlightType.punctuation, 391 _spans.add(_HighlightSpan(_HighlightType.punctuation,
395 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 392 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
396 continue; 393 continue;
397 } 394 }
398 395
399 // Meta data 396 // Meta data
400 if (_scanner.scan(RegExp(r'@\w+'))) { 397 if (_scanner.scan(RegExp(r'@\w+'))) {
401 _spans.add(_HighlightSpan(_HighlightType.keyword, 398 _spans.add(_HighlightSpan(_HighlightType.keyword,
402 - _scanner.lastMatch.start, _scanner.lastMatch.end)); 399 + _scanner.lastMatch!.start, _scanner.lastMatch!.end));
403 continue; 400 continue;
404 } 401 }
405 402
406 // Words 403 // Words
407 if (_scanner.scan(RegExp(r'\w+'))) { 404 if (_scanner.scan(RegExp(r'\w+'))) {
408 - _HighlightType type; 405 + _HighlightType? type;
409 406
410 - String word = _scanner.lastMatch[0]; 407 + String word = _scanner.lastMatch![0]!;
411 if (word.startsWith('_')) { 408 if (word.startsWith('_')) {
412 word = word.substring(1); 409 word = word.substring(1);
413 } 410 }
@@ -425,7 +422,7 @@ class DartSyntaxHighlighter { @@ -425,7 +422,7 @@ class DartSyntaxHighlighter {
425 422
426 if (type != null) { 423 if (type != null) {
427 _spans.add(_HighlightSpan( 424 _spans.add(_HighlightSpan(
428 - type, _scanner.lastMatch.start, _scanner.lastMatch.end)); 425 + type, _scanner.lastMatch!.start, _scanner.lastMatch!.end));
429 } 426 }
430 } 427 }
431 428