Showing
42 changed files
with
175 additions
and
167 deletions
1 | -include: package:pedantic/analysis_options.yaml | 1 | +include: package:flutter_lints/flutter.yaml |
2 | + | ||
3 | +analyzer: | ||
4 | + strong-mode: | ||
5 | + implicit-dynamic: false | ||
6 | + errors: | ||
7 | + missing_required_param: warning | ||
8 | + missing_return: warning | ||
9 | + public_member_api_docs: ignore | ||
10 | + todo: ignore | ||
11 | + constant_identifier_names: ignore | ||
12 | + avoid_print: ignore | ||
13 | + | ||
14 | +linter: | ||
15 | + rules: | ||
16 | + - always_put_control_body_on_new_line | ||
17 | + - avoid_bool_literals_in_conditional_expressions | ||
18 | + - avoid_classes_with_only_static_members | ||
19 | + - avoid_field_initializers_in_const_classes | ||
20 | + - avoid_slow_async_io | ||
21 | + - avoid_unused_constructor_parameters | ||
22 | + - avoid_void_async | ||
23 | + - cancel_subscriptions | ||
24 | + - directives_ordering | ||
25 | + - flutter_style_todos | ||
26 | + - no_adjacent_strings_in_list | ||
27 | + - omit_local_variable_types | ||
28 | + - package_api_docs | ||
29 | + - prefer_asserts_in_initializer_lists | ||
30 | + - prefer_final_locals | ||
31 | + - prefer_foreach | ||
32 | + - prefer_if_elements_to_conditional_expressions | ||
33 | + - prefer_single_quotes | ||
34 | + - public_member_api_docs | ||
35 | + - sort_constructors_first | ||
36 | + - sort_pub_dependencies | ||
37 | + - sort_unnamed_constructors_first | ||
38 | + - test_types_in_equals | ||
39 | + - throw_in_finally | ||
40 | + - unnecessary_statements |
@@ -30,6 +30,8 @@ import 'data.dart'; | @@ -30,6 +30,8 @@ import 'data.dart'; | ||
30 | import 'examples.dart'; | 30 | import 'examples.dart'; |
31 | 31 | ||
32 | class MyApp extends StatefulWidget { | 32 | class MyApp extends StatefulWidget { |
33 | + const MyApp({Key? key}) : super(key: key); | ||
34 | + | ||
33 | @override | 35 | @override |
34 | MyAppState createState() { | 36 | MyAppState createState() { |
35 | return MyAppState(); | 37 | return MyAppState(); |
@@ -42,7 +44,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { | @@ -42,7 +44,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { | ||
42 | 44 | ||
43 | PrintingInfo? printingInfo; | 45 | PrintingInfo? printingInfo; |
44 | 46 | ||
45 | - var _data = CustomData(); | 47 | + var _data = const CustomData(); |
46 | var _hasData = false; | 48 | var _hasData = false; |
47 | var _pending = false; | 49 | var _pending = false; |
48 | 50 | ||
@@ -175,10 +177,10 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { | @@ -175,10 +177,10 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { | ||
175 | final controller = TextEditingController(); | 177 | final controller = TextEditingController(); |
176 | 178 | ||
177 | return AlertDialog( | 179 | return AlertDialog( |
178 | - title: Text('Please type your name:'), | ||
179 | - contentPadding: EdgeInsets.symmetric(horizontal: 20), | 180 | + title: const Text('Please type your name:'), |
181 | + contentPadding: const EdgeInsets.symmetric(horizontal: 20), | ||
180 | content: TextField( | 182 | content: TextField( |
181 | - decoration: InputDecoration(hintText: '[your name]'), | 183 | + decoration: const InputDecoration(hintText: '[your name]'), |
182 | controller: controller, | 184 | controller: controller, |
183 | ), | 185 | ), |
184 | actions: [ | 186 | actions: [ |
@@ -188,7 +190,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { | @@ -188,7 +190,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { | ||
188 | Navigator.pop(context, controller.text); | 190 | Navigator.pop(context, controller.text); |
189 | } | 191 | } |
190 | }, | 192 | }, |
191 | - child: Text('OK'), | 193 | + child: const Text('OK'), |
192 | ), | 194 | ), |
193 | ], | 195 | ], |
194 | ); | 196 | ); |
@@ -53,7 +53,7 @@ Future<Uint8List> generateCertificate( | @@ -53,7 +53,7 @@ Future<Uint8List> generateCertificate( | ||
53 | fontSize: 25, | 53 | fontSize: 25, |
54 | ), | 54 | ), |
55 | children: [ | 55 | children: [ |
56 | - pw.TextSpan(text: 'CERTIFICATE '), | 56 | + const pw.TextSpan(text: 'CERTIFICATE '), |
57 | pw.TextSpan( | 57 | pw.TextSpan( |
58 | text: 'of', | 58 | text: 'of', |
59 | style: pw.TextStyle( | 59 | style: pw.TextStyle( |
@@ -61,7 +61,7 @@ Future<Uint8List> generateCertificate( | @@ -61,7 +61,7 @@ Future<Uint8List> generateCertificate( | ||
61 | fontWeight: pw.FontWeight.normal, | 61 | fontWeight: pw.FontWeight.normal, |
62 | ), | 62 | ), |
63 | ), | 63 | ), |
64 | - pw.TextSpan(text: ' ACHIEVEMENT'), | 64 | + const pw.TextSpan(text: ' ACHIEVEMENT'), |
65 | ]), | 65 | ]), |
66 | ), | 66 | ), |
67 | pw.Spacer(), | 67 | pw.Spacer(), |
@@ -108,10 +108,10 @@ Future<Uint8List> generateCertificate( | @@ -108,10 +108,10 @@ Future<Uint8List> generateCertificate( | ||
108 | height: 10, | 108 | height: 10, |
109 | ), | 109 | ), |
110 | pw.Padding( | 110 | pw.Padding( |
111 | - padding: pw.EdgeInsets.symmetric(horizontal: 10), | 111 | + padding: const pw.EdgeInsets.symmetric(horizontal: 10), |
112 | child: pw.Text( | 112 | child: pw.Text( |
113 | 'Flutter PDF Demo', | 113 | 'Flutter PDF Demo', |
114 | - style: pw.TextStyle( | 114 | + style: const pw.TextStyle( |
115 | fontSize: 10, | 115 | fontSize: 10, |
116 | ), | 116 | ), |
117 | ), | 117 | ), |
@@ -138,7 +138,7 @@ Future<Uint8List> generateCertificate( | @@ -138,7 +138,7 @@ Future<Uint8List> generateCertificate( | ||
138 | pw.Flexible( | 138 | pw.Flexible( |
139 | child: pw.Text( | 139 | child: pw.Text( |
140 | lorem.paragraph(40), | 140 | lorem.paragraph(40), |
141 | - style: pw.TextStyle(fontSize: 6), | 141 | + style: const pw.TextStyle(fontSize: 6), |
142 | textAlign: pw.TextAlign.justify, | 142 | textAlign: pw.TextAlign.justify, |
143 | ), | 143 | ), |
144 | ), | 144 | ), |
@@ -161,16 +161,16 @@ Future<Uint8List> generateCertificate( | @@ -161,16 +161,16 @@ Future<Uint8List> generateCertificate( | ||
161 | buildBackground: (context) => pw.FullPage( | 161 | buildBackground: (context) => pw.FullPage( |
162 | ignoreMargins: true, | 162 | ignoreMargins: true, |
163 | child: pw.Container( | 163 | child: pw.Container( |
164 | - margin: pw.EdgeInsets.all(10), | 164 | + margin: const pw.EdgeInsets.all(10), |
165 | decoration: pw.BoxDecoration( | 165 | decoration: pw.BoxDecoration( |
166 | - border: | ||
167 | - pw.Border.all(color: PdfColor.fromInt(0xffe435), width: 1), | 166 | + border: pw.Border.all( |
167 | + color: const PdfColor.fromInt(0xffe435), width: 1), | ||
168 | ), | 168 | ), |
169 | child: pw.Container( | 169 | child: pw.Container( |
170 | - margin: pw.EdgeInsets.all(5), | 170 | + margin: const pw.EdgeInsets.all(5), |
171 | decoration: pw.BoxDecoration( | 171 | decoration: pw.BoxDecoration( |
172 | - border: | ||
173 | - pw.Border.all(color: PdfColor.fromInt(0xffe435), width: 5), | 172 | + border: pw.Border.all( |
173 | + color: const PdfColor.fromInt(0xffe435), width: 5), | ||
174 | ), | 174 | ), |
175 | width: double.infinity, | 175 | width: double.infinity, |
176 | height: double.infinity, | 176 | height: double.infinity, |
@@ -240,7 +240,7 @@ Future<Uint8List> generateCertificate( | @@ -240,7 +240,7 @@ Future<Uint8List> generateCertificate( | ||
240 | ), | 240 | ), |
241 | ), | 241 | ), |
242 | pw.Padding( | 242 | pw.Padding( |
243 | - padding: pw.EdgeInsets.only( | 243 | + padding: const pw.EdgeInsets.only( |
244 | top: 120, | 244 | top: 120, |
245 | left: 80, | 245 | left: 80, |
246 | right: 80, | 246 | right: 80, |
@@ -51,7 +51,7 @@ Future<Uint8List> generateDocument( | @@ -51,7 +51,7 @@ Future<Uint8List> generateDocument( | ||
51 | ), | 51 | ), |
52 | build: (context) { | 52 | build: (context) { |
53 | return pw.Padding( | 53 | return pw.Padding( |
54 | - padding: pw.EdgeInsets.only( | 54 | + padding: const pw.EdgeInsets.only( |
55 | left: 60, | 55 | left: 60, |
56 | right: 60, | 56 | right: 60, |
57 | bottom: 30, | 57 | bottom: 30, |
@@ -90,7 +90,7 @@ Future<Uint8List> generateDocument( | @@ -90,7 +90,7 @@ Future<Uint8List> generateDocument( | ||
90 | destination: 'https://wikipedia.org/wiki/PDF', | 90 | destination: 'https://wikipedia.org/wiki/PDF', |
91 | child: pw.Text( | 91 | child: pw.Text( |
92 | 'https://wikipedia.org/wiki/PDF', | 92 | 'https://wikipedia.org/wiki/PDF', |
93 | - style: pw.TextStyle( | 93 | + style: const pw.TextStyle( |
94 | color: PdfColors.pink100, | 94 | color: PdfColors.pink100, |
95 | ), | 95 | ), |
96 | ), | 96 | ), |
@@ -288,7 +288,7 @@ Future<Uint8List> generateReport( | @@ -288,7 +288,7 @@ Future<Uint8List> generateReport( | ||
288 | legend: '${data[0]}\n$pct%', | 288 | legend: '${data[0]}\n$pct%', |
289 | value: value, | 289 | value: value, |
290 | color: color, | 290 | color: color, |
291 | - legendStyle: pw.TextStyle(fontSize: 10), | 291 | + legendStyle: const pw.TextStyle(fontSize: 10), |
292 | ); | 292 | ); |
293 | }), | 293 | }), |
294 | ), | 294 | ), |
@@ -19,10 +19,12 @@ import 'package:flutter/material.dart'; | @@ -19,10 +19,12 @@ import 'package:flutter/material.dart'; | ||
19 | import 'app.dart'; | 19 | import 'app.dart'; |
20 | 20 | ||
21 | void main() { | 21 | void main() { |
22 | - runApp(App()); | 22 | + runApp(const App()); |
23 | } | 23 | } |
24 | 24 | ||
25 | class App extends StatelessWidget { | 25 | class App extends StatelessWidget { |
26 | + const App({Key? key}) : super(key: key); | ||
27 | + | ||
26 | @override | 28 | @override |
27 | Widget build(BuildContext context) { | 29 | Widget build(BuildContext context) { |
28 | const scrollbarTheme = | 30 | const scrollbarTheme = |
@@ -32,7 +34,7 @@ class App extends StatelessWidget { | @@ -32,7 +34,7 @@ class App extends StatelessWidget { | ||
32 | theme: ThemeData.light().copyWith(scrollbarTheme: scrollbarTheme), | 34 | theme: ThemeData.light().copyWith(scrollbarTheme: scrollbarTheme), |
33 | darkTheme: ThemeData.dark().copyWith(scrollbarTheme: scrollbarTheme), | 35 | darkTheme: ThemeData.dark().copyWith(scrollbarTheme: scrollbarTheme), |
34 | title: 'Flutter PDF Demo', | 36 | title: 'Flutter PDF Demo', |
35 | - home: MyApp(), | 37 | + home: const MyApp(), |
36 | ); | 38 | ); |
37 | } | 39 | } |
38 | } | 40 | } |
@@ -7,7 +7,7 @@ import 'package:printing_demo/examples/document.dart'; | @@ -7,7 +7,7 @@ import 'package:printing_demo/examples/document.dart'; | ||
7 | 7 | ||
8 | void main() { | 8 | void main() { |
9 | testWidgets('Pdf Generate the document', (WidgetTester tester) async { | 9 | testWidgets('Pdf Generate the document', (WidgetTester tester) async { |
10 | - final data = CustomData(); | 10 | + const data = CustomData(); |
11 | final doc = await generateDocument(PdfPageFormat.a4, data); | 11 | final doc = await generateDocument(PdfPageFormat.a4, data); |
12 | 12 | ||
13 | final file = File('document.pdf'); | 13 | final file = File('document.pdf'); |
1 | -include: package:pedantic/analysis_options.yaml | 1 | +include: package:flutter_lints/flutter.yaml |
2 | 2 | ||
3 | analyzer: | 3 | analyzer: |
4 | strong-mode: | 4 | strong-mode: |
@@ -8,6 +8,8 @@ analyzer: | @@ -8,6 +8,8 @@ analyzer: | ||
8 | missing_return: warning | 8 | missing_return: warning |
9 | public_member_api_docs: ignore | 9 | public_member_api_docs: ignore |
10 | todo: ignore | 10 | todo: ignore |
11 | + constant_identifier_names: ignore | ||
12 | + avoid_print: ignore | ||
11 | 13 | ||
12 | linter: | 14 | linter: |
13 | rules: | 15 | rules: |
@@ -15,52 +17,24 @@ linter: | @@ -15,52 +17,24 @@ linter: | ||
15 | - avoid_bool_literals_in_conditional_expressions | 17 | - avoid_bool_literals_in_conditional_expressions |
16 | - avoid_classes_with_only_static_members | 18 | - avoid_classes_with_only_static_members |
17 | - avoid_field_initializers_in_const_classes | 19 | - avoid_field_initializers_in_const_classes |
18 | - - avoid_function_literals_in_foreach_calls | ||
19 | - - avoid_renaming_method_parameters | ||
20 | - - avoid_returning_null_for_void | ||
21 | - avoid_slow_async_io | 20 | - avoid_slow_async_io |
22 | - avoid_unused_constructor_parameters | 21 | - avoid_unused_constructor_parameters |
23 | - avoid_void_async | 22 | - avoid_void_async |
24 | - - await_only_futures | ||
25 | - - camel_case_types | ||
26 | - cancel_subscriptions | 23 | - cancel_subscriptions |
27 | - - control_flow_in_finally | ||
28 | - directives_ordering | 24 | - directives_ordering |
29 | - - empty_statements | ||
30 | - flutter_style_todos | 25 | - flutter_style_todos |
31 | - - hash_and_equals | ||
32 | - - implementation_imports | ||
33 | - - iterable_contains_unrelated_type | ||
34 | - - list_remove_unrelated_type | ||
35 | - no_adjacent_strings_in_list | 26 | - no_adjacent_strings_in_list |
36 | - - non_constant_identifier_names | ||
37 | - omit_local_variable_types | 27 | - omit_local_variable_types |
38 | - - overridden_fields | ||
39 | - package_api_docs | 28 | - package_api_docs |
40 | - - package_names | ||
41 | - - package_prefixed_library_names | ||
42 | - prefer_asserts_in_initializer_lists | 29 | - prefer_asserts_in_initializer_lists |
43 | - - prefer_const_constructors | ||
44 | - - prefer_const_constructors_in_immutables | ||
45 | - - prefer_const_declarations | ||
46 | - - prefer_const_literals_to_create_immutables | ||
47 | - prefer_final_locals | 30 | - prefer_final_locals |
48 | - prefer_foreach | 31 | - prefer_foreach |
49 | - prefer_if_elements_to_conditional_expressions | 32 | - prefer_if_elements_to_conditional_expressions |
50 | - - prefer_initializing_formals | ||
51 | - - prefer_inlined_adds | ||
52 | - - prefer_typing_uninitialized_variables | ||
53 | - - prefer_void_to_null | 33 | + - prefer_single_quotes |
54 | - public_member_api_docs | 34 | - public_member_api_docs |
55 | - sort_constructors_first | 35 | - sort_constructors_first |
56 | - sort_pub_dependencies | 36 | - sort_pub_dependencies |
57 | - sort_unnamed_constructors_first | 37 | - sort_unnamed_constructors_first |
58 | - test_types_in_equals | 38 | - test_types_in_equals |
59 | - throw_in_finally | 39 | - throw_in_finally |
60 | - - unnecessary_brace_in_string_interps | ||
61 | - - unnecessary_getters_setters | ||
62 | - - unnecessary_null_aware_assignments | ||
63 | - - unnecessary_overrides | ||
64 | - - unnecessary_parenthesis | ||
65 | - unnecessary_statements | 40 | - unnecessary_statements |
66 | - - use_full_hex_values_for_flutter_colors |
@@ -15,7 +15,6 @@ | @@ -15,7 +15,6 @@ | ||
15 | */ | 15 | */ |
16 | 16 | ||
17 | export 'src/pdf/annotation.dart'; | 17 | export 'src/pdf/annotation.dart'; |
18 | -export 'src/pdf/arabic.dart'; | ||
19 | export 'src/pdf/border.dart'; | 18 | export 'src/pdf/border.dart'; |
20 | export 'src/pdf/color.dart'; | 19 | export 'src/pdf/color.dart'; |
21 | export 'src/pdf/colors.dart'; | 20 | export 'src/pdf/colors.dart'; |
@@ -14,11 +14,9 @@ | @@ -14,11 +14,9 @@ | ||
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -/// Arabic shape substitutions functions | ||
18 | -class PdfArabic { | ||
19 | - /// Arabic shape substitutions: char code => (isolated, final, initial, medial). | ||
20 | - /// Arabic Substition A | ||
21 | - static const Map<int, dynamic> _arabicSubstitionA = <int, dynamic>{ | 17 | +/// Arabic shape substitutions: char code => (isolated, final, initial, medial). |
18 | +/// Arabic Substition A | ||
19 | +const Map<int, dynamic> _arabicSubstitionA = <int, dynamic>{ | ||
22 | 0x0640: <int>[0x0640, 0x0640, 0x0640, 0x0640], // ARABIC TATWEEL | 20 | 0x0640: <int>[0x0640, 0x0640, 0x0640, 0x0640], // ARABIC TATWEEL |
23 | 21 | ||
24 | 0x0621: <int>[0xFE80], // ARABIC LETTER HAMZA | 22 | 0x0621: <int>[0xFE80], // ARABIC LETTER HAMZA |
@@ -107,15 +105,15 @@ class PdfArabic { | @@ -107,15 +105,15 @@ class PdfArabic { | ||
107 | 0x06D0: <int>[0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7], //ARABIC LETTER E | 105 | 0x06D0: <int>[0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7], //ARABIC LETTER E |
108 | 0x06D2: <int>[0xFBAE, 0xFBAF], // ARABIC LETTER YEH BARREE | 106 | 0x06D2: <int>[0xFBAE, 0xFBAF], // ARABIC LETTER YEH BARREE |
109 | 0x06D3: <int>[0xFBB0, 0xFBB1], // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE | 107 | 0x06D3: <int>[0xFBB0, 0xFBB1], // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE |
110 | - }; | 108 | +}; |
111 | 109 | ||
112 | - /* | 110 | +/* |
113 | var ligaturesSubstitutionA = { | 111 | var ligaturesSubstitutionA = { |
114 | 0xFBEA: []// ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF ISOLATED FORM | 112 | 0xFBEA: []// ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF ISOLATED FORM |
115 | }; | 113 | }; |
116 | */ | 114 | */ |
117 | 115 | ||
118 | - static const Map<int, dynamic> _diacriticLigatures = <int, dynamic>{ | 116 | +const Map<int, dynamic> _diacriticLigatures = <int, dynamic>{ |
119 | 0x0651: <int, int>{ | 117 | 0x0651: <int, int>{ |
120 | 0x064C: 0xFC5E, // Shadda + Dammatan | 118 | 0x064C: 0xFC5E, // Shadda + Dammatan |
121 | 0x064D: 0xFC5F, // Shadda + Kasratan | 119 | 0x064D: 0xFC5F, // Shadda + Kasratan |
@@ -124,9 +122,9 @@ class PdfArabic { | @@ -124,9 +122,9 @@ class PdfArabic { | ||
124 | 0x0650: 0xFC62, // Shadda + Kasra | 122 | 0x0650: 0xFC62, // Shadda + Kasra |
125 | 0x0670: 0xFC63, // Shadda + Dagger alif | 123 | 0x0670: 0xFC63, // Shadda + Dagger alif |
126 | }, | 124 | }, |
127 | - }; | 125 | +}; |
128 | 126 | ||
129 | - static const Map<int, dynamic> _ligatures = <int, dynamic>{ | 127 | +const Map<int, dynamic> _ligatures = <int, dynamic>{ |
130 | 0xFEDF: <int, int>{ | 128 | 0xFEDF: <int, int>{ |
131 | 0xFE82: | 129 | 0xFE82: |
132 | 0xFEF5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM | 130 | 0xFEF5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM |
@@ -137,12 +135,9 @@ class PdfArabic { | @@ -137,12 +135,9 @@ class PdfArabic { | ||
137 | 0xFE8E: 0xFEFB // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM | 135 | 0xFE8E: 0xFEFB // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM |
138 | }, | 136 | }, |
139 | 0xFEE0: <int, int>{ | 137 | 0xFEE0: <int, int>{ |
140 | - 0xFE82: | ||
141 | - 0xFEF6, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM | ||
142 | - 0xFE84: | ||
143 | - 0xFEF8, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM | ||
144 | - 0xFE88: | ||
145 | - 0xFEFA, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM | 138 | + 0xFE82: 0xFEF6, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM |
139 | + 0xFE84: 0xFEF8, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM | ||
140 | + 0xFE88: 0xFEFA, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM | ||
146 | 0xFE8E: 0xFEFC // ARABIC LIGATURE LAM WITH ALEF FINAL FORM | 141 | 0xFE8E: 0xFEFC // ARABIC LIGATURE LAM WITH ALEF FINAL FORM |
147 | }, | 142 | }, |
148 | // 0xFE8D: <int, dynamic>{ | 143 | // 0xFE8D: <int, dynamic>{ |
@@ -150,11 +145,11 @@ class PdfArabic { | @@ -150,11 +145,11 @@ class PdfArabic { | ||
150 | // 0xFEE0: <int, int>{0xFEEA: 0xFDF2} | 145 | // 0xFEE0: <int, int>{0xFEEA: 0xFDF2} |
151 | // } | 146 | // } |
152 | // }, // ALLAH | 147 | // }, // ALLAH |
153 | - }; | 148 | +}; |
154 | 149 | ||
155 | - static const List<int> _alfletter = <int>[1570, 1571, 1573, 1575]; | 150 | +const List<int> _alfletter = <int>[1570, 1571, 1573, 1575]; |
156 | 151 | ||
157 | - static const Map<int, int> _arabicDiacritics = <int, int>{ | 152 | +const Map<int, int> _arabicDiacritics = <int, int>{ |
158 | 0x064B: 0x064B, // Fathatan | 153 | 0x064B: 0x064B, // Fathatan |
159 | 0x064C: 0x064C, // Dammatan | 154 | 0x064C: 0x064C, // Dammatan |
160 | 0x064D: 0x064D, // Kasratan | 155 | 0x064D: 0x064D, // Kasratan |
@@ -173,56 +168,56 @@ class PdfArabic { | @@ -173,56 +168,56 @@ class PdfArabic { | ||
173 | 0xFC62: 0xFC62, // Shadda + Kasra | 168 | 0xFC62: 0xFC62, // Shadda + Kasra |
174 | 0xFC63: 0xFC63, // Shadda + Dagger alif | 169 | 0xFC63: 0xFC63, // Shadda + Dagger alif |
175 | // 1548: 1548, | 170 | // 1548: 1548, |
176 | - }; | 171 | +}; |
177 | 172 | ||
178 | - static const int _noChangeInForm = -1; | ||
179 | - static const int _isolatedForm = 0; | ||
180 | - static const int _finalForm = 1; | ||
181 | - static const int _initialForm = 2; | ||
182 | - static const int _medialForm = 3; | 173 | +const int _noChangeInForm = -1; |
174 | +const int _isolatedForm = 0; | ||
175 | +const int _finalForm = 1; | ||
176 | +const int _initialForm = 2; | ||
177 | +const int _medialForm = 3; | ||
183 | 178 | ||
184 | - static bool _isInArabicSubstitutionA(int letter) { | 179 | +bool _isInArabicSubstitutionA(int letter) { |
185 | return _arabicSubstitionA.containsKey(letter); | 180 | return _arabicSubstitionA.containsKey(letter); |
186 | - } | 181 | +} |
187 | 182 | ||
188 | - static bool _isArabicLetter(int letter) { | 183 | +bool _isArabicLetter(int letter) { |
189 | return (letter >= 0x0600 && letter <= 0x06FF) || | 184 | return (letter >= 0x0600 && letter <= 0x06FF) || |
190 | (letter >= 0x0750 && letter <= 0x077F) || | 185 | (letter >= 0x0750 && letter <= 0x077F) || |
191 | (letter >= 0x08FF && letter <= 0xFB50) || | 186 | (letter >= 0x08FF && letter <= 0xFB50) || |
192 | (letter >= 0xFDFF && letter <= 0xFEFF); | 187 | (letter >= 0xFDFF && letter <= 0xFEFF); |
193 | - } | 188 | +} |
194 | 189 | ||
195 | - static bool _isArabicEndLetter(int letter) { | 190 | +bool _isArabicEndLetter(int letter) { |
196 | return _isArabicLetter(letter) && | 191 | return _isArabicLetter(letter) && |
197 | _isInArabicSubstitutionA(letter) && | 192 | _isInArabicSubstitutionA(letter) && |
198 | _arabicSubstitionA[letter].length <= 2; | 193 | _arabicSubstitionA[letter].length <= 2; |
199 | - } | 194 | +} |
200 | 195 | ||
201 | - static bool _isArabicAlfLetter(int letter) { | 196 | +bool _isArabicAlfLetter(int letter) { |
202 | return _isArabicLetter(letter) && _alfletter.contains(letter); | 197 | return _isArabicLetter(letter) && _alfletter.contains(letter); |
203 | - } | 198 | +} |
204 | 199 | ||
205 | - static bool _arabicLetterHasFinalForm(int letter) { | 200 | +bool _arabicLetterHasFinalForm(int letter) { |
206 | return _isArabicLetter(letter) && | 201 | return _isArabicLetter(letter) && |
207 | _isInArabicSubstitutionA(letter) && | 202 | _isInArabicSubstitutionA(letter) && |
208 | (_arabicSubstitionA[letter].length >= 2); | 203 | (_arabicSubstitionA[letter].length >= 2); |
209 | - } | 204 | +} |
210 | 205 | ||
211 | - static bool _arabicLetterHasMedialForm(int letter) { | 206 | +bool _arabicLetterHasMedialForm(int letter) { |
212 | return _isArabicLetter(letter) && | 207 | return _isArabicLetter(letter) && |
213 | _isInArabicSubstitutionA(letter) && | 208 | _isInArabicSubstitutionA(letter) && |
214 | _arabicSubstitionA[letter].length == 4; | 209 | _arabicSubstitionA[letter].length == 4; |
215 | - } | 210 | +} |
216 | 211 | ||
217 | - static bool _isArabicDiacritic(int letter) { | 212 | +bool _isArabicDiacritic(int letter) { |
218 | return _arabicDiacritics.containsKey(letter); | 213 | return _arabicDiacritics.containsKey(letter); |
219 | - } | 214 | +} |
220 | 215 | ||
221 | - static bool isArabicDiacriticValue(int letter) { | 216 | +bool isArabicDiacriticValue(int letter) { |
222 | return _arabicDiacritics.containsValue(letter); | 217 | return _arabicDiacritics.containsValue(letter); |
223 | - } | 218 | +} |
224 | 219 | ||
225 | - static List<int> _resolveLigatures(List<int> lettersq) { | 220 | +List<int> _resolveLigatures(List<int> lettersq) { |
226 | final result = <int>[]; | 221 | final result = <int>[]; |
227 | dynamic tmpLigatures = _ligatures; | 222 | dynamic tmpLigatures = _ligatures; |
228 | dynamic tmpDiacritic = _diacriticLigatures; | 223 | dynamic tmpDiacritic = _diacriticLigatures; |
@@ -290,9 +285,9 @@ class PdfArabic { | @@ -290,9 +285,9 @@ class PdfArabic { | ||
290 | } | 285 | } |
291 | 286 | ||
292 | return result; | 287 | return result; |
293 | - } | 288 | +} |
294 | 289 | ||
295 | - static int _getCorrectForm(int currentChar, int beforeChar, int nextChar) { | 290 | +int _getCorrectForm(int currentChar, int beforeChar, int nextChar) { |
296 | if (_isInArabicSubstitutionA(currentChar) == false) { | 291 | if (_isInArabicSubstitutionA(currentChar) == false) { |
297 | return _noChangeInForm; | 292 | return _noChangeInForm; |
298 | } | 293 | } |
@@ -317,9 +312,9 @@ class PdfArabic { | @@ -317,9 +312,9 @@ class PdfArabic { | ||
317 | return _finalForm; | 312 | return _finalForm; |
318 | } | 313 | } |
319 | return _initialForm; | 314 | return _initialForm; |
320 | - } | 315 | +} |
321 | 316 | ||
322 | - static Iterable<String> _parse(String text) sync* { | 317 | +Iterable<String> _parse(String text) sync* { |
323 | final words = text.split(' '); | 318 | final words = text.split(' '); |
324 | 319 | ||
325 | final notArabicWords = <List<int>>[]; | 320 | final notArabicWords = <List<int>>[]; |
@@ -350,8 +345,7 @@ class PdfArabic { | @@ -350,8 +345,7 @@ class PdfArabic { | ||
350 | if (_isArabicLetter(currentLetter)) { | 345 | if (_isArabicLetter(currentLetter)) { |
351 | isNewWordArabic = true; | 346 | isNewWordArabic = true; |
352 | 347 | ||
353 | - final position = | ||
354 | - _getCorrectForm(currentLetter, prevLetter, nextLetter); | 348 | + final position = _getCorrectForm(currentLetter, prevLetter, nextLetter); |
355 | prevLetter = currentLetter; | 349 | prevLetter = currentLetter; |
356 | if (position != -1) { | 350 | if (position != -1) { |
357 | newWord.insert(0, _arabicSubstitionA[currentLetter][position]); | 351 | newWord.insert(0, _arabicSubstitionA[currentLetter][position]); |
@@ -391,10 +385,9 @@ class PdfArabic { | @@ -391,10 +385,9 @@ class PdfArabic { | ||
391 | yield ' '; | 385 | yield ' '; |
392 | } | 386 | } |
393 | } | 387 | } |
394 | - } | 388 | +} |
395 | 389 | ||
396 | - /// Apply Arabic shape substitutions | ||
397 | - static String convert(String input) { | 390 | +/// Apply Arabic shape substitutions |
391 | +String convert(String input) { | ||
398 | return List<String>.from(_parse(input)).join(''); | 392 | return List<String>.from(_parse(input)).join(''); |
399 | - } | ||
400 | } | 393 | } |
@@ -49,7 +49,7 @@ class PdfCatalog extends PdfObjectDict { | @@ -49,7 +49,7 @@ class PdfCatalog extends PdfObjectDict { | ||
49 | final PdfNames names; | 49 | final PdfNames names; |
50 | 50 | ||
51 | /// These map the page modes just defined to the pagemodes setting of Pdf. | 51 | /// These map the page modes just defined to the pagemodes setting of Pdf. |
52 | - static const List<String> _PdfPageModes = <String>[ | 52 | + static const List<String> _pdfPageModes = <String>[ |
53 | '/UseNone', | 53 | '/UseNone', |
54 | '/UseOutlines', | 54 | '/UseOutlines', |
55 | '/UseThumbs', | 55 | '/UseThumbs', |
@@ -78,7 +78,7 @@ class PdfCatalog extends PdfObjectDict { | @@ -78,7 +78,7 @@ class PdfCatalog extends PdfObjectDict { | ||
78 | params['/Names'] = names.ref(); | 78 | params['/Names'] = names.ref(); |
79 | 79 | ||
80 | // the /PageMode setting | 80 | // the /PageMode setting |
81 | - params['/PageMode'] = PdfName(_PdfPageModes[pageMode.index]); | 81 | + params['/PageMode'] = PdfName(_pdfPageModes[pageMode.index]); |
82 | 82 | ||
83 | if (pdfDocument.sign != null) { | 83 | if (pdfDocument.sign != null) { |
84 | if (pdfDocument.sign!.value.hasMDP) { | 84 | if (pdfDocument.sign!.value.hasMDP) { |
@@ -199,10 +199,10 @@ class PdfString extends PdfDataType { | @@ -199,10 +199,10 @@ class PdfString extends PdfDataType { | ||
199 | 199 | ||
200 | final encoding = <int>[]; | 200 | final encoding = <int>[]; |
201 | 201 | ||
202 | - final add = (int unit) { | 202 | + void add(int unit) { |
203 | encoding.add((unit & UNICODE_BYTE_ONE_MASK) >> 8); | 203 | encoding.add((unit & UNICODE_BYTE_ONE_MASK) >> 8); |
204 | encoding.add(unit & UNICODE_BYTE_ZERO_MASK); | 204 | encoding.add(unit & UNICODE_BYTE_ZERO_MASK); |
205 | - }; | 205 | + } |
206 | 206 | ||
207 | for (var unit in str.codeUnits) { | 207 | for (var unit in str.codeUnits) { |
208 | if ((unit >= 0 && unit < UNICODE_UTF16_RESERVED_LO) || | 208 | if ((unit >= 0 && unit < UNICODE_UTF16_RESERVED_LO) || |
@@ -139,7 +139,7 @@ class PdfGraphicState { | @@ -139,7 +139,7 @@ class PdfGraphicState { | ||
139 | 139 | ||
140 | @override | 140 | @override |
141 | bool operator ==(dynamic other) { | 141 | bool operator ==(dynamic other) { |
142 | - if (!(other is PdfGraphicState)) { | 142 | + if (other is! PdfGraphicState) { |
143 | return false; | 143 | return false; |
144 | } | 144 | } |
145 | return other.fillOpacity == fillOpacity && | 145 | return other.fillOpacity == fillOpacity && |
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | import 'dart:convert'; | 17 | import 'dart:convert'; |
18 | import 'dart:typed_data'; | 18 | import 'dart:typed_data'; |
19 | 19 | ||
20 | -import 'arabic.dart'; | 20 | +import 'arabic.dart' as arabic; |
21 | import 'array.dart'; | 21 | import 'array.dart'; |
22 | import 'data_types.dart'; | 22 | import 'data_types.dart'; |
23 | import 'document.dart'; | 23 | import 'document.dart'; |
@@ -74,7 +74,7 @@ class PdfTtfFont extends PdfFont { | @@ -74,7 +74,7 @@ class PdfTtfFont extends PdfFont { | ||
74 | return PdfFontMetrics.zero; | 74 | return PdfFontMetrics.zero; |
75 | } | 75 | } |
76 | 76 | ||
77 | - if (PdfArabic.isArabicDiacriticValue(charCode)) { | 77 | + if (arabic.isArabicDiacriticValue(charCode)) { |
78 | final metric = font.glyphInfoMap[g] ?? PdfFontMetrics.zero; | 78 | final metric = font.glyphInfoMap[g] ?? PdfFontMetrics.zero; |
79 | return metric.copyWith(advanceWidth: 0); | 79 | return metric.copyWith(advanceWidth: 0); |
80 | } | 80 | } |
@@ -33,6 +33,7 @@ class PdfType1Font extends PdfFont { | @@ -33,6 +33,7 @@ class PdfType1Font extends PdfFont { | ||
33 | PdfType1Font.create(PdfDocument pdfDocument, this.fontName, this.ascent, | 33 | PdfType1Font.create(PdfDocument pdfDocument, this.fontName, this.ascent, |
34 | this.descent, this.widths) | 34 | this.descent, this.widths) |
35 | : assert(() { | 35 | : assert(() { |
36 | + // ignore: avoid_print | ||
36 | print( | 37 | print( |
37 | '$fontName has no Unicode support see https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management'); | 38 | '$fontName has no Unicode support see https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management'); |
38 | return true; | 39 | return true; |
@@ -101,5 +101,5 @@ class SvgTransform { | @@ -101,5 +101,5 @@ class SvgTransform { | ||
101 | static const none = SvgTransform(null); | 101 | static const none = SvgTransform(null); |
102 | 102 | ||
103 | static final _transformRegExp = | 103 | static final _transformRegExp = |
104 | - RegExp('(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)\s*'); | 104 | + RegExp(r'(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)\s*'); |
105 | } | 105 | } |
@@ -148,7 +148,7 @@ class Stack extends MultiChildWidget { | @@ -148,7 +148,7 @@ class Stack extends MultiChildWidget { | ||
148 | } | 148 | } |
149 | 149 | ||
150 | for (var child in children) { | 150 | for (var child in children) { |
151 | - if (!(child is Positioned)) { | 151 | + if (child is! Positioned) { |
152 | hasNonPositionedChildren = true; | 152 | hasNonPositionedChildren = true; |
153 | 153 | ||
154 | child.layout(context, nonPositionedConstraints, parentUsesSize: true); | 154 | child.layout(context, nonPositionedConstraints, parentUsesSize: true); |
@@ -169,7 +169,7 @@ class Stack extends MultiChildWidget { | @@ -169,7 +169,7 @@ class Stack extends MultiChildWidget { | ||
169 | } | 169 | } |
170 | 170 | ||
171 | for (var child in children) { | 171 | for (var child in children) { |
172 | - if (!(child is Positioned)) { | 172 | + if (child is! Positioned) { |
173 | child.box = PdfRect.fromPoints( | 173 | child.box = PdfRect.fromPoints( |
174 | alignment.inscribe(child.box!.size, box!).offset, child.box!.size); | 174 | alignment.inscribe(child.box!.size, box!).offset, child.box!.size); |
175 | } else { | 175 | } else { |
@@ -18,6 +18,7 @@ import 'dart:math' as math; | @@ -18,6 +18,7 @@ import 'dart:math' as math; | ||
18 | 18 | ||
19 | import 'package:meta/meta.dart'; | 19 | import 'package:meta/meta.dart'; |
20 | import 'package:pdf/pdf.dart'; | 20 | import 'package:pdf/pdf.dart'; |
21 | +import 'package:pdf/src/pdf/arabic.dart' as arabic; | ||
21 | 22 | ||
22 | import 'annotations.dart'; | 23 | import 'annotations.dart'; |
23 | import 'document.dart'; | 24 | import 'document.dart'; |
@@ -682,7 +683,7 @@ class RichText extends Widget with SpanningWidget { | @@ -682,7 +683,7 @@ class RichText extends Widget with SpanningWidget { | ||
682 | font.stringMetrics(' ') * (style.fontSize! * textScaleFactor); | 683 | font.stringMetrics(' ') * (style.fontSize! * textScaleFactor); |
683 | 684 | ||
684 | final spanLines = (_textDirection == TextDirection.rtl | 685 | final spanLines = (_textDirection == TextDirection.rtl |
685 | - ? PdfArabic.convert(span.text!) | 686 | + ? arabic.convert(span.text!) |
686 | : span.text)! | 687 | : span.text)! |
687 | .split('\n'); | 688 | .split('\n'); |
688 | 689 |
1 | name: pdf | 1 | name: pdf |
2 | -author: David PHAM-VAN <dev.nfet.net@gmail.com> | ||
3 | description: A pdf producer for Dart. It can create pdf files for both web or flutter. | 2 | description: A pdf producer for Dart. It can create pdf files for both web or flutter. |
4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf | 3 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf |
5 | repository: https://github.com/DavBfr/dart_pdf | 4 | repository: https://github.com/DavBfr/dart_pdf |
@@ -20,5 +19,5 @@ dependencies: | @@ -20,5 +19,5 @@ dependencies: | ||
20 | xml: ^5.1.0 | 19 | xml: ^5.1.0 |
21 | 20 | ||
22 | dev_dependencies: | 21 | dev_dependencies: |
23 | - pedantic: ^1.11.0 | 22 | + flutter_lints: ^1.0.4 |
24 | test: ^1.16.0 | 23 | test: ^1.16.0 |
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | 16 | ||
17 | import 'dart:io'; | 17 | import 'dart:io'; |
18 | 18 | ||
19 | -import 'package:pdf/pdf.dart'; | 19 | +import 'package:pdf/src/pdf/arabic.dart' as arabic; |
20 | import 'package:pdf/widgets.dart'; | 20 | import 'package:pdf/widgets.dart'; |
21 | import 'package:test/test.dart'; | 21 | import 'package:test/test.dart'; |
22 | 22 | ||
@@ -51,11 +51,11 @@ void main() { | @@ -51,11 +51,11 @@ void main() { | ||
51 | <int>[1612, 65249, 1618, 1614, 65276, 1614, 65204, 65247, 65165]); | 51 | <int>[1612, 65249, 1618, 1614, 65276, 1614, 65204, 65247, 65165]); |
52 | 52 | ||
53 | expect( | 53 | expect( |
54 | - PdfArabic.convert(a.original).codeUnits, | 54 | + arabic.convert(a.original).codeUnits, |
55 | equals(a.reshaped), | 55 | equals(a.reshaped), |
56 | ); | 56 | ); |
57 | expect( | 57 | expect( |
58 | - PdfArabic.convert(b.original).codeUnits, | 58 | + arabic.convert(b.original).codeUnits, |
59 | equals(b.reshaped), | 59 | equals(b.reshaped), |
60 | ); | 60 | ); |
61 | }); | 61 | }); |
@@ -453,7 +453,7 @@ void main() { | @@ -453,7 +453,7 @@ void main() { | ||
453 | for (var item in cases) { | 453 | for (var item in cases) { |
454 | try { | 454 | try { |
455 | expect( | 455 | expect( |
456 | - PdfArabic.convert(item.original).codeUnits, | 456 | + arabic.convert(item.original).codeUnits, |
457 | equals(item.reshaped), | 457 | equals(item.reshaped), |
458 | ); | 458 | ); |
459 | } catch (e) { | 459 | } catch (e) { |
@@ -105,7 +105,8 @@ class ColorWheel extends Widget { | @@ -105,7 +105,8 @@ class ColorWheel extends Widget { | ||
105 | large: false, sweep: true) | 105 | large: false, sweep: true) |
106 | ..lineTo(endBottom.x, endBottom.y) | 106 | ..lineTo(endBottom.x, endBottom.y) |
107 | ..bezierArc(endBottom.x, endBottom.y, radius2, radius2, startBottom.x, | 107 | ..bezierArc(endBottom.x, endBottom.y, radius2, radius2, startBottom.x, |
108 | - startBottom.y, large: false) | 108 | + startBottom.y, |
109 | + large: false) | ||
109 | ..lineTo(startTop.x, startTop.y) | 110 | ..lineTo(startTop.x, startTop.y) |
110 | ..fillPath() | 111 | ..fillPath() |
111 | ..moveTo(startTop.x, startTop.y) | 112 | ..moveTo(startTop.x, startTop.y) |
@@ -16,9 +16,9 @@ | @@ -16,9 +16,9 @@ | ||
16 | 16 | ||
17 | import 'dart:io'; | 17 | import 'dart:io'; |
18 | 18 | ||
19 | -import 'package:test/test.dart'; | ||
20 | import 'package:pdf/pdf.dart'; | 19 | import 'package:pdf/pdf.dart'; |
21 | import 'package:pdf/widgets.dart'; | 20 | import 'package:pdf/widgets.dart'; |
21 | +import 'package:test/test.dart'; | ||
22 | 22 | ||
23 | late Document pdf; | 23 | late Document pdf; |
24 | 24 |
@@ -16,9 +16,9 @@ | @@ -16,9 +16,9 @@ | ||
16 | 16 | ||
17 | import 'dart:io'; | 17 | import 'dart:io'; |
18 | 18 | ||
19 | -import 'package:test/test.dart'; | ||
20 | import 'package:pdf/pdf.dart'; | 19 | import 'package:pdf/pdf.dart'; |
21 | import 'package:pdf/widgets.dart'; | 20 | import 'package:pdf/widgets.dart'; |
21 | +import 'package:test/test.dart'; | ||
22 | 22 | ||
23 | late Document pdf; | 23 | late Document pdf; |
24 | 24 |
@@ -16,9 +16,9 @@ | @@ -16,9 +16,9 @@ | ||
16 | 16 | ||
17 | import 'dart:io'; | 17 | import 'dart:io'; |
18 | 18 | ||
19 | -import 'package:test/test.dart'; | ||
20 | import 'package:pdf/pdf.dart'; | 19 | import 'package:pdf/pdf.dart'; |
21 | import 'package:pdf/widgets.dart'; | 20 | import 'package:pdf/widgets.dart'; |
21 | +import 'package:test/test.dart'; | ||
22 | 22 | ||
23 | late Document pdf; | 23 | late Document pdf; |
24 | 24 |
@@ -16,9 +16,9 @@ | @@ -16,9 +16,9 @@ | ||
16 | 16 | ||
17 | import 'dart:io'; | 17 | import 'dart:io'; |
18 | 18 | ||
19 | -import 'package:test/test.dart'; | ||
20 | import 'package:pdf/pdf.dart'; | 19 | import 'package:pdf/pdf.dart'; |
21 | import 'package:pdf/widgets.dart'; | 20 | import 'package:pdf/widgets.dart'; |
21 | +import 'package:test/test.dart'; | ||
22 | 22 | ||
23 | late Document pdf; | 23 | late Document pdf; |
24 | 24 |
@@ -55,7 +55,7 @@ List<TableRow> buildTable( | @@ -55,7 +55,7 @@ List<TableRow> buildTable( | ||
55 | height: Theme.of(context).tableCell.fontSize), | 55 | height: Theme.of(context).tableCell.fontSize), |
56 | Container( | 56 | Container( |
57 | margin: const EdgeInsets.all(5), | 57 | margin: const EdgeInsets.all(5), |
58 | - child: Text('${color.toHex()}', style: Theme.of(context).tableCell)), | 58 | + child: Text(color.toHex(), style: Theme.of(context).tableCell)), |
59 | ]; | 59 | ]; |
60 | rows.add(TableRow(children: tableRow)); | 60 | rows.add(TableRow(children: tableRow)); |
61 | } | 61 | } |
@@ -220,7 +220,7 @@ void main() { | @@ -220,7 +220,7 @@ void main() { | ||
220 | for (var word in para.split(' ')) { | 220 | for (var word in para.split(' ')) { |
221 | spans.add( | 221 | spans.add( |
222 | TextSpan( | 222 | TextSpan( |
223 | - text: '$word', | 223 | + text: word, |
224 | style: TextStyle( | 224 | style: TextStyle( |
225 | font: ttf, | 225 | font: ttf, |
226 | fontSize: rnd.nextDouble() * 20 + 20, | 226 | fontSize: rnd.nextDouble() * 20 + 20, |
@@ -17,9 +17,9 @@ | @@ -17,9 +17,9 @@ | ||
17 | import 'dart:io'; | 17 | import 'dart:io'; |
18 | import 'dart:math' as math; | 18 | import 'dart:math' as math; |
19 | 19 | ||
20 | -import 'package:test/test.dart'; | ||
21 | import 'package:pdf/pdf.dart'; | 20 | import 'package:pdf/pdf.dart'; |
22 | import 'package:pdf/widgets.dart'; | 21 | import 'package:pdf/widgets.dart'; |
22 | +import 'package:test/test.dart'; | ||
23 | 23 | ||
24 | late Document pdf; | 24 | late Document pdf; |
25 | 25 |
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | - Fix pdfium memory leak | 8 | - Fix pdfium memory leak |
9 | - Fix error while loading shared libraries on Linux | 9 | - Fix error while loading shared libraries on Linux |
10 | - Update pdfium library to 4627 | 10 | - Update pdfium library to 4627 |
11 | +- Apply Flutter 2.5 coding style | ||
11 | 12 | ||
12 | ## 5.5.0 | 13 | ## 5.5.0 |
13 | 14 |
1 | -include: package:pedantic/analysis_options.yaml | 1 | +include: package:flutter_lints/flutter.yaml |
2 | 2 | ||
3 | analyzer: | 3 | analyzer: |
4 | strong-mode: | 4 | strong-mode: |
@@ -6,8 +6,10 @@ analyzer: | @@ -6,8 +6,10 @@ analyzer: | ||
6 | errors: | 6 | errors: |
7 | missing_required_param: warning | 7 | missing_required_param: warning |
8 | missing_return: warning | 8 | missing_return: warning |
9 | - public_member_api_docs: warning | 9 | + public_member_api_docs: ignore |
10 | todo: ignore | 10 | todo: ignore |
11 | + constant_identifier_names: ignore | ||
12 | + avoid_print: ignore | ||
11 | 13 | ||
12 | linter: | 14 | linter: |
13 | rules: | 15 | rules: |
@@ -15,52 +17,24 @@ linter: | @@ -15,52 +17,24 @@ linter: | ||
15 | - avoid_bool_literals_in_conditional_expressions | 17 | - avoid_bool_literals_in_conditional_expressions |
16 | - avoid_classes_with_only_static_members | 18 | - avoid_classes_with_only_static_members |
17 | - avoid_field_initializers_in_const_classes | 19 | - avoid_field_initializers_in_const_classes |
18 | - - avoid_function_literals_in_foreach_calls | ||
19 | - - avoid_renaming_method_parameters | ||
20 | - - avoid_returning_null_for_void | ||
21 | - avoid_slow_async_io | 20 | - avoid_slow_async_io |
22 | - avoid_unused_constructor_parameters | 21 | - avoid_unused_constructor_parameters |
23 | - avoid_void_async | 22 | - avoid_void_async |
24 | - - await_only_futures | ||
25 | - - camel_case_types | ||
26 | - cancel_subscriptions | 23 | - cancel_subscriptions |
27 | - - control_flow_in_finally | ||
28 | - directives_ordering | 24 | - directives_ordering |
29 | - - empty_statements | ||
30 | - flutter_style_todos | 25 | - flutter_style_todos |
31 | - - hash_and_equals | ||
32 | - - implementation_imports | ||
33 | - - iterable_contains_unrelated_type | ||
34 | - - list_remove_unrelated_type | ||
35 | - no_adjacent_strings_in_list | 26 | - no_adjacent_strings_in_list |
36 | - - non_constant_identifier_names | ||
37 | - omit_local_variable_types | 27 | - omit_local_variable_types |
38 | - - overridden_fields | ||
39 | - package_api_docs | 28 | - package_api_docs |
40 | - - package_names | ||
41 | - - package_prefixed_library_names | ||
42 | - prefer_asserts_in_initializer_lists | 29 | - prefer_asserts_in_initializer_lists |
43 | - - prefer_const_constructors | ||
44 | - - prefer_const_constructors_in_immutables | ||
45 | - - prefer_const_declarations | ||
46 | - - prefer_const_literals_to_create_immutables | ||
47 | - prefer_final_locals | 30 | - prefer_final_locals |
48 | - prefer_foreach | 31 | - prefer_foreach |
49 | - prefer_if_elements_to_conditional_expressions | 32 | - prefer_if_elements_to_conditional_expressions |
50 | - - prefer_initializing_formals | ||
51 | - - prefer_inlined_adds | ||
52 | - - prefer_typing_uninitialized_variables | ||
53 | - - prefer_void_to_null | 33 | + - prefer_single_quotes |
54 | - public_member_api_docs | 34 | - public_member_api_docs |
55 | - sort_constructors_first | 35 | - sort_constructors_first |
56 | - sort_pub_dependencies | 36 | - sort_pub_dependencies |
57 | - sort_unnamed_constructors_first | 37 | - sort_unnamed_constructors_first |
58 | - test_types_in_equals | 38 | - test_types_in_equals |
59 | - throw_in_finally | 39 | - throw_in_finally |
60 | - - unnecessary_brace_in_string_interps | ||
61 | - - unnecessary_getters_setters | ||
62 | - - unnecessary_null_aware_assignments | ||
63 | - - unnecessary_overrides | ||
64 | - - unnecessary_parenthesis | ||
65 | - unnecessary_statements | 40 | - unnecessary_statements |
66 | - - use_full_hex_values_for_flutter_colors |
@@ -152,7 +152,11 @@ class PrintingPlugin extends PrintingPlatform { | @@ -152,7 +152,11 @@ class PrintingPlugin extends PrintingPlatform { | ||
152 | stopWatch.stop(); | 152 | stopWatch.stop(); |
153 | completer.complete(true); | 153 | completer.complete(true); |
154 | } catch (e) { | 154 | } catch (e) { |
155 | - print(e); | 155 | + assert(() { |
156 | + // ignore: avoid_print | ||
157 | + print('Error: $e'); | ||
158 | + return true; | ||
159 | + }()); | ||
156 | completer.complete(_getPdf(result)); | 160 | completer.complete(_getPdf(result)); |
157 | } | 161 | } |
158 | }); | 162 | }); |
@@ -50,7 +50,7 @@ Future<ImageProvider> flutterImageProvider( | @@ -50,7 +50,7 @@ Future<ImageProvider> flutterImageProvider( | ||
50 | stream.removeListener(listener); | 50 | stream.removeListener(listener); |
51 | }, onError: (dynamic exception, StackTrace? stackTrace) { | 51 | }, onError: (dynamic exception, StackTrace? stackTrace) { |
52 | if (!completer.isCompleted) { | 52 | if (!completer.isCompleted) { |
53 | - completer.complete(null); | 53 | + completer.completeError('image failed to load'); |
54 | } | 54 | } |
55 | if (onError != null) { | 55 | if (onError != null) { |
56 | onError(exception, stackTrace); | 56 | onError(exception, stackTrace); |
@@ -68,7 +68,12 @@ class DownloadbleFont { | @@ -68,7 +68,12 @@ class DownloadbleFont { | ||
68 | protect: protect, | 68 | protect: protect, |
69 | ); | 69 | ); |
70 | } catch (e) { | 70 | } catch (e) { |
71 | + assert(() { | ||
72 | + // ignore: avoid_print | ||
71 | print('$e\nError loading $name, fallback to Helvetica.'); | 73 | print('$e\nError loading $name, fallback to Helvetica.'); |
74 | + return true; | ||
75 | + }()); | ||
76 | + | ||
72 | return Font.helvetica(); | 77 | return Font.helvetica(); |
73 | } | 78 | } |
74 | } | 79 | } |
@@ -42,7 +42,12 @@ mixin AssetManifest { | @@ -42,7 +42,12 @@ mixin AssetManifest { | ||
42 | final jsonData = json.decode(jsonString) as Map<String, dynamic>; | 42 | final jsonData = json.decode(jsonString) as Map<String, dynamic>; |
43 | _assets.addAll(jsonData.keys); | 43 | _assets.addAll(jsonData.keys); |
44 | } catch (e) { | 44 | } catch (e) { |
45 | + assert(() { | ||
46 | + // ignore: avoid_print | ||
45 | print('Error loading AssetManifest.json $e'); | 47 | print('Error loading AssetManifest.json $e'); |
48 | + return true; | ||
49 | + }()); | ||
50 | + | ||
46 | rootBundle.evict('AssetManifest.json'); | 51 | rootBundle.evict('AssetManifest.json'); |
47 | _failed = true; | 52 | _failed = true; |
48 | _ready = true; | 53 | _ready = true; |
@@ -152,7 +152,12 @@ class MethodChannelPrinting extends PrintingPlatform { | @@ -152,7 +152,12 @@ class MethodChannelPrinting extends PrintingPlatform { | ||
152 | <String, dynamic>{}, | 152 | <String, dynamic>{}, |
153 | ); | 153 | ); |
154 | } catch (e) { | 154 | } catch (e) { |
155 | + assert(() { | ||
156 | + // ignore: avoid_print | ||
155 | print('Error getting printing info: $e'); | 157 | print('Error getting printing info: $e'); |
158 | + return true; | ||
159 | + }()); | ||
160 | + | ||
156 | return PrintingInfo.unavailable; | 161 | return PrintingInfo.unavailable; |
157 | } | 162 | } |
158 | 163 |
@@ -24,6 +24,7 @@ import 'dart:typed_data'; | @@ -24,6 +24,7 @@ import 'dart:typed_data'; | ||
24 | 24 | ||
25 | import 'package:js/js.dart'; | 25 | import 'package:js/js.dart'; |
26 | 26 | ||
27 | +// ignore: avoid_classes_with_only_static_members | ||
27 | @JS('pdfjsLib') | 28 | @JS('pdfjsLib') |
28 | class PdfJs { | 29 | class PdfJs { |
29 | external static PdfJsDocLoader getDocument(Settings data); | 30 | external static PdfJsDocLoader getDocument(Settings data); |
1 | name: printing | 1 | name: printing |
2 | -author: David PHAM-VAN <dev.nfet.net@gmail.com> | ||
3 | description: > | 2 | description: > |
4 | Plugin that allows Flutter apps to generate and print documents to | 3 | Plugin that allows Flutter apps to generate and print documents to |
5 | compatible printers on Android, iOS, macOS, Windows, and Linux, | 4 | compatible printers on Android, iOS, macOS, Windows, and Linux, |
@@ -27,6 +26,7 @@ dependencies: | @@ -27,6 +26,7 @@ dependencies: | ||
27 | plugin_platform_interface: ^2.0.0 | 26 | plugin_platform_interface: ^2.0.0 |
28 | 27 | ||
29 | dev_dependencies: | 28 | dev_dependencies: |
29 | + flutter_lints: ^1.0.4 | ||
30 | flutter_test: | 30 | flutter_test: |
31 | sdk: flutter | 31 | sdk: flutter |
32 | mockito: ^5.0.0 | 32 | mockito: ^5.0.0 |
@@ -32,6 +32,7 @@ void main() { | @@ -32,6 +32,7 @@ void main() { | ||
32 | 32 | ||
33 | setUp(() { | 33 | setUp(() { |
34 | channel.setMockMethodCallHandler((MethodCall methodCall) async { | 34 | channel.setMockMethodCallHandler((MethodCall methodCall) async { |
35 | + // ignore: avoid_print | ||
35 | print(methodCall); | 36 | print(methodCall); |
36 | return '1'; | 37 | return '1'; |
37 | }); | 38 | }); |
1 | name: readme_to_dart | 1 | name: readme_to_dart |
2 | -author: David PHAM-VAN <dev.nfet.net@gmail.com> | ||
3 | description: Readme Markdown to dart source converter. | 2 | description: Readme Markdown to dart source converter. |
4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/test | 3 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/test |
5 | repository: https://github.com/DavBfr/dart_pdf | 4 | repository: https://github.com/DavBfr/dart_pdf |
-
Please register or login to post a comment