David PHAM-VAN

Add Flutter 3.7 compatibility

include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-dynamic: false
errors:
missing_required_param: warning
missing_return: warning
... ...
... ... @@ -10,6 +10,7 @@
- Fix lints
- Add options to customise border in Dataset widget [838]
- Add Choice Field [Carsten Fregin]
- Add Flutter 3.7 compatibility
## 3.8.4
... ...
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-dynamic: false
errors:
missing_required_param: warning
missing_return: warning
... ...
... ... @@ -76,7 +76,6 @@ class PdfBool extends PdfDataType {
class PdfNum extends PdfDataType {
const PdfNum(this.value)
: assert(value != double.infinity),
assert(value != double.nan),
assert(value != double.negativeInfinity);
static const int precision = 5;
... ... @@ -85,6 +84,9 @@ class PdfNum extends PdfDataType {
@override
void output(PdfStream s, [int? indent]) {
assert(!value.isNaN);
assert(!value.isInfinite);
if (value is int) {
s.putString(value.toInt().toString());
} else {
... ...
... ... @@ -11,7 +11,7 @@ environment:
dependencies:
archive: ^3.1.0
barcode: ">=2.2.3 <3.0.0"
bidi: ^2.0.2
bidi: ^2.0.6
crypto: ^3.0.0
image: ^4.0.0
meta: ">=1.3.0 <2.0.0"
... ...
... ... @@ -7,6 +7,7 @@
- Update Image dependency
- Fix canChangeOrientation option not appearing bug [Bilal Raja]
- Add Support cmaps option on printing web [Koji Wakamiya]
- Add Flutter 3.7 compatibility
## 5.9.3
... ...
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-dynamic: false
errors:
missing_required_param: warning
missing_return: warning
... ...
... ... @@ -25,8 +25,8 @@ import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
/// ImageProvider that draws a Flutter Widget on a PDF document
class WidgetWraper extends pw.ImageProvider {
WidgetWraper._(
class WidgetWrapper extends pw.ImageProvider {
WidgetWrapper._(
this.bytes,
int width,
int height,
... ... @@ -51,7 +51,7 @@ class WidgetWraper extends pw.ImageProvider {
/// Future<Uint8List> _generatePdf(PdfPageFormat format) async {
/// final pdf = pw.Document();
///
/// final image = await WidgetWraper.fromKey(key: rb);
/// final image = await WidgetWrapper.fromKey(key: rb);
///
/// pdf.addPage(
/// pw.Page(
... ... @@ -66,7 +66,7 @@ class WidgetWraper extends pw.ImageProvider {
/// return pdf.save();
/// }
/// ```
static Future<WidgetWraper> fromKey({
static Future<WidgetWrapper> fromKey({
required GlobalKey key,
int? width,
int? height,
... ... @@ -82,7 +82,7 @@ class WidgetWraper extends pw.ImageProvider {
final byteData = await image.toByteData(format: ui.ImageByteFormat.rawRgba);
if (byteData == null) {
return WidgetWraper._(
return WidgetWrapper._(
Uint8List(0),
0,
0,
... ... @@ -92,7 +92,7 @@ class WidgetWraper extends pw.ImageProvider {
}
final imageData = byteData.buffer.asUint8List();
return WidgetWraper._(
return WidgetWrapper._(
imageData,
image.width,
image.height,
... ... @@ -104,7 +104,7 @@ class WidgetWraper extends pw.ImageProvider {
/// Wrap a Flutter Widget to an ImageProvider.
///
/// ```
/// final wrapped = await WidgetWraper.fromWidget(
/// final wrapped = await WidgetWrapper.fromWidget(
/// widget: Container(
/// color: Colors.white,
/// child: Text(
... ... @@ -125,7 +125,7 @@ class WidgetWraper extends pw.ImageProvider {
/// ),
/// );
/// ```
static Future<WidgetWraper> fromWidget({
static Future<WidgetWrapper> fromWidget({
required Widget widget,
required BoxConstraints constraints,
double pixelRatio = 1.0,
... ... @@ -170,11 +170,7 @@ class WidgetWraper extends pw.ImageProvider {
configuration: ViewConfiguration(
size: Size(_constraints.maxWidth, _constraints.maxHeight),
devicePixelRatio: ui.window.devicePixelRatio),
window: _FlutterView(
configuration: ui.ViewConfiguration(
devicePixelRatio: ui.window.devicePixelRatio,
),
),
window: ui.window,
);
final pipelineOwner = PipelineOwner()..rootNode = renderView;
... ... @@ -204,7 +200,7 @@ class WidgetWraper extends pw.ImageProvider {
throw Exception('Unable to read image data');
}
return WidgetWraper._(
return WidgetWrapper._(
bytes.buffer.asUint8List(),
image.width,
image.height,
... ... @@ -228,15 +224,51 @@ class WidgetWraper extends pw.ImageProvider {
}
}
class _FlutterView extends ui.FlutterView {
_FlutterView({required this.configuration});
final ui.ViewConfiguration configuration;
/// ImageProvider that draws a Flutter Widget on a PDF document
@Deprecated('Use WidgetWrapper instead')
class WidgetWraper extends WidgetWrapper {
WidgetWraper._(
Uint8List bytes,
int width,
int height,
PdfImageOrientation orientation,
double? dpi,
) : super._(bytes, width, height, orientation, dpi);
@override
ui.PlatformDispatcher get platformDispatcher =>
ui.PlatformDispatcher.instance;
/// Wrap a Flutter Widget identified by a GlobalKey to an ImageProvider.
@Deprecated('Use WidgetWrapper.fromKey instead')
static Future<WidgetWrapper> fromKey({
required GlobalKey key,
int? width,
int? height,
double pixelRatio = 1.0,
PdfImageOrientation? orientation,
double? dpi,
}) {
return WidgetWrapper.fromKey(
key: key,
width: width,
pixelRatio: pixelRatio,
orientation: orientation,
dpi: dpi,
);
}
@override
ui.ViewConfiguration get viewConfiguration => configuration;
/// Wrap a Flutter Widget to an ImageProvider.
@Deprecated('Use WidgetWrapper.fromWidget instead')
static Future<WidgetWrapper> fromWidget({
required Widget widget,
required BoxConstraints constraints,
double pixelRatio = 1.0,
PdfImageOrientation? orientation,
double? dpi,
}) {
return WidgetWrapper.fromWidget(
widget: widget,
constraints: constraints,
pixelRatio: pixelRatio,
orientation: orientation,
dpi: dpi,
);
}
}
... ...
... ... @@ -14,13 +14,11 @@
* limitations under the License.
*/
// @dart=2.9
import 'dart:io';
import 'package:markdown/markdown.dart' as md;
Iterable<String> getCode(List<md.Node> nodes, [bool isCode = false]) sync* {
Iterable<String> getCode(List<md.Node>? nodes, [bool isCode = false]) sync* {
if (nodes == null) {
return;
}
... ...
... ... @@ -14,8 +14,6 @@
* limitations under the License.
*/
// @dart=2.9
import 'dart:io';
import 'package:pdf/pdf.dart';
... ... @@ -154,15 +152,16 @@ Future<void> main() async {
}
class SyntaxHighlighterStyle {
const SyntaxHighlighterStyle(
{this.baseStyle,
this.numberStyle,
this.commentStyle,
this.keywordStyle,
this.stringStyle,
this.punctuationStyle,
this.classStyle,
this.constantStyle});
const SyntaxHighlighterStyle({
required this.baseStyle,
required this.numberStyle,
required this.commentStyle,
required this.keywordStyle,
required this.stringStyle,
required this.punctuationStyle,
required this.classStyle,
required this.constantStyle,
});
final TextStyle baseStyle;
final TextStyle numberStyle;
... ... @@ -190,9 +189,7 @@ class SyntaxHighlighterStyle {
}
class DartSyntaxHighlighter {
DartSyntaxHighlighter(this._style) {
_spans = <_HighlightSpan>[];
}
DartSyntaxHighlighter(this._style);
final SyntaxHighlighterStyle _style;
... ... @@ -259,10 +256,10 @@ class DartSyntaxHighlighter {
'bool'
];
String _src;
StringScanner _scanner;
late String _src;
late StringScanner _scanner;
List<_HighlightSpan> _spans;
final _spans = <_HighlightSpan>[];
TextSpan format(String source) {
_src = source;
... ... @@ -306,18 +303,18 @@ class DartSyntaxHighlighter {
// Block comments
if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) {
_spans.add(_HighlightSpan(_HighlightType.comment,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Line comments
if (_scanner.scan('//')) {
final int startComment = _scanner.lastMatch.start;
final int startComment = _scanner.lastMatch!.start;
bool eof = false;
int endComment;
if (_scanner.scan(RegExp(r'.*\n'))) {
endComment = _scanner.lastMatch.end - 1;
endComment = _scanner.lastMatch!.end - 1;
} else {
eof = true;
endComment = _src.length;
... ... @@ -336,78 +333,78 @@ class DartSyntaxHighlighter {
// Raw r"String"
if (_scanner.scan(RegExp(r'r".*"'))) {
_spans.add(_HighlightSpan(_HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Raw r'String'
if (_scanner.scan(RegExp(r"r'.*'"))) {
_spans.add(_HighlightSpan(_HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Multiline """String"""
if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) {
_spans.add(_HighlightSpan(_HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Multiline '''String'''
if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) {
_spans.add(_HighlightSpan(_HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// "String"
if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) {
_spans.add(_HighlightSpan(_HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// 'String'
if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) {
_spans.add(_HighlightSpan(_HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Double
if (_scanner.scan(RegExp(r'\d+\.\d+'))) {
_spans.add(_HighlightSpan(_HighlightType.number,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Integer
if (_scanner.scan(RegExp(r'\d+'))) {
_spans.add(_HighlightSpan(_HighlightType.number,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Punctuation
if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) {
_spans.add(_HighlightSpan(_HighlightType.punctuation,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Meta data
if (_scanner.scan(RegExp(r'@\w+'))) {
_spans.add(_HighlightSpan(_HighlightType.keyword,
_scanner.lastMatch.start, _scanner.lastMatch.end));
_scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue;
}
// Words
if (_scanner.scan(RegExp(r'\w+'))) {
_HighlightType type;
_HighlightType? type;
String word = _scanner.lastMatch[0];
String word = _scanner.lastMatch![0]!;
if (word.startsWith('_')) {
word = word.substring(1);
}
... ... @@ -425,7 +422,7 @@ class DartSyntaxHighlighter {
if (type != null) {
_spans.add(_HighlightSpan(
type, _scanner.lastMatch.start, _scanner.lastMatch.end));
type, _scanner.lastMatch!.start, _scanner.lastMatch!.end));
}
}
... ...