David PHAM-VAN

Apply Flutter 2.5 coding style

include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-dynamic: false
errors:
missing_required_param: warning
missing_return: warning
public_member_api_docs: ignore
todo: ignore
constant_identifier_names: ignore
avoid_print: ignore
linter:
rules:
- always_put_control_body_on_new_line
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_field_initializers_in_const_classes
- avoid_slow_async_io
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- directives_ordering
- flutter_style_todos
- no_adjacent_strings_in_list
- omit_local_variable_types
- package_api_docs
- prefer_asserts_in_initializer_lists
- prefer_final_locals
- prefer_foreach
- prefer_if_elements_to_conditional_expressions
- prefer_single_quotes
- public_member_api_docs
- sort_constructors_first
- sort_pub_dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- unnecessary_statements
... ...
... ... @@ -30,6 +30,8 @@ import 'data.dart';
import 'examples.dart';
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
MyAppState createState() {
return MyAppState();
... ... @@ -42,7 +44,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
PrintingInfo? printingInfo;
var _data = CustomData();
var _data = const CustomData();
var _hasData = false;
var _pending = false;
... ... @@ -175,10 +177,10 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
final controller = TextEditingController();
return AlertDialog(
title: Text('Please type your name:'),
contentPadding: EdgeInsets.symmetric(horizontal: 20),
title: const Text('Please type your name:'),
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
content: TextField(
decoration: InputDecoration(hintText: '[your name]'),
decoration: const InputDecoration(hintText: '[your name]'),
controller: controller,
),
actions: [
... ... @@ -188,7 +190,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
Navigator.pop(context, controller.text);
}
},
child: Text('OK'),
child: const Text('OK'),
),
],
);
... ...
... ... @@ -53,7 +53,7 @@ Future<Uint8List> generateCertificate(
fontSize: 25,
),
children: [
pw.TextSpan(text: 'CERTIFICATE '),
const pw.TextSpan(text: 'CERTIFICATE '),
pw.TextSpan(
text: 'of',
style: pw.TextStyle(
... ... @@ -61,7 +61,7 @@ Future<Uint8List> generateCertificate(
fontWeight: pw.FontWeight.normal,
),
),
pw.TextSpan(text: ' ACHIEVEMENT'),
const pw.TextSpan(text: ' ACHIEVEMENT'),
]),
),
pw.Spacer(),
... ... @@ -108,10 +108,10 @@ Future<Uint8List> generateCertificate(
height: 10,
),
pw.Padding(
padding: pw.EdgeInsets.symmetric(horizontal: 10),
padding: const pw.EdgeInsets.symmetric(horizontal: 10),
child: pw.Text(
'Flutter PDF Demo',
style: pw.TextStyle(
style: const pw.TextStyle(
fontSize: 10,
),
),
... ... @@ -138,7 +138,7 @@ Future<Uint8List> generateCertificate(
pw.Flexible(
child: pw.Text(
lorem.paragraph(40),
style: pw.TextStyle(fontSize: 6),
style: const pw.TextStyle(fontSize: 6),
textAlign: pw.TextAlign.justify,
),
),
... ... @@ -161,16 +161,16 @@ Future<Uint8List> generateCertificate(
buildBackground: (context) => pw.FullPage(
ignoreMargins: true,
child: pw.Container(
margin: pw.EdgeInsets.all(10),
margin: const pw.EdgeInsets.all(10),
decoration: pw.BoxDecoration(
border:
pw.Border.all(color: PdfColor.fromInt(0xffe435), width: 1),
border: pw.Border.all(
color: const PdfColor.fromInt(0xffe435), width: 1),
),
child: pw.Container(
margin: pw.EdgeInsets.all(5),
margin: const pw.EdgeInsets.all(5),
decoration: pw.BoxDecoration(
border:
pw.Border.all(color: PdfColor.fromInt(0xffe435), width: 5),
border: pw.Border.all(
color: const PdfColor.fromInt(0xffe435), width: 5),
),
width: double.infinity,
height: double.infinity,
... ... @@ -240,7 +240,7 @@ Future<Uint8List> generateCertificate(
),
),
pw.Padding(
padding: pw.EdgeInsets.only(
padding: const pw.EdgeInsets.only(
top: 120,
left: 80,
right: 80,
... ...
... ... @@ -51,7 +51,7 @@ Future<Uint8List> generateDocument(
),
build: (context) {
return pw.Padding(
padding: pw.EdgeInsets.only(
padding: const pw.EdgeInsets.only(
left: 60,
right: 60,
bottom: 30,
... ... @@ -90,7 +90,7 @@ Future<Uint8List> generateDocument(
destination: 'https://wikipedia.org/wiki/PDF',
child: pw.Text(
'https://wikipedia.org/wiki/PDF',
style: pw.TextStyle(
style: const pw.TextStyle(
color: PdfColors.pink100,
),
),
... ...
... ... @@ -288,7 +288,7 @@ Future<Uint8List> generateReport(
legend: '${data[0]}\n$pct%',
value: value,
color: color,
legendStyle: pw.TextStyle(fontSize: 10),
legendStyle: const pw.TextStyle(fontSize: 10),
);
}),
),
... ...
... ... @@ -19,10 +19,12 @@ import 'package:flutter/material.dart';
import 'app.dart';
void main() {
runApp(App());
runApp(const App());
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
const scrollbarTheme =
... ... @@ -32,7 +34,7 @@ class App extends StatelessWidget {
theme: ThemeData.light().copyWith(scrollbarTheme: scrollbarTheme),
darkTheme: ThemeData.dark().copyWith(scrollbarTheme: scrollbarTheme),
title: 'Flutter PDF Demo',
home: MyApp(),
home: const MyApp(),
);
}
}
... ...
... ... @@ -17,6 +17,7 @@ dependencies:
url_launcher: ^6.0.6
dev_dependencies:
flutter_lints: ^1.0.4
flutter_test:
sdk: flutter
test: ^1.16.5
... ...
... ... @@ -7,7 +7,7 @@ import 'package:printing_demo/examples/document.dart';
void main() {
testWidgets('Pdf Generate the document', (WidgetTester tester) async {
final data = CustomData();
const data = CustomData();
final doc = await generateDocument(PdfPageFormat.a4, data);
final file = File('document.pdf');
... ...
... ... @@ -3,6 +3,7 @@
## 3.6.0
- Fix text justify with multiple paragraphs
- Apply Flutter 2.5 coding style
## 3.5.0
... ...
include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
... ... @@ -8,6 +8,8 @@ analyzer:
missing_return: warning
public_member_api_docs: ignore
todo: ignore
constant_identifier_names: ignore
avoid_print: ignore
linter:
rules:
... ... @@ -15,52 +17,24 @@ linter:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_renaming_method_parameters
- avoid_returning_null_for_void
- avoid_slow_async_io
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- control_flow_in_finally
- directives_ordering
- empty_statements
- flutter_style_todos
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- non_constant_identifier_names
- omit_local_variable_types
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_final_locals
- prefer_foreach
- prefer_if_elements_to_conditional_expressions
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- prefer_single_quotes
- public_member_api_docs
- sort_constructors_first
- sort_pub_dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_null_aware_assignments
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- use_full_hex_values_for_flutter_colors
... ...
... ... @@ -15,7 +15,6 @@
*/
export 'src/pdf/annotation.dart';
export 'src/pdf/arabic.dart';
export 'src/pdf/border.dart';
export 'src/pdf/color.dart';
export 'src/pdf/colors.dart';
... ...
... ... @@ -14,11 +14,9 @@
* limitations under the License.
*/
/// Arabic shape substitutions functions
class PdfArabic {
/// Arabic shape substitutions: char code => (isolated, final, initial, medial).
/// Arabic Substition A
static const Map<int, dynamic> _arabicSubstitionA = <int, dynamic>{
/// Arabic shape substitutions: char code => (isolated, final, initial, medial).
/// Arabic Substition A
const Map<int, dynamic> _arabicSubstitionA = <int, dynamic>{
0x0640: <int>[0x0640, 0x0640, 0x0640, 0x0640], // ARABIC TATWEEL
0x0621: <int>[0xFE80], // ARABIC LETTER HAMZA
... ... @@ -107,15 +105,15 @@ class PdfArabic {
0x06D0: <int>[0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7], //ARABIC LETTER E
0x06D2: <int>[0xFBAE, 0xFBAF], // ARABIC LETTER YEH BARREE
0x06D3: <int>[0xFBB0, 0xFBB1], // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE
};
};
/*
/*
var ligaturesSubstitutionA = {
0xFBEA: []// ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF ISOLATED FORM
};
*/
static const Map<int, dynamic> _diacriticLigatures = <int, dynamic>{
const Map<int, dynamic> _diacriticLigatures = <int, dynamic>{
0x0651: <int, int>{
0x064C: 0xFC5E, // Shadda + Dammatan
0x064D: 0xFC5F, // Shadda + Kasratan
... ... @@ -124,9 +122,9 @@ class PdfArabic {
0x0650: 0xFC62, // Shadda + Kasra
0x0670: 0xFC63, // Shadda + Dagger alif
},
};
};
static const Map<int, dynamic> _ligatures = <int, dynamic>{
const Map<int, dynamic> _ligatures = <int, dynamic>{
0xFEDF: <int, int>{
0xFE82:
0xFEF5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
... ... @@ -137,12 +135,9 @@ class PdfArabic {
0xFE8E: 0xFEFB // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
},
0xFEE0: <int, int>{
0xFE82:
0xFEF6, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
0xFE84:
0xFEF8, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
0xFE88:
0xFEFA, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM
0xFE82: 0xFEF6, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
0xFE84: 0xFEF8, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
0xFE88: 0xFEFA, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM
0xFE8E: 0xFEFC // ARABIC LIGATURE LAM WITH ALEF FINAL FORM
},
// 0xFE8D: <int, dynamic>{
... ... @@ -150,11 +145,11 @@ class PdfArabic {
// 0xFEE0: <int, int>{0xFEEA: 0xFDF2}
// }
// }, // ALLAH
};
};
static const List<int> _alfletter = <int>[1570, 1571, 1573, 1575];
const List<int> _alfletter = <int>[1570, 1571, 1573, 1575];
static const Map<int, int> _arabicDiacritics = <int, int>{
const Map<int, int> _arabicDiacritics = <int, int>{
0x064B: 0x064B, // Fathatan
0x064C: 0x064C, // Dammatan
0x064D: 0x064D, // Kasratan
... ... @@ -173,56 +168,56 @@ class PdfArabic {
0xFC62: 0xFC62, // Shadda + Kasra
0xFC63: 0xFC63, // Shadda + Dagger alif
// 1548: 1548,
};
};
static const int _noChangeInForm = -1;
static const int _isolatedForm = 0;
static const int _finalForm = 1;
static const int _initialForm = 2;
static const int _medialForm = 3;
const int _noChangeInForm = -1;
const int _isolatedForm = 0;
const int _finalForm = 1;
const int _initialForm = 2;
const int _medialForm = 3;
static bool _isInArabicSubstitutionA(int letter) {
bool _isInArabicSubstitutionA(int letter) {
return _arabicSubstitionA.containsKey(letter);
}
}
static bool _isArabicLetter(int letter) {
bool _isArabicLetter(int letter) {
return (letter >= 0x0600 && letter <= 0x06FF) ||
(letter >= 0x0750 && letter <= 0x077F) ||
(letter >= 0x08FF && letter <= 0xFB50) ||
(letter >= 0xFDFF && letter <= 0xFEFF);
}
}
static bool _isArabicEndLetter(int letter) {
bool _isArabicEndLetter(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
_arabicSubstitionA[letter].length <= 2;
}
}
static bool _isArabicAlfLetter(int letter) {
bool _isArabicAlfLetter(int letter) {
return _isArabicLetter(letter) && _alfletter.contains(letter);
}
}
static bool _arabicLetterHasFinalForm(int letter) {
bool _arabicLetterHasFinalForm(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
(_arabicSubstitionA[letter].length >= 2);
}
}
static bool _arabicLetterHasMedialForm(int letter) {
bool _arabicLetterHasMedialForm(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
_arabicSubstitionA[letter].length == 4;
}
}
static bool _isArabicDiacritic(int letter) {
bool _isArabicDiacritic(int letter) {
return _arabicDiacritics.containsKey(letter);
}
}
static bool isArabicDiacriticValue(int letter) {
bool isArabicDiacriticValue(int letter) {
return _arabicDiacritics.containsValue(letter);
}
}
static List<int> _resolveLigatures(List<int> lettersq) {
List<int> _resolveLigatures(List<int> lettersq) {
final result = <int>[];
dynamic tmpLigatures = _ligatures;
dynamic tmpDiacritic = _diacriticLigatures;
... ... @@ -290,9 +285,9 @@ class PdfArabic {
}
return result;
}
}
static int _getCorrectForm(int currentChar, int beforeChar, int nextChar) {
int _getCorrectForm(int currentChar, int beforeChar, int nextChar) {
if (_isInArabicSubstitutionA(currentChar) == false) {
return _noChangeInForm;
}
... ... @@ -317,9 +312,9 @@ class PdfArabic {
return _finalForm;
}
return _initialForm;
}
}
static Iterable<String> _parse(String text) sync* {
Iterable<String> _parse(String text) sync* {
final words = text.split(' ');
final notArabicWords = <List<int>>[];
... ... @@ -350,8 +345,7 @@ class PdfArabic {
if (_isArabicLetter(currentLetter)) {
isNewWordArabic = true;
final position =
_getCorrectForm(currentLetter, prevLetter, nextLetter);
final position = _getCorrectForm(currentLetter, prevLetter, nextLetter);
prevLetter = currentLetter;
if (position != -1) {
newWord.insert(0, _arabicSubstitionA[currentLetter][position]);
... ... @@ -391,10 +385,9 @@ class PdfArabic {
yield ' ';
}
}
}
}
/// Apply Arabic shape substitutions
static String convert(String input) {
/// Apply Arabic shape substitutions
String convert(String input) {
return List<String>.from(_parse(input)).join('');
}
}
... ...
... ... @@ -49,7 +49,7 @@ class PdfCatalog extends PdfObjectDict {
final PdfNames names;
/// These map the page modes just defined to the pagemodes setting of Pdf.
static const List<String> _PdfPageModes = <String>[
static const List<String> _pdfPageModes = <String>[
'/UseNone',
'/UseOutlines',
'/UseThumbs',
... ... @@ -78,7 +78,7 @@ class PdfCatalog extends PdfObjectDict {
params['/Names'] = names.ref();
// the /PageMode setting
params['/PageMode'] = PdfName(_PdfPageModes[pageMode.index]);
params['/PageMode'] = PdfName(_pdfPageModes[pageMode.index]);
if (pdfDocument.sign != null) {
if (pdfDocument.sign!.value.hasMDP) {
... ...
... ... @@ -199,10 +199,10 @@ class PdfString extends PdfDataType {
final encoding = <int>[];
final add = (int unit) {
void add(int unit) {
encoding.add((unit & UNICODE_BYTE_ONE_MASK) >> 8);
encoding.add(unit & UNICODE_BYTE_ZERO_MASK);
};
}
for (var unit in str.codeUnits) {
if ((unit >= 0 && unit < UNICODE_UTF16_RESERVED_LO) ||
... ...
... ... @@ -139,7 +139,7 @@ class PdfGraphicState {
@override
bool operator ==(dynamic other) {
if (!(other is PdfGraphicState)) {
if (other is! PdfGraphicState) {
return false;
}
return other.fillOpacity == fillOpacity &&
... ...
... ... @@ -17,7 +17,7 @@
import 'dart:convert';
import 'dart:typed_data';
import 'arabic.dart';
import 'arabic.dart' as arabic;
import 'array.dart';
import 'data_types.dart';
import 'document.dart';
... ... @@ -74,7 +74,7 @@ class PdfTtfFont extends PdfFont {
return PdfFontMetrics.zero;
}
if (PdfArabic.isArabicDiacriticValue(charCode)) {
if (arabic.isArabicDiacriticValue(charCode)) {
final metric = font.glyphInfoMap[g] ?? PdfFontMetrics.zero;
return metric.copyWith(advanceWidth: 0);
}
... ...
... ... @@ -33,6 +33,7 @@ class PdfType1Font extends PdfFont {
PdfType1Font.create(PdfDocument pdfDocument, this.fontName, this.ascent,
this.descent, this.widths)
: assert(() {
// ignore: avoid_print
print(
'$fontName has no Unicode support see https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management');
return true;
... ...
... ... @@ -101,5 +101,5 @@ class SvgTransform {
static const none = SvgTransform(null);
static final _transformRegExp =
RegExp('(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)\s*');
RegExp(r'(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)\s*');
}
... ...
... ... @@ -148,7 +148,7 @@ class Stack extends MultiChildWidget {
}
for (var child in children) {
if (!(child is Positioned)) {
if (child is! Positioned) {
hasNonPositionedChildren = true;
child.layout(context, nonPositionedConstraints, parentUsesSize: true);
... ... @@ -169,7 +169,7 @@ class Stack extends MultiChildWidget {
}
for (var child in children) {
if (!(child is Positioned)) {
if (child is! Positioned) {
child.box = PdfRect.fromPoints(
alignment.inscribe(child.box!.size, box!).offset, child.box!.size);
} else {
... ...
... ... @@ -18,6 +18,7 @@ import 'dart:math' as math;
import 'package:meta/meta.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/src/pdf/arabic.dart' as arabic;
import 'annotations.dart';
import 'document.dart';
... ... @@ -682,7 +683,7 @@ class RichText extends Widget with SpanningWidget {
font.stringMetrics(' ') * (style.fontSize! * textScaleFactor);
final spanLines = (_textDirection == TextDirection.rtl
? PdfArabic.convert(span.text!)
? arabic.convert(span.text!)
: span.text)!
.split('\n');
... ...
name: pdf
author: David PHAM-VAN <dev.nfet.net@gmail.com>
description: A pdf producer for Dart. It can create pdf files for both web or flutter.
homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository: https://github.com/DavBfr/dart_pdf
... ... @@ -20,5 +19,5 @@ dependencies:
xml: ^5.1.0
dev_dependencies:
pedantic: ^1.11.0
flutter_lints: ^1.0.4
test: ^1.16.0
... ...
... ... @@ -16,7 +16,7 @@
import 'dart:io';
import 'package:pdf/pdf.dart';
import 'package:pdf/src/pdf/arabic.dart' as arabic;
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
... ... @@ -51,11 +51,11 @@ void main() {
<int>[1612, 65249, 1618, 1614, 65276, 1614, 65204, 65247, 65165]);
expect(
PdfArabic.convert(a.original).codeUnits,
arabic.convert(a.original).codeUnits,
equals(a.reshaped),
);
expect(
PdfArabic.convert(b.original).codeUnits,
arabic.convert(b.original).codeUnits,
equals(b.reshaped),
);
});
... ... @@ -453,7 +453,7 @@ void main() {
for (var item in cases) {
try {
expect(
PdfArabic.convert(item.original).codeUnits,
arabic.convert(item.original).codeUnits,
equals(item.reshaped),
);
} catch (e) {
... ...
... ... @@ -105,7 +105,8 @@ class ColorWheel extends Widget {
large: false, sweep: true)
..lineTo(endBottom.x, endBottom.y)
..bezierArc(endBottom.x, endBottom.y, radius2, radius2, startBottom.x,
startBottom.y, large: false)
startBottom.y,
large: false)
..lineTo(startTop.x, startTop.y)
..fillPath()
..moveTo(startTop.x, startTop.y)
... ...
... ... @@ -16,9 +16,9 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -16,9 +16,9 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -16,9 +16,9 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -16,9 +16,9 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -55,7 +55,7 @@ List<TableRow> buildTable(
height: Theme.of(context).tableCell.fontSize),
Container(
margin: const EdgeInsets.all(5),
child: Text('${color.toHex()}', style: Theme.of(context).tableCell)),
child: Text(color.toHex(), style: Theme.of(context).tableCell)),
];
rows.add(TableRow(children: tableRow));
}
... ...
... ... @@ -220,7 +220,7 @@ void main() {
for (var word in para.split(' ')) {
spans.add(
TextSpan(
text: '$word',
text: word,
style: TextStyle(
font: ttf,
fontSize: rnd.nextDouble() * 20 + 20,
... ...
... ... @@ -17,9 +17,9 @@
import 'dart:io';
import 'dart:math' as math;
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -8,6 +8,7 @@
- Fix pdfium memory leak
- Fix error while loading shared libraries on Linux
- Update pdfium library to 4627
- Apply Flutter 2.5 coding style
## 5.5.0
... ...
include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
... ... @@ -6,8 +6,10 @@ analyzer:
errors:
missing_required_param: warning
missing_return: warning
public_member_api_docs: warning
public_member_api_docs: ignore
todo: ignore
constant_identifier_names: ignore
avoid_print: ignore
linter:
rules:
... ... @@ -15,52 +17,24 @@ linter:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_renaming_method_parameters
- avoid_returning_null_for_void
- avoid_slow_async_io
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- control_flow_in_finally
- directives_ordering
- empty_statements
- flutter_style_todos
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- non_constant_identifier_names
- omit_local_variable_types
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_final_locals
- prefer_foreach
- prefer_if_elements_to_conditional_expressions
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- prefer_single_quotes
- public_member_api_docs
- sort_constructors_first
- sort_pub_dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_null_aware_assignments
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- use_full_hex_values_for_flutter_colors
... ...
... ... @@ -152,7 +152,11 @@ class PrintingPlugin extends PrintingPlatform {
stopWatch.stop();
completer.complete(true);
} catch (e) {
print(e);
assert(() {
// ignore: avoid_print
print('Error: $e');
return true;
}());
completer.complete(_getPdf(result));
}
});
... ...
... ... @@ -50,7 +50,7 @@ Future<ImageProvider> flutterImageProvider(
stream.removeListener(listener);
}, onError: (dynamic exception, StackTrace? stackTrace) {
if (!completer.isCompleted) {
completer.complete(null);
completer.completeError('image failed to load');
}
if (onError != null) {
onError(exception, stackTrace);
... ...
... ... @@ -68,7 +68,12 @@ class DownloadbleFont {
protect: protect,
);
} catch (e) {
assert(() {
// ignore: avoid_print
print('$e\nError loading $name, fallback to Helvetica.');
return true;
}());
return Font.helvetica();
}
}
... ...
... ... @@ -42,7 +42,12 @@ mixin AssetManifest {
final jsonData = json.decode(jsonString) as Map<String, dynamic>;
_assets.addAll(jsonData.keys);
} catch (e) {
assert(() {
// ignore: avoid_print
print('Error loading AssetManifest.json $e');
return true;
}());
rootBundle.evict('AssetManifest.json');
_failed = true;
_ready = true;
... ...
... ... @@ -152,7 +152,12 @@ class MethodChannelPrinting extends PrintingPlatform {
<String, dynamic>{},
);
} catch (e) {
assert(() {
// ignore: avoid_print
print('Error getting printing info: $e');
return true;
}());
return PrintingInfo.unavailable;
}
... ...
... ... @@ -24,6 +24,7 @@ import 'dart:typed_data';
import 'package:js/js.dart';
// ignore: avoid_classes_with_only_static_members
@JS('pdfjsLib')
class PdfJs {
external static PdfJsDocLoader getDocument(Settings data);
... ...
name: printing
author: David PHAM-VAN <dev.nfet.net@gmail.com>
description: >
Plugin that allows Flutter apps to generate and print documents to
compatible printers on Android, iOS, macOS, Windows, and Linux,
... ... @@ -27,6 +26,7 @@ dependencies:
plugin_platform_interface: ^2.0.0
dev_dependencies:
flutter_lints: ^1.0.4
flutter_test:
sdk: flutter
mockito: ^5.0.0
... ...
... ... @@ -32,6 +32,7 @@ void main() {
setUp(() {
channel.setMockMethodCallHandler((MethodCall methodCall) async {
// ignore: avoid_print
print(methodCall);
return '1';
});
... ...
name: readme_to_dart
author: David PHAM-VAN <dev.nfet.net@gmail.com>
description: Readme Markdown to dart source converter.
homepage: https://github.com/DavBfr/dart_pdf/tree/master/test
repository: https://github.com/DavBfr/dart_pdf
... ...