David PHAM-VAN

Apply Flutter 2.5 coding style

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 }
@@ -17,6 +17,7 @@ dependencies: @@ -17,6 +17,7 @@ dependencies:
17 url_launcher: ^6.0.6 17 url_launcher: ^6.0.6
18 18
19 dev_dependencies: 19 dev_dependencies:
  20 + flutter_lints: ^1.0.4
20 flutter_test: 21 flutter_test:
21 sdk: flutter 22 sdk: flutter
22 test: ^1.16.5 23 test: ^1.16.5
@@ -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');
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 ## 3.6.0 3 ## 3.6.0
4 4
5 - Fix text justify with multiple paragraphs 5 - Fix text justify with multiple paragraphs
  6 +- Apply Flutter 2.5 coding style
6 7
7 ## 3.5.0 8 ## 3.5.0
8 9
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,387 +14,380 @@ @@ -14,387 +14,380 @@
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>{  
22 - 0x0640: <int>[0x0640, 0x0640, 0x0640, 0x0640], // ARABIC TATWEEL  
23 -  
24 - 0x0621: <int>[0xFE80], // ARABIC LETTER HAMZA  
25 - 0x0622: <int>[0xFE81, 0xFE82], // ARABIC LETTER ALEF WITH MADDA ABOVE  
26 - 0x0623: <int>[0xFE83, 0xFE84], // ARABIC LETTER ALEF WITH HAMZA ABOVE  
27 - 0x0624: <int>[0xFE85, 0xFE86], // ARABIC LETTER WAW WITH HAMZA ABOVE  
28 - 0x0625: <int>[0xFE87, 0xFE88], // ARABIC LETTER ALEF WITH HAMZA BELOW  
29 - 0x0626: <int>[  
30 - 0xFE89,  
31 - 0xFE8A,  
32 - 0xFE8B,  
33 - 0xFE8C  
34 - ], // ARABIC LETTER YEH WITH HAMZA ABOVE  
35 - 0x0627: <int>[0xFE8D, 0xFE8E], // ARABIC LETTER ALEF  
36 - 0x0628: <int>[0xFE8F, 0xFE90, 0xFE91, 0xFE92], // ARABIC LETTER BEH  
37 - 0x0629: <int>[0xFE93, 0xFE94], // ARABIC LETTER TEH MARBUTA  
38 - 0x062A: <int>[0xFE95, 0xFE96, 0xFE97, 0xFE98], // ARABIC LETTER TEH  
39 - 0x062B: <int>[0xFE99, 0xFE9A, 0xFE9B, 0xFE9C], // ARABIC LETTER THEH  
40 - 0x062C: <int>[0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0], // ARABIC LETTER JEEM  
41 - 0x062D: <int>[0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4], // ARABIC LETTER HAH  
42 - 0x062E: <int>[0xFEA5, 0xFEA6, 0xFEA7, 0xFEA8], // ARABIC LETTER KHAH  
43 - 0x062F: <int>[0xFEA9, 0xFEAA], // ARABIC LETTER DAL  
44 - 0x0630: <int>[0xFEAB, 0xFEAC], // ARABIC LETTER THAL  
45 - 0x0631: <int>[0xFEAD, 0xFEAE], // ARABIC LETTER REH  
46 - 0x0632: <int>[0xFEAF, 0xFEB0], // ARABIC LETTER ZAIN  
47 - 0x0633: <int>[0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4], // ARABIC LETTER SEEN  
48 - 0x0634: <int>[0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8], // ARABIC LETTER SHEEN  
49 - 0x0635: <int>[0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC], // ARABIC LETTER SAD  
50 - 0x0636: <int>[0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0], // ARABIC LETTER DAD  
51 - 0x0637: <int>[0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4], // ARABIC LETTER TAH  
52 - 0x0638: <int>[0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8], // ARABIC LETTER ZAH  
53 - 0x0639: <int>[0xFEC9, 0xFECA, 0xFECB, 0xFECC], // ARABIC LETTER AIN  
54 - 0x063A: <int>[0xFECD, 0xFECE, 0xFECF, 0xFED0], // ARABIC LETTER GHAIN  
55 - 0x0641: <int>[0xFED1, 0xFED2, 0xFED3, 0xFED4], // ARABIC LETTER FEH  
56 - 0x0642: <int>[0xFED5, 0xFED6, 0xFED7, 0xFED8], // ARABIC LETTER QAF  
57 - 0x0643: <int>[0xFED9, 0xFEDA, 0xFEDB, 0xFEDC], // ARABIC LETTER KAF  
58 - 0x0644: <int>[0xFEDD, 0xFEDE, 0xFEDF, 0xFEE0], // ARABIC LETTER LAM  
59 - 0x0645: <int>[0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4], // ARABIC LETTER MEEM  
60 - 0x0646: <int>[0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8], // ARABIC LETTER NOON  
61 - 0x0647: <int>[0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC], // ARABIC LETTER HEH  
62 - 0x0648: <int>[0xFEED, 0xFEEE], // ARABIC LETTER WAW  
63 - 0x0649: <int>[0xFEEF, 0xFEF0, 64488, 64489], // ARABIC LETTER ALEF MAKSURA  
64 - 0x064A: <int>[0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4], // ARABIC LETTER YEH  
65 - 0x0671: <int>[0xFB50, 0xFB51], // ARABIC LETTER ALEF WASLA  
66 - 0x0677: <int>[0xFBDD], // ARABIC LETTER U WITH HAMZA ABOVE  
67 - 0x0679: <int>[0xFB66, 0xFB67, 0xFB68, 0xFB69], // ARABIC LETTER TTEH  
68 - 0x067A: <int>[0xFB5E, 0xFB5F, 0xFB60, 0xFB61], // ARABIC LETTER TTEHEH  
69 - 0x067B: <int>[0xFB52, 0xFB53, 0xFB54, 0xFB55], // ARABIC LETTER BEEH  
70 - 0x067E: <int>[0xFB56, 0xFB57, 0xFB58, 0xFB59], // ARABIC LETTER PEH  
71 - 0x067F: <int>[0xFB62, 0xFB63, 0xFB64, 0xFB65], // ARABIC LETTER TEHEH  
72 - 0x0680: <int>[0xFB5A, 0xFB5B, 0xFB5C, 0xFB5D], // ARABIC LETTER BEHEH  
73 - 0x0683: <int>[0xFB76, 0xFB77, 0xFB78, 0xFB79], // ARABIC LETTER NYEH  
74 - 0x0684: <int>[0xFB72, 0xFB73, 0xFB74, 0xFB75], // ARABIC LETTER DYEH  
75 - 0x0686: <int>[0xFB7A, 0xFB7B, 0xFB7C, 0xFB7D], // ARABIC LETTER TCHEH  
76 - 0x0687: <int>[0xFB7E, 0xFB7F, 0xFB80, 0xFB81], // ARABIC LETTER TCHEHEH  
77 - 0x0688: <int>[0xFB88, 0xFB89], // ARABIC LETTER DDAL  
78 - 0x068C: <int>[0xFB84, 0xFB85], // ARABIC LETTER DAHAL  
79 - 0x068D: <int>[0xFB82, 0xFB83], // ARABIC LETTER DDAHAL  
80 - 0x068E: <int>[0xFB86, 0xFB87], // ARABIC LETTER DUL  
81 - 0x0691: <int>[0xFB8C, 0xFB8D], // ARABIC LETTER RREH  
82 - 0x0698: <int>[0xFB8A, 0xFB8B], // ARABIC LETTER JEH  
83 - 0x06A4: <int>[0xFB6A, 0xFB6B, 0xFB6C, 0xFB6D], // ARABIC LETTER VEH  
84 - 0x06A6: <int>[0xFB6E, 0xFB6F, 0xFB70, 0xFB71], // ARABIC LETTER PEHEH  
85 - 0x06A9: <int>[0xFB8E, 0xFB8F, 0xFB90, 0xFB91], // ARABIC LETTER KEHEH  
86 - 0x06AD: <int>[0xFBD3, 0xFBD4, 0xFBD5, 0xFBD6], // ARABIC LETTER NG  
87 - 0x06AF: <int>[0xFB92, 0xFB93, 0xFB94, 0xFB95], // ARABIC LETTER GAF  
88 - 0x06B1: <int>[0xFB9A, 0xFB9B, 0xFB9C, 0xFB9D], // ARABIC LETTER NGOEH  
89 - 0x06B3: <int>[0xFB96, 0xFB97, 0xFB98, 0xFB99], // ARABIC LETTER GUEH  
90 - 0x06BA: <int>[0xFB9E, 0xFB9F], // ARABIC LETTER NOON GHUNNA  
91 - 0x06BB: <int>[0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3], // ARABIC LETTER RNOON  
92 - 0x06BE: <int>[  
93 - 0xFBAA,  
94 - 0xFBAB,  
95 - 0xFBAC,  
96 - 0xFBAD  
97 - ], // ARABIC LETTER HEH DOACHASHMEE  
98 - 0x06C0: <int>[0xFBA4, 0xFBA5], // ARABIC LETTER HEH WITH YEH ABOVE  
99 - 0x06C1: <int>[0xFBA6, 0xFBA7, 0xFBA8, 0xFBA9], // ARABIC LETTER HEH GOAL  
100 - 0x06C5: <int>[0xFBE0, 0xFBE1], // ARABIC LETTER KIRGHIZ OE  
101 - 0x06C6: <int>[0xFBD9, 0xFBDA], // ARABIC LETTER OE  
102 - 0x06C7: <int>[0xFBD7, 0xFBD8], // ARABIC LETTER U  
103 - 0x06C8: <int>[0xFBDB, 0xFBDC], // ARABIC LETTER YU  
104 - 0x06C9: <int>[0xFBE2, 0xFBE3], // ARABIC LETTER KIRGHIZ YU  
105 - 0x06CB: <int>[0xFBDE, 0xFBDF], // ARABIC LETTER VE  
106 - 0x06CC: <int>[0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF], // ARABIC LETTER FARSI YEH  
107 - 0x06D0: <int>[0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7], //ARABIC LETTER E  
108 - 0x06D2: <int>[0xFBAE, 0xFBAF], // ARABIC LETTER YEH BARREE  
109 - 0x06D3: <int>[0xFBB0, 0xFBB1], // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE  
110 - };  
111 -  
112 - /* 17 +/// Arabic shape substitutions: char code => (isolated, final, initial, medial).
  18 +/// Arabic Substition A
  19 +const Map<int, dynamic> _arabicSubstitionA = <int, dynamic>{
  20 + 0x0640: <int>[0x0640, 0x0640, 0x0640, 0x0640], // ARABIC TATWEEL
  21 +
  22 + 0x0621: <int>[0xFE80], // ARABIC LETTER HAMZA
  23 + 0x0622: <int>[0xFE81, 0xFE82], // ARABIC LETTER ALEF WITH MADDA ABOVE
  24 + 0x0623: <int>[0xFE83, 0xFE84], // ARABIC LETTER ALEF WITH HAMZA ABOVE
  25 + 0x0624: <int>[0xFE85, 0xFE86], // ARABIC LETTER WAW WITH HAMZA ABOVE
  26 + 0x0625: <int>[0xFE87, 0xFE88], // ARABIC LETTER ALEF WITH HAMZA BELOW
  27 + 0x0626: <int>[
  28 + 0xFE89,
  29 + 0xFE8A,
  30 + 0xFE8B,
  31 + 0xFE8C
  32 + ], // ARABIC LETTER YEH WITH HAMZA ABOVE
  33 + 0x0627: <int>[0xFE8D, 0xFE8E], // ARABIC LETTER ALEF
  34 + 0x0628: <int>[0xFE8F, 0xFE90, 0xFE91, 0xFE92], // ARABIC LETTER BEH
  35 + 0x0629: <int>[0xFE93, 0xFE94], // ARABIC LETTER TEH MARBUTA
  36 + 0x062A: <int>[0xFE95, 0xFE96, 0xFE97, 0xFE98], // ARABIC LETTER TEH
  37 + 0x062B: <int>[0xFE99, 0xFE9A, 0xFE9B, 0xFE9C], // ARABIC LETTER THEH
  38 + 0x062C: <int>[0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0], // ARABIC LETTER JEEM
  39 + 0x062D: <int>[0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4], // ARABIC LETTER HAH
  40 + 0x062E: <int>[0xFEA5, 0xFEA6, 0xFEA7, 0xFEA8], // ARABIC LETTER KHAH
  41 + 0x062F: <int>[0xFEA9, 0xFEAA], // ARABIC LETTER DAL
  42 + 0x0630: <int>[0xFEAB, 0xFEAC], // ARABIC LETTER THAL
  43 + 0x0631: <int>[0xFEAD, 0xFEAE], // ARABIC LETTER REH
  44 + 0x0632: <int>[0xFEAF, 0xFEB0], // ARABIC LETTER ZAIN
  45 + 0x0633: <int>[0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4], // ARABIC LETTER SEEN
  46 + 0x0634: <int>[0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8], // ARABIC LETTER SHEEN
  47 + 0x0635: <int>[0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC], // ARABIC LETTER SAD
  48 + 0x0636: <int>[0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0], // ARABIC LETTER DAD
  49 + 0x0637: <int>[0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4], // ARABIC LETTER TAH
  50 + 0x0638: <int>[0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8], // ARABIC LETTER ZAH
  51 + 0x0639: <int>[0xFEC9, 0xFECA, 0xFECB, 0xFECC], // ARABIC LETTER AIN
  52 + 0x063A: <int>[0xFECD, 0xFECE, 0xFECF, 0xFED0], // ARABIC LETTER GHAIN
  53 + 0x0641: <int>[0xFED1, 0xFED2, 0xFED3, 0xFED4], // ARABIC LETTER FEH
  54 + 0x0642: <int>[0xFED5, 0xFED6, 0xFED7, 0xFED8], // ARABIC LETTER QAF
  55 + 0x0643: <int>[0xFED9, 0xFEDA, 0xFEDB, 0xFEDC], // ARABIC LETTER KAF
  56 + 0x0644: <int>[0xFEDD, 0xFEDE, 0xFEDF, 0xFEE0], // ARABIC LETTER LAM
  57 + 0x0645: <int>[0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4], // ARABIC LETTER MEEM
  58 + 0x0646: <int>[0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8], // ARABIC LETTER NOON
  59 + 0x0647: <int>[0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC], // ARABIC LETTER HEH
  60 + 0x0648: <int>[0xFEED, 0xFEEE], // ARABIC LETTER WAW
  61 + 0x0649: <int>[0xFEEF, 0xFEF0, 64488, 64489], // ARABIC LETTER ALEF MAKSURA
  62 + 0x064A: <int>[0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4], // ARABIC LETTER YEH
  63 + 0x0671: <int>[0xFB50, 0xFB51], // ARABIC LETTER ALEF WASLA
  64 + 0x0677: <int>[0xFBDD], // ARABIC LETTER U WITH HAMZA ABOVE
  65 + 0x0679: <int>[0xFB66, 0xFB67, 0xFB68, 0xFB69], // ARABIC LETTER TTEH
  66 + 0x067A: <int>[0xFB5E, 0xFB5F, 0xFB60, 0xFB61], // ARABIC LETTER TTEHEH
  67 + 0x067B: <int>[0xFB52, 0xFB53, 0xFB54, 0xFB55], // ARABIC LETTER BEEH
  68 + 0x067E: <int>[0xFB56, 0xFB57, 0xFB58, 0xFB59], // ARABIC LETTER PEH
  69 + 0x067F: <int>[0xFB62, 0xFB63, 0xFB64, 0xFB65], // ARABIC LETTER TEHEH
  70 + 0x0680: <int>[0xFB5A, 0xFB5B, 0xFB5C, 0xFB5D], // ARABIC LETTER BEHEH
  71 + 0x0683: <int>[0xFB76, 0xFB77, 0xFB78, 0xFB79], // ARABIC LETTER NYEH
  72 + 0x0684: <int>[0xFB72, 0xFB73, 0xFB74, 0xFB75], // ARABIC LETTER DYEH
  73 + 0x0686: <int>[0xFB7A, 0xFB7B, 0xFB7C, 0xFB7D], // ARABIC LETTER TCHEH
  74 + 0x0687: <int>[0xFB7E, 0xFB7F, 0xFB80, 0xFB81], // ARABIC LETTER TCHEHEH
  75 + 0x0688: <int>[0xFB88, 0xFB89], // ARABIC LETTER DDAL
  76 + 0x068C: <int>[0xFB84, 0xFB85], // ARABIC LETTER DAHAL
  77 + 0x068D: <int>[0xFB82, 0xFB83], // ARABIC LETTER DDAHAL
  78 + 0x068E: <int>[0xFB86, 0xFB87], // ARABIC LETTER DUL
  79 + 0x0691: <int>[0xFB8C, 0xFB8D], // ARABIC LETTER RREH
  80 + 0x0698: <int>[0xFB8A, 0xFB8B], // ARABIC LETTER JEH
  81 + 0x06A4: <int>[0xFB6A, 0xFB6B, 0xFB6C, 0xFB6D], // ARABIC LETTER VEH
  82 + 0x06A6: <int>[0xFB6E, 0xFB6F, 0xFB70, 0xFB71], // ARABIC LETTER PEHEH
  83 + 0x06A9: <int>[0xFB8E, 0xFB8F, 0xFB90, 0xFB91], // ARABIC LETTER KEHEH
  84 + 0x06AD: <int>[0xFBD3, 0xFBD4, 0xFBD5, 0xFBD6], // ARABIC LETTER NG
  85 + 0x06AF: <int>[0xFB92, 0xFB93, 0xFB94, 0xFB95], // ARABIC LETTER GAF
  86 + 0x06B1: <int>[0xFB9A, 0xFB9B, 0xFB9C, 0xFB9D], // ARABIC LETTER NGOEH
  87 + 0x06B3: <int>[0xFB96, 0xFB97, 0xFB98, 0xFB99], // ARABIC LETTER GUEH
  88 + 0x06BA: <int>[0xFB9E, 0xFB9F], // ARABIC LETTER NOON GHUNNA
  89 + 0x06BB: <int>[0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3], // ARABIC LETTER RNOON
  90 + 0x06BE: <int>[
  91 + 0xFBAA,
  92 + 0xFBAB,
  93 + 0xFBAC,
  94 + 0xFBAD
  95 + ], // ARABIC LETTER HEH DOACHASHMEE
  96 + 0x06C0: <int>[0xFBA4, 0xFBA5], // ARABIC LETTER HEH WITH YEH ABOVE
  97 + 0x06C1: <int>[0xFBA6, 0xFBA7, 0xFBA8, 0xFBA9], // ARABIC LETTER HEH GOAL
  98 + 0x06C5: <int>[0xFBE0, 0xFBE1], // ARABIC LETTER KIRGHIZ OE
  99 + 0x06C6: <int>[0xFBD9, 0xFBDA], // ARABIC LETTER OE
  100 + 0x06C7: <int>[0xFBD7, 0xFBD8], // ARABIC LETTER U
  101 + 0x06C8: <int>[0xFBDB, 0xFBDC], // ARABIC LETTER YU
  102 + 0x06C9: <int>[0xFBE2, 0xFBE3], // ARABIC LETTER KIRGHIZ YU
  103 + 0x06CB: <int>[0xFBDE, 0xFBDF], // ARABIC LETTER VE
  104 + 0x06CC: <int>[0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF], // ARABIC LETTER FARSI YEH
  105 + 0x06D0: <int>[0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7], //ARABIC LETTER E
  106 + 0x06D2: <int>[0xFBAE, 0xFBAF], // ARABIC LETTER YEH BARREE
  107 + 0x06D3: <int>[0xFBB0, 0xFBB1], // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE
  108 +};
  109 +
  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>{  
119 - 0x0651: <int, int>{  
120 - 0x064C: 0xFC5E, // Shadda + Dammatan  
121 - 0x064D: 0xFC5F, // Shadda + Kasratan  
122 - 0x064E: 0xFC60, // Shadda + Fatha  
123 - 0x064F: 0xFC61, // Shadda + Damma  
124 - 0x0650: 0xFC62, // Shadda + Kasra  
125 - 0x0670: 0xFC63, // Shadda + Dagger alif  
126 - },  
127 - };  
128 -  
129 - static const Map<int, dynamic> _ligatures = <int, dynamic>{  
130 - 0xFEDF: <int, int>{  
131 - 0xFE82:  
132 - 0xFEF5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM  
133 - 0xFE84:  
134 - 0xFEF7, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM  
135 - 0xFE88:  
136 - 0xFEF9, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM  
137 - 0xFE8E: 0xFEFB // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM  
138 - },  
139 - 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  
146 - 0xFE8E: 0xFEFC // ARABIC LIGATURE LAM WITH ALEF FINAL FORM  
147 - }, 116 +const Map<int, dynamic> _diacriticLigatures = <int, dynamic>{
  117 + 0x0651: <int, int>{
  118 + 0x064C: 0xFC5E, // Shadda + Dammatan
  119 + 0x064D: 0xFC5F, // Shadda + Kasratan
  120 + 0x064E: 0xFC60, // Shadda + Fatha
  121 + 0x064F: 0xFC61, // Shadda + Damma
  122 + 0x0650: 0xFC62, // Shadda + Kasra
  123 + 0x0670: 0xFC63, // Shadda + Dagger alif
  124 + },
  125 +};
  126 +
  127 +const Map<int, dynamic> _ligatures = <int, dynamic>{
  128 + 0xFEDF: <int, int>{
  129 + 0xFE82:
  130 + 0xFEF5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
  131 + 0xFE84:
  132 + 0xFEF7, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
  133 + 0xFE88:
  134 + 0xFEF9, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM
  135 + 0xFE8E: 0xFEFB // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
  136 + },
  137 + 0xFEE0: <int, int>{
  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
  141 + 0xFE8E: 0xFEFC // ARABIC LIGATURE LAM WITH ALEF FINAL FORM
  142 + },
148 // 0xFE8D: <int, dynamic>{ 143 // 0xFE8D: <int, dynamic>{
149 // 0xFEDF: <int, dynamic>{ 144 // 0xFEDF: <int, dynamic>{
150 // 0xFEE0: <int, int>{0xFEEA: 0xFDF2} 145 // 0xFEE0: <int, int>{0xFEEA: 0xFDF2}
151 // } 146 // }
152 // }, // ALLAH 147 // }, // ALLAH
153 - };  
154 -  
155 - static const List<int> _alfletter = <int>[1570, 1571, 1573, 1575];  
156 -  
157 - static const Map<int, int> _arabicDiacritics = <int, int>{  
158 - 0x064B: 0x064B, // Fathatan  
159 - 0x064C: 0x064C, // Dammatan  
160 - 0x064D: 0x064D, // Kasratan  
161 - 0x064E: 0x064E, // Fatha  
162 - 0x064F: 0x064F, // Damma  
163 - 0x0650: 0x0650, // Kasra  
164 - 0x0651: 0x0651, // Shadda  
165 - 0x0652: 0x0652, // Sukun  
166 -  
167 - 0x0670: 0x0670, // Dagger alif  
168 -  
169 - 0xFC5E: 0xFC5E, // Shadda + Dammatan  
170 - 0xFC5F: 0xFC5F, // Shadda + Kasratan  
171 - 0xFC60: 0xFC60, // Shadda + Fatha  
172 - 0xFC61: 0xFC61, // Shadda + Damma  
173 - 0xFC62: 0xFC62, // Shadda + Kasra  
174 - 0xFC63: 0xFC63, // Shadda + Dagger alif  
175 - // 1548: 1548,  
176 - };  
177 -  
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;  
183 -  
184 - static bool _isInArabicSubstitutionA(int letter) {  
185 - return _arabicSubstitionA.containsKey(letter);  
186 - } 148 +};
  149 +
  150 +const List<int> _alfletter = <int>[1570, 1571, 1573, 1575];
  151 +
  152 +const Map<int, int> _arabicDiacritics = <int, int>{
  153 + 0x064B: 0x064B, // Fathatan
  154 + 0x064C: 0x064C, // Dammatan
  155 + 0x064D: 0x064D, // Kasratan
  156 + 0x064E: 0x064E, // Fatha
  157 + 0x064F: 0x064F, // Damma
  158 + 0x0650: 0x0650, // Kasra
  159 + 0x0651: 0x0651, // Shadda
  160 + 0x0652: 0x0652, // Sukun
  161 +
  162 + 0x0670: 0x0670, // Dagger alif
  163 +
  164 + 0xFC5E: 0xFC5E, // Shadda + Dammatan
  165 + 0xFC5F: 0xFC5F, // Shadda + Kasratan
  166 + 0xFC60: 0xFC60, // Shadda + Fatha
  167 + 0xFC61: 0xFC61, // Shadda + Damma
  168 + 0xFC62: 0xFC62, // Shadda + Kasra
  169 + 0xFC63: 0xFC63, // Shadda + Dagger alif
  170 + // 1548: 1548,
  171 +};
  172 +
  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;
  178 +
  179 +bool _isInArabicSubstitutionA(int letter) {
  180 + return _arabicSubstitionA.containsKey(letter);
  181 +}
187 182
188 - static bool _isArabicLetter(int letter) {  
189 - return (letter >= 0x0600 && letter <= 0x06FF) ||  
190 - (letter >= 0x0750 && letter <= 0x077F) ||  
191 - (letter >= 0x08FF && letter <= 0xFB50) ||  
192 - (letter >= 0xFDFF && letter <= 0xFEFF);  
193 - } 183 +bool _isArabicLetter(int letter) {
  184 + return (letter >= 0x0600 && letter <= 0x06FF) ||
  185 + (letter >= 0x0750 && letter <= 0x077F) ||
  186 + (letter >= 0x08FF && letter <= 0xFB50) ||
  187 + (letter >= 0xFDFF && letter <= 0xFEFF);
  188 +}
194 189
195 - static bool _isArabicEndLetter(int letter) {  
196 - return _isArabicLetter(letter) &&  
197 - _isInArabicSubstitutionA(letter) &&  
198 - _arabicSubstitionA[letter].length <= 2;  
199 - } 190 +bool _isArabicEndLetter(int letter) {
  191 + return _isArabicLetter(letter) &&
  192 + _isInArabicSubstitutionA(letter) &&
  193 + _arabicSubstitionA[letter].length <= 2;
  194 +}
200 195
201 - static bool _isArabicAlfLetter(int letter) {  
202 - return _isArabicLetter(letter) && _alfletter.contains(letter);  
203 - } 196 +bool _isArabicAlfLetter(int letter) {
  197 + return _isArabicLetter(letter) && _alfletter.contains(letter);
  198 +}
204 199
205 - static bool _arabicLetterHasFinalForm(int letter) {  
206 - return _isArabicLetter(letter) &&  
207 - _isInArabicSubstitutionA(letter) &&  
208 - (_arabicSubstitionA[letter].length >= 2);  
209 - } 200 +bool _arabicLetterHasFinalForm(int letter) {
  201 + return _isArabicLetter(letter) &&
  202 + _isInArabicSubstitutionA(letter) &&
  203 + (_arabicSubstitionA[letter].length >= 2);
  204 +}
210 205
211 - static bool _arabicLetterHasMedialForm(int letter) {  
212 - return _isArabicLetter(letter) &&  
213 - _isInArabicSubstitutionA(letter) &&  
214 - _arabicSubstitionA[letter].length == 4;  
215 - } 206 +bool _arabicLetterHasMedialForm(int letter) {
  207 + return _isArabicLetter(letter) &&
  208 + _isInArabicSubstitutionA(letter) &&
  209 + _arabicSubstitionA[letter].length == 4;
  210 +}
216 211
217 - static bool _isArabicDiacritic(int letter) {  
218 - return _arabicDiacritics.containsKey(letter);  
219 - } 212 +bool _isArabicDiacritic(int letter) {
  213 + return _arabicDiacritics.containsKey(letter);
  214 +}
220 215
221 - static bool isArabicDiacriticValue(int letter) {  
222 - return _arabicDiacritics.containsValue(letter);  
223 - } 216 +bool isArabicDiacriticValue(int letter) {
  217 + return _arabicDiacritics.containsValue(letter);
  218 +}
224 219
225 - static List<int> _resolveLigatures(List<int> lettersq) {  
226 - final result = <int>[];  
227 - dynamic tmpLigatures = _ligatures;  
228 - dynamic tmpDiacritic = _diacriticLigatures;  
229 - final letters = lettersq.reversed.toList(); 220 +List<int> _resolveLigatures(List<int> lettersq) {
  221 + final result = <int>[];
  222 + dynamic tmpLigatures = _ligatures;
  223 + dynamic tmpDiacritic = _diacriticLigatures;
  224 + final letters = lettersq.reversed.toList();
230 225
231 - final effectedLetters = <int>[];  
232 - final effectedDiacritics = <int>[]; 226 + final effectedLetters = <int>[];
  227 + final effectedDiacritics = <int>[];
233 228
234 - final finalDiacritics = <int>[]; 229 + final finalDiacritics = <int>[];
235 230
236 - for (var i = 0; i < letters.length; i++) {  
237 - if (isArabicDiacriticValue(letters[i])) {  
238 - effectedDiacritics.insert(0, letters[i]);  
239 - if (tmpDiacritic.containsKey(letters[i])) {  
240 - tmpDiacritic = tmpDiacritic[letters[i]]; 231 + for (var i = 0; i < letters.length; i++) {
  232 + if (isArabicDiacriticValue(letters[i])) {
  233 + effectedDiacritics.insert(0, letters[i]);
  234 + if (tmpDiacritic.containsKey(letters[i])) {
  235 + tmpDiacritic = tmpDiacritic[letters[i]];
241 236
242 - if (tmpDiacritic is int) {  
243 - finalDiacritics.insert(0, tmpDiacritic);  
244 - tmpDiacritic = _diacriticLigatures;  
245 - effectedDiacritics.clear();  
246 - }  
247 - } else { 237 + if (tmpDiacritic is int) {
  238 + finalDiacritics.insert(0, tmpDiacritic);
248 tmpDiacritic = _diacriticLigatures; 239 tmpDiacritic = _diacriticLigatures;
249 -  
250 - // add all Diacritics if there is no letter Ligatures.  
251 - if (effectedLetters.isEmpty) {  
252 - result.insertAll(0, finalDiacritics);  
253 - result.insertAll(0, effectedDiacritics);  
254 - finalDiacritics.clear();  
255 - effectedDiacritics.clear();  
256 - }  
257 - }  
258 - } else if (tmpLigatures.containsKey(letters[i])) {  
259 - effectedLetters.insert(0, letters[i]);  
260 - tmpLigatures = tmpLigatures[letters[i]];  
261 -  
262 - if (tmpLigatures is int) {  
263 - result.insert(0, tmpLigatures);  
264 - tmpLigatures = _ligatures;  
265 - effectedLetters.clear(); 240 + effectedDiacritics.clear();
266 } 241 }
267 } else { 242 } else {
268 - tmpLigatures = _ligatures;  
269 -  
270 - // add effected letters if they aren't ligature.  
271 - if (effectedLetters.isNotEmpty) {  
272 - result.insertAll(0, effectedLetters);  
273 - effectedLetters.clear();  
274 - } 243 + tmpDiacritic = _diacriticLigatures;
275 244
276 - // add Diacritics after or before letter ligature.  
277 - if (effectedLetters.isEmpty && effectedDiacritics.isNotEmpty) { 245 + // add all Diacritics if there is no letter Ligatures.
  246 + if (effectedLetters.isEmpty) {
  247 + result.insertAll(0, finalDiacritics);
278 result.insertAll(0, effectedDiacritics); 248 result.insertAll(0, effectedDiacritics);
  249 + finalDiacritics.clear();
279 effectedDiacritics.clear(); 250 effectedDiacritics.clear();
280 } 251 }
  252 + }
  253 + } else if (tmpLigatures.containsKey(letters[i])) {
  254 + effectedLetters.insert(0, letters[i]);
  255 + tmpLigatures = tmpLigatures[letters[i]];
281 256
282 - result.insert(0, letters[i]); 257 + if (tmpLigatures is int) {
  258 + result.insert(0, tmpLigatures);
  259 + tmpLigatures = _ligatures;
  260 + effectedLetters.clear();
283 } 261 }
  262 + } else {
  263 + tmpLigatures = _ligatures;
284 264
285 - // add Diacritic ligatures.  
286 - if (effectedLetters.isEmpty && finalDiacritics.isNotEmpty) {  
287 - result.insertAll(0, finalDiacritics);  
288 - finalDiacritics.clear(); 265 + // add effected letters if they aren't ligature.
  266 + if (effectedLetters.isNotEmpty) {
  267 + result.insertAll(0, effectedLetters);
  268 + effectedLetters.clear();
289 } 269 }
290 - }  
291 270
292 - return result;  
293 - } 271 + // add Diacritics after or before letter ligature.
  272 + if (effectedLetters.isEmpty && effectedDiacritics.isNotEmpty) {
  273 + result.insertAll(0, effectedDiacritics);
  274 + effectedDiacritics.clear();
  275 + }
294 276
295 - static int _getCorrectForm(int currentChar, int beforeChar, int nextChar) {  
296 - if (_isInArabicSubstitutionA(currentChar) == false) {  
297 - return _noChangeInForm;  
298 - }  
299 - if (!_arabicLetterHasFinalForm(currentChar) ||  
300 - (!_isArabicLetter(beforeChar) && !_isArabicLetter(nextChar)) ||  
301 - (!_isArabicLetter(nextChar) && _isArabicEndLetter(beforeChar)) ||  
302 - (_isArabicEndLetter(currentChar) && !_isArabicLetter(beforeChar)) ||  
303 - (_isArabicEndLetter(currentChar) && _isArabicAlfLetter(beforeChar)) ||  
304 - (_isArabicEndLetter(currentChar) && _isArabicEndLetter(beforeChar))) {  
305 - return _isolatedForm; 277 + result.insert(0, letters[i]);
306 } 278 }
307 279
308 - if (_arabicLetterHasMedialForm(currentChar) &&  
309 - _isArabicLetter(beforeChar) &&  
310 - !_isArabicEndLetter(beforeChar) &&  
311 - _isArabicLetter(nextChar) &&  
312 - _arabicLetterHasFinalForm(nextChar)) {  
313 - return _medialForm; 280 + // add Diacritic ligatures.
  281 + if (effectedLetters.isEmpty && finalDiacritics.isNotEmpty) {
  282 + result.insertAll(0, finalDiacritics);
  283 + finalDiacritics.clear();
314 } 284 }
  285 + }
315 286
316 - if (_isArabicEndLetter(currentChar) || (!_isArabicLetter(nextChar))) {  
317 - return _finalForm;  
318 - }  
319 - return _initialForm; 287 + return result;
  288 +}
  289 +
  290 +int _getCorrectForm(int currentChar, int beforeChar, int nextChar) {
  291 + if (_isInArabicSubstitutionA(currentChar) == false) {
  292 + return _noChangeInForm;
  293 + }
  294 + if (!_arabicLetterHasFinalForm(currentChar) ||
  295 + (!_isArabicLetter(beforeChar) && !_isArabicLetter(nextChar)) ||
  296 + (!_isArabicLetter(nextChar) && _isArabicEndLetter(beforeChar)) ||
  297 + (_isArabicEndLetter(currentChar) && !_isArabicLetter(beforeChar)) ||
  298 + (_isArabicEndLetter(currentChar) && _isArabicAlfLetter(beforeChar)) ||
  299 + (_isArabicEndLetter(currentChar) && _isArabicEndLetter(beforeChar))) {
  300 + return _isolatedForm;
  301 + }
  302 +
  303 + if (_arabicLetterHasMedialForm(currentChar) &&
  304 + _isArabicLetter(beforeChar) &&
  305 + !_isArabicEndLetter(beforeChar) &&
  306 + _isArabicLetter(nextChar) &&
  307 + _arabicLetterHasFinalForm(nextChar)) {
  308 + return _medialForm;
  309 + }
  310 +
  311 + if (_isArabicEndLetter(currentChar) || (!_isArabicLetter(nextChar))) {
  312 + return _finalForm;
320 } 313 }
  314 + return _initialForm;
  315 +}
321 316
322 - static Iterable<String> _parse(String text) sync* {  
323 - final words = text.split(' '); 317 +Iterable<String> _parse(String text) sync* {
  318 + final words = text.split(' ');
324 319
325 - final notArabicWords = <List<int>>[]; 320 + final notArabicWords = <List<int>>[];
326 321
327 - var first = true;  
328 - for (var word in words) {  
329 - final newWord = <int>[];  
330 - var isNewWordArabic = false; 322 + var first = true;
  323 + for (var word in words) {
  324 + final newWord = <int>[];
  325 + var isNewWordArabic = false;
331 326
332 - var prevLetter = 0; 327 + var prevLetter = 0;
333 328
334 - for (var j = 0; j < word.length; j += 1) {  
335 - final currentLetter = word.codeUnitAt(j); 329 + for (var j = 0; j < word.length; j += 1) {
  330 + final currentLetter = word.codeUnitAt(j);
336 331
337 - if (_isArabicDiacritic(currentLetter)) {  
338 - newWord.insert(0, _arabicDiacritics[currentLetter]!);  
339 - continue; 332 + if (_isArabicDiacritic(currentLetter)) {
  333 + newWord.insert(0, _arabicDiacritics[currentLetter]!);
  334 + continue;
  335 + }
  336 + final nextLetter = word
  337 + .split('')
  338 + .skip(j + 1)
  339 + .map((String e) => e.codeUnitAt(0))
  340 + .firstWhere(
  341 + (int element) => !_isArabicDiacritic(element),
  342 + orElse: () => 0,
  343 + );
  344 +
  345 + if (_isArabicLetter(currentLetter)) {
  346 + isNewWordArabic = true;
  347 +
  348 + final position = _getCorrectForm(currentLetter, prevLetter, nextLetter);
  349 + prevLetter = currentLetter;
  350 + if (position != -1) {
  351 + newWord.insert(0, _arabicSubstitionA[currentLetter][position]);
  352 + } else {
  353 + newWord.add(currentLetter);
340 } 354 }
341 - final nextLetter = word  
342 - .split('')  
343 - .skip(j + 1)  
344 - .map((String e) => e.codeUnitAt(0))  
345 - .firstWhere(  
346 - (int element) => !_isArabicDiacritic(element),  
347 - orElse: () => 0,  
348 - );  
349 -  
350 - if (_isArabicLetter(currentLetter)) {  
351 - isNewWordArabic = true;  
352 -  
353 - final position =  
354 - _getCorrectForm(currentLetter, prevLetter, nextLetter);  
355 - prevLetter = currentLetter;  
356 - if (position != -1) {  
357 - newWord.insert(0, _arabicSubstitionA[currentLetter][position]);  
358 - } else {  
359 - newWord.add(currentLetter);  
360 - } 355 + } else {
  356 + prevLetter = 0;
  357 + if (isNewWordArabic && currentLetter > 32) {
  358 + newWord.insert(0, currentLetter);
361 } else { 359 } else {
362 - prevLetter = 0;  
363 - if (isNewWordArabic && currentLetter > 32) {  
364 - newWord.insert(0, currentLetter);  
365 - } else {  
366 - newWord.add(currentLetter);  
367 - } 360 + newWord.add(currentLetter);
368 } 361 }
369 } 362 }
  363 + }
370 364
371 - if (!first && isNewWordArabic) {  
372 - yield ' ';  
373 - }  
374 - first = false; 365 + if (!first && isNewWordArabic) {
  366 + yield ' ';
  367 + }
  368 + first = false;
375 369
376 - if (isNewWordArabic) {  
377 - isNewWordArabic = false;  
378 - for (var notArabicNewWord in notArabicWords) {  
379 - yield '${String.fromCharCodes(notArabicNewWord)} ';  
380 - }  
381 - notArabicWords.clear();  
382 - yield String.fromCharCodes(_resolveLigatures(newWord));  
383 - } else {  
384 - notArabicWords.insert(0, newWord); 370 + if (isNewWordArabic) {
  371 + isNewWordArabic = false;
  372 + for (var notArabicNewWord in notArabicWords) {
  373 + yield '${String.fromCharCodes(notArabicNewWord)} ';
385 } 374 }
  375 + notArabicWords.clear();
  376 + yield String.fromCharCodes(_resolveLigatures(newWord));
  377 + } else {
  378 + notArabicWords.insert(0, newWord);
386 } 379 }
387 - // if notArabicWords.length != 0, that means all sentence doesn't contain Arabic.  
388 - for (var i = 0; i < notArabicWords.length; i++) {  
389 - yield String.fromCharCodes(notArabicWords[i]);  
390 - if (i != notArabicWords.length - 1) {  
391 - yield ' ';  
392 - } 380 + }
  381 + // if notArabicWords.length != 0, that means all sentence doesn't contain Arabic.
  382 + for (var i = 0; i < notArabicWords.length; i++) {
  383 + yield String.fromCharCodes(notArabicWords[i]);
  384 + if (i != notArabicWords.length - 1) {
  385 + yield ' ';
393 } 386 }
394 } 387 }
  388 +}
395 389
396 - /// Apply Arabic shape substitutions  
397 - static String convert(String input) {  
398 - return List<String>.from(_parse(input)).join('');  
399 - } 390 +/// Apply Arabic shape substitutions
  391 +String convert(String input) {
  392 + return List<String>.from(_parse(input)).join('');
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
@@ -48,7 +48,7 @@ void main() { @@ -48,7 +48,7 @@ void main() {
48 .where((file) => file.path.endsWith('.svg')) 48 .where((file) => file.path.endsWith('.svg'))
49 .map<String>((file) => file.path) 49 .map<String>((file) => file.path)
50 .toList() 50 .toList()
51 - ..sort(); 51 + ..sort();
52 52
53 pdf.addPage( 53 pdf.addPage(
54 MultiPage( 54 MultiPage(
@@ -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 - print('$e\nError loading $name, fallback to Helvetica.'); 71 + assert(() {
  72 + // ignore: avoid_print
  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 - print('Error loading AssetManifest.json $e'); 45 + assert(() {
  46 + // ignore: avoid_print
  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 - print('Error getting printing info: $e'); 155 + assert(() {
  156 + // ignore: avoid_print
  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