David PHAM-VAN

Fix lints

... ... @@ -7,6 +7,7 @@
- Add Inseparable Widget
- Fix unit tests
- Update Image dependency
- Fix lints
## 3.8.4
... ...
... ... @@ -10,6 +10,7 @@ analyzer:
todo: ignore
constant_identifier_names: ignore
avoid_print: ignore
no_leading_underscores_for_local_identifiers: ignore
linter:
rules:
... ...
... ... @@ -43,7 +43,7 @@ String logicalToVisual(String input) {
final buffer = StringBuffer();
final paragraphs = bidi.splitStringToParagraphs(input);
for (final paragraph in paragraphs) {
final endsWithNewLine = paragraph.paragraphSeparator == 10;
final endsWithNewLine = paragraph.separator == 10;
final endIndex = paragraph.bidiText.length - (endsWithNewLine ? 1 : 0);
final visual = String.fromCharCodes(paragraph.bidiText, 0, endIndex);
buffer.write(visual.split(' ').reversed.join(' '));
... ...
... ... @@ -127,7 +127,7 @@ class PdfGraphicState {
if (blendMode != null) {
final bm = blendMode.toString();
params['/BM'] =
PdfName('/' + bm.substring(13, 14).toUpperCase() + bm.substring(14));
PdfName('/${bm.substring(13, 14).toUpperCase()}${bm.substring(14)}');
}
if (softMask != null) {
... ...
... ... @@ -63,7 +63,7 @@ class PdfBorder extends PdfObjectDict {
super.prepare();
params['/S'] =
PdfName('/' + 'SDBIU'.substring(style.index, style.index + 1));
PdfName('/${'SDBIU'.substring(style.index, style.index + 1)}');
params['/W'] = PdfNum(width);
if (dash != null) {
... ...
... ... @@ -37,7 +37,7 @@ class PdfFontDescriptor extends PdfObjectDict {
void prepare() {
super.prepare();
params['/FontName'] = PdfName('/' + ttfFont.fontName);
params['/FontName'] = PdfName('/${ttfFont.fontName}');
params['/FontFile2'] = file.ref();
params['/Flags'] = PdfNum(ttfFont.font.unicode ? 4 : 32);
params['/FontBBox'] = PdfArray.fromNum(<int>[
... ...
... ... @@ -89,7 +89,7 @@ class PdfTtfFont extends PdfFont {
file.buf.putBytes(font.bytes.buffer.asUint8List());
file.params['/Length1'] = PdfNum(font.bytes.lengthInBytes);
params['/BaseFont'] = PdfName('/' + fontName);
params['/BaseFont'] = PdfName('/$fontName');
params['/FontDescriptor'] = descriptor.ref();
charMin = 32;
charMax = 255;
... ... @@ -113,7 +113,7 @@ class PdfTtfFont extends PdfFont {
final descendantFont = PdfDict({
'/Type': const PdfName('/Font'),
'/BaseFont': PdfName('/' + fontName),
'/BaseFont': PdfName('/$fontName'),
'/FontFile2': file.ref(),
'/FontDescriptor': descriptor.ref(),
'/W': PdfArray([
... ... @@ -130,7 +130,7 @@ class PdfTtfFont extends PdfFont {
})
});
params['/BaseFont'] = PdfName('/' + fontName);
params['/BaseFont'] = PdfName('/$fontName');
params['/Encoding'] = const PdfName('/Identity-H');
params['/DescendantFonts'] = PdfArray([descendantFont]);
params['/ToUnicode'] = unicodeCMap.ref();
... ...
... ... @@ -59,7 +59,7 @@ class PdfType1Font extends PdfFont {
void prepare() {
super.prepare();
params['/BaseFont'] = PdfName('/' + fontName);
params['/BaseFont'] = PdfName('/$fontName');
}
@override
... ...
... ... @@ -51,11 +51,8 @@ class PdfUnicodeCmap extends PdfObjectStream {
for (var key = 0; key < cmap.length; key++) {
final value = cmap[key];
buf.putString('<' +
key.toRadixString(16).toUpperCase().padLeft(4, '0') +
'> <' +
value.toRadixString(16).toUpperCase().padLeft(4, '0') +
'>\n');
buf.putString(
'<${key.toRadixString(16).toUpperCase().padLeft(4, '0')}> <${value.toRadixString(16).toUpperCase().padLeft(4, '0')}>\n');
}
buf.putString('endbfchar\n'
... ...
... ... @@ -50,10 +50,7 @@ class PdfXref {
/// The xref in the format of the xref section in the Pdf file
String ref() {
return offset.toString().padLeft(10, '0') +
' ' +
generation.toString().padLeft(5, '0') +
(type == PdfCrossRefEntryType.inUse ? ' n ' : ' f ');
return '${offset.toString().padLeft(10, '0')} ${generation.toString().padLeft(5, '0')}${type == PdfCrossRefEntryType.inUse ? ' n ' : ' f '}';
}
PdfIndirect? get container => object == null ? null : PdfIndirect(object!, 0);
... ...
... ... @@ -62,19 +62,19 @@ enum VerticalDirection {
typedef _ChildSizingFunction = double? Function(Widget child, double? extent);
class _FlexContext extends WidgetContext {
class FlexContext extends WidgetContext {
int firstChild = 0;
int lastChild = 0;
@override
void apply(_FlexContext other) {
void apply(FlexContext other) {
firstChild = other.firstChild;
lastChild = other.lastChild;
}
@override
WidgetContext clone() {
return _FlexContext()..apply(this);
return FlexContext()..apply(this);
}
@override
... ... @@ -101,7 +101,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
final VerticalDirection verticalDirection;
final _FlexContext _context = _FlexContext();
final FlexContext _context = FlexContext();
double _getIntrinsicSize(
{Axis? sizingDirection,
... ... @@ -502,7 +502,7 @@ class Flex extends MultiChildWidget with SpanningWidget {
bool get hasMoreWidgets => true;
@override
void restoreContext(_FlexContext context) {
void restoreContext(FlexContext context) {
_context.firstChild = context.lastChild;
}
... ...
... ... @@ -24,7 +24,7 @@ import 'geometry.dart';
import 'multi_page.dart';
import 'widget.dart';
class _GridViewContext extends WidgetContext {
class GridViewContext extends WidgetContext {
int firstChild = 0;
int lastChild = 0;
... ... @@ -32,7 +32,7 @@ class _GridViewContext extends WidgetContext {
double? childMainAxis;
@override
void apply(_GridViewContext other) {
void apply(GridViewContext other) {
firstChild = other.firstChild;
lastChild = other.lastChild;
childCrossAxis = other.childCrossAxis ?? childCrossAxis;
... ... @@ -41,7 +41,7 @@ class _GridViewContext extends WidgetContext {
@override
WidgetContext clone() {
return _GridViewContext()..apply(this);
return GridViewContext()..apply(this);
}
@override
... ... @@ -67,7 +67,7 @@ class GridView extends MultiChildWidget with SpanningWidget {
final double crossAxisSpacing;
final double childAspectRatio;
final _GridViewContext _context = _GridViewContext();
final GridViewContext _context = GridViewContext();
int? _mainAxisCount;
... ... @@ -331,7 +331,7 @@ class GridView extends MultiChildWidget with SpanningWidget {
bool get hasMoreWidgets => true;
@override
void restoreContext(_GridViewContext context) {
void restoreContext(GridViewContext context) {
_context.apply(context);
_context.firstChild = context.lastChild;
}
... ...
... ... @@ -77,14 +77,14 @@ class Partition extends Widget with SpanningWidget {
bool get hasMoreWidgets => child.hasMoreWidgets;
}
class _PartitionsContext extends WidgetContext {
_PartitionsContext(int count)
class PartitionsContext extends WidgetContext {
PartitionsContext(int count)
: partitionContext = List<WidgetContext?>.filled(count, null);
final List<WidgetContext?> partitionContext;
@override
void apply(_PartitionsContext other) {
void apply(PartitionsContext other) {
for (var index = 0; index < partitionContext.length; index++) {
partitionContext[index]?.apply(other.partitionContext[index]!);
}
... ... @@ -92,7 +92,7 @@ class _PartitionsContext extends WidgetContext {
@override
WidgetContext clone() {
final context = _PartitionsContext(partitionContext.length);
final context = PartitionsContext(partitionContext.length);
for (var index = 0; index < partitionContext.length; index++) {
context.partitionContext[index] = partitionContext[index]?.clone();
}
... ... @@ -105,12 +105,12 @@ class Partitions extends Widget with SpanningWidget {
Partitions({
required this.children,
this.mainAxisSize = MainAxisSize.max,
}) : _context = _PartitionsContext(children.length),
}) : _context = PartitionsContext(children.length),
super();
final List<Partition> children;
final _PartitionsContext _context;
final PartitionsContext _context;
final MainAxisSize mainAxisSize;
... ... @@ -218,7 +218,7 @@ class Partitions extends Widget with SpanningWidget {
}
@override
void restoreContext(_PartitionsContext context) {
void restoreContext(PartitionsContext context) {
_context.apply(context);
var index = 0;
for (final child in children) {
... ...
... ... @@ -121,7 +121,7 @@ class LoremText {
}
wordList.add(w);
}
final text = wordList.join(' ') + '.';
final text = '${wordList.join(' ')}.';
return text[0].toUpperCase() + text.substring(1);
}
... ...
... ... @@ -136,27 +136,27 @@ class TableBorder extends Border {
}
}
class _TableContext extends WidgetContext {
class TableContext extends WidgetContext {
int firstLine = 0;
int lastLine = 0;
@override
void apply(_TableContext other) {
void apply(TableContext other) {
firstLine = other.firstLine;
lastLine = other.lastLine;
}
@override
WidgetContext clone() {
return _TableContext()..apply(this);
return TableContext()..apply(this);
}
@override
String toString() => '$runtimeType firstLine: $firstLine lastLine: $lastLine';
}
class _ColumnLayout {
_ColumnLayout(this.width, this.flex);
class ColumnLayout {
ColumnLayout(this.width, this.flex);
final double? width;
final double? flex;
... ... @@ -165,7 +165,7 @@ class _ColumnLayout {
abstract class TableColumnWidth {
const TableColumnWidth();
_ColumnLayout layout(
ColumnLayout layout(
Widget child, Context context, BoxConstraints constraints);
}
... ... @@ -175,10 +175,10 @@ class IntrinsicColumnWidth extends TableColumnWidth {
final double? flex;
@override
_ColumnLayout layout(
ColumnLayout layout(
Widget child, Context context, BoxConstraints constraints) {
if (flex != null) {
return _ColumnLayout(0, flex);
return ColumnLayout(0, flex);
}
child.layout(context, const BoxConstraints());
... ... @@ -189,7 +189,7 @@ class IntrinsicColumnWidth extends TableColumnWidth {
(child is Expanded
? child.flex.toDouble()
: (child.box!.width == double.infinity ? 1 : 0));
return _ColumnLayout(calculatedWidth, childFlex);
return ColumnLayout(calculatedWidth, childFlex);
}
}
... ... @@ -199,9 +199,9 @@ class FixedColumnWidth extends TableColumnWidth {
final double width;
@override
_ColumnLayout layout(
ColumnLayout layout(
Widget child, Context context, BoxConstraints? constraints) {
return _ColumnLayout(width, 0);
return ColumnLayout(width, 0);
}
}
... ... @@ -211,9 +211,9 @@ class FlexColumnWidth extends TableColumnWidth {
final double flex;
@override
_ColumnLayout layout(
ColumnLayout layout(
Widget child, Context context, BoxConstraints? constraints) {
return _ColumnLayout(0, flex);
return ColumnLayout(0, flex);
}
}
... ... @@ -223,9 +223,9 @@ class FractionColumnWidth extends TableColumnWidth {
final double value;
@override
_ColumnLayout layout(
ColumnLayout layout(
Widget child, Context context, BoxConstraints? constraints) {
return _ColumnLayout(constraints!.maxWidth * value, 0);
return ColumnLayout(constraints!.maxWidth * value, 0);
}
}
... ... @@ -412,7 +412,7 @@ class Table extends Widget with SpanningWidget {
final List<double?> _widths = <double?>[];
final List<double> _heights = <double>[];
final _TableContext _context = _TableContext();
final TableContext _context = TableContext();
final TableColumnWidth defaultColumnWidth;
final Map<int, TableColumnWidth>? columnWidths;
... ... @@ -423,7 +423,7 @@ class Table extends Widget with SpanningWidget {
}
@override
void restoreContext(_TableContext context) {
void restoreContext(TableContext context) {
_context.apply(context);
_context.firstLine = _context.lastLine;
}
... ...
... ... @@ -393,7 +393,7 @@ class _WidgetSpan extends _Span {
}
}
typedef _VisitorCallback = bool Function(
typedef VisitorCallback = bool Function(
InlineSpan span,
TextStyle? parentStyle,
AnnotationBuilder? annotation,
... ... @@ -435,7 +435,7 @@ abstract class InlineSpan {
}
bool visitChildren(
_VisitorCallback visitor,
VisitorCallback visitor,
TextStyle? parentStyle,
AnnotationBuilder? annotation,
);
... ... @@ -469,7 +469,7 @@ class WidgetSpan extends InlineSpan {
/// Calls `visitor` on this [WidgetSpan]. There are no children spans to walk.
@override
bool visitChildren(
_VisitorCallback visitor,
VisitorCallback visitor,
TextStyle? parentStyle,
AnnotationBuilder? annotation,
) {
... ... @@ -509,7 +509,7 @@ class TextSpan extends InlineSpan {
@override
bool visitChildren(
_VisitorCallback visitor,
VisitorCallback visitor,
TextStyle? parentStyle,
AnnotationBuilder? annotation,
) {
... ... @@ -624,14 +624,14 @@ class _Line {
}
}
class _RichTextContext extends WidgetContext {
class RichTextContext extends WidgetContext {
var startOffset = 0.0;
var endOffset = 0.0;
var spanStart = 0;
var spanEnd = 0;
@override
void apply(_RichTextContext other) {
void apply(RichTextContext other) {
startOffset = other.startOffset;
endOffset = other.endOffset;
spanStart = other.spanStart;
... ... @@ -640,7 +640,7 @@ class _RichTextContext extends WidgetContext {
@override
WidgetContext clone() {
return _RichTextContext()..apply(this);
return RichTextContext()..apply(this);
}
@override
... ... @@ -682,7 +682,7 @@ class RichText extends Widget with SpanningWidget {
final List<_TextDecoration> _decorations = <_TextDecoration>[];
final _context = _RichTextContext();
final _context = RichTextContext();
final TextOverflow? overflow;
... ... @@ -1297,7 +1297,7 @@ class RichText extends Widget with SpanningWidget {
bool get hasMoreWidgets => canSpan;
@override
void restoreContext(_RichTextContext context) {
void restoreContext(RichTextContext context) {
_context.spanStart = context.spanEnd;
_context.startOffset = -context.endOffset;
}
... ...
... ... @@ -45,19 +45,19 @@ class _RunMetrics {
final int childCount;
}
class _WrapContext extends WidgetContext {
class WrapContext extends WidgetContext {
int firstChild = 0;
int lastChild = 0;
@override
void apply(_WrapContext other) {
void apply(WrapContext other) {
firstChild = other.firstChild;
lastChild = other.lastChild;
}
@override
WidgetContext clone() {
return _WrapContext()..apply(this);
return WrapContext()..apply(this);
}
@override
... ... @@ -110,7 +110,7 @@ class Wrap extends MultiChildWidget with SpanningWidget {
@override
bool get hasMoreWidgets => _context.lastChild < children.length;
final _WrapContext _context = _WrapContext();
final WrapContext _context = WrapContext();
double? _getMainAxisExtent(Widget child) {
switch (direction) {
... ... @@ -390,7 +390,7 @@ class Wrap extends MultiChildWidget with SpanningWidget {
}
@override
void restoreContext(_WrapContext context) {
void restoreContext(WrapContext context) {
_context.apply(context);
_context.firstChild = context.lastChild;
}
... ...
... ... @@ -20,5 +20,5 @@ dependencies:
xml: ">=5.1.0 <7.0.0"
dev_dependencies:
flutter_lints: ^1.0.4
flutter_lints: ^2.0.0
test: ">=1.16.0 <2.0.0"
... ...
... ... @@ -24,6 +24,7 @@ import '../printing.dart';
import '../printing_info.dart';
import 'page.dart';
import 'raster.dart';
/// Custom widget builder that's used for custom
/// rasterized pdf pages rendering
typedef CustomPdfPagesBuilder = Widget Function(
... ...
... ... @@ -15,6 +15,7 @@
*/
import 'package:flutter/material.dart';
/// A class that holds rasterized pdf data
class PdfPreviewPageData {
/// Default constructor
... ... @@ -26,8 +27,10 @@ class PdfPreviewPageData {
/// rasterized pdf image provider
final ImageProvider image;
/// rasterized image width
final int width;
/// rasterized image height
final int height;
... ...