David PHAM-VAN

Apply Flutter 2.5 coding style

include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-dynamic: false
errors:
missing_required_param: warning
missing_return: warning
public_member_api_docs: ignore
todo: ignore
constant_identifier_names: ignore
avoid_print: ignore
linter:
rules:
- always_put_control_body_on_new_line
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_field_initializers_in_const_classes
- avoid_slow_async_io
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- directives_ordering
- flutter_style_todos
- no_adjacent_strings_in_list
- omit_local_variable_types
- package_api_docs
- prefer_asserts_in_initializer_lists
- prefer_final_locals
- prefer_foreach
- prefer_if_elements_to_conditional_expressions
- prefer_single_quotes
- public_member_api_docs
- sort_constructors_first
- sort_pub_dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- unnecessary_statements
... ...
... ... @@ -30,6 +30,8 @@ import 'data.dart';
import 'examples.dart';
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
MyAppState createState() {
return MyAppState();
... ... @@ -42,7 +44,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
PrintingInfo? printingInfo;
var _data = CustomData();
var _data = const CustomData();
var _hasData = false;
var _pending = false;
... ... @@ -175,10 +177,10 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
final controller = TextEditingController();
return AlertDialog(
title: Text('Please type your name:'),
contentPadding: EdgeInsets.symmetric(horizontal: 20),
title: const Text('Please type your name:'),
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
content: TextField(
decoration: InputDecoration(hintText: '[your name]'),
decoration: const InputDecoration(hintText: '[your name]'),
controller: controller,
),
actions: [
... ... @@ -188,7 +190,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
Navigator.pop(context, controller.text);
}
},
child: Text('OK'),
child: const Text('OK'),
),
],
);
... ...
... ... @@ -53,7 +53,7 @@ Future<Uint8List> generateCertificate(
fontSize: 25,
),
children: [
pw.TextSpan(text: 'CERTIFICATE '),
const pw.TextSpan(text: 'CERTIFICATE '),
pw.TextSpan(
text: 'of',
style: pw.TextStyle(
... ... @@ -61,7 +61,7 @@ Future<Uint8List> generateCertificate(
fontWeight: pw.FontWeight.normal,
),
),
pw.TextSpan(text: ' ACHIEVEMENT'),
const pw.TextSpan(text: ' ACHIEVEMENT'),
]),
),
pw.Spacer(),
... ... @@ -108,10 +108,10 @@ Future<Uint8List> generateCertificate(
height: 10,
),
pw.Padding(
padding: pw.EdgeInsets.symmetric(horizontal: 10),
padding: const pw.EdgeInsets.symmetric(horizontal: 10),
child: pw.Text(
'Flutter PDF Demo',
style: pw.TextStyle(
style: const pw.TextStyle(
fontSize: 10,
),
),
... ... @@ -138,7 +138,7 @@ Future<Uint8List> generateCertificate(
pw.Flexible(
child: pw.Text(
lorem.paragraph(40),
style: pw.TextStyle(fontSize: 6),
style: const pw.TextStyle(fontSize: 6),
textAlign: pw.TextAlign.justify,
),
),
... ... @@ -161,16 +161,16 @@ Future<Uint8List> generateCertificate(
buildBackground: (context) => pw.FullPage(
ignoreMargins: true,
child: pw.Container(
margin: pw.EdgeInsets.all(10),
margin: const pw.EdgeInsets.all(10),
decoration: pw.BoxDecoration(
border:
pw.Border.all(color: PdfColor.fromInt(0xffe435), width: 1),
border: pw.Border.all(
color: const PdfColor.fromInt(0xffe435), width: 1),
),
child: pw.Container(
margin: pw.EdgeInsets.all(5),
margin: const pw.EdgeInsets.all(5),
decoration: pw.BoxDecoration(
border:
pw.Border.all(color: PdfColor.fromInt(0xffe435), width: 5),
border: pw.Border.all(
color: const PdfColor.fromInt(0xffe435), width: 5),
),
width: double.infinity,
height: double.infinity,
... ... @@ -240,7 +240,7 @@ Future<Uint8List> generateCertificate(
),
),
pw.Padding(
padding: pw.EdgeInsets.only(
padding: const pw.EdgeInsets.only(
top: 120,
left: 80,
right: 80,
... ...
... ... @@ -51,7 +51,7 @@ Future<Uint8List> generateDocument(
),
build: (context) {
return pw.Padding(
padding: pw.EdgeInsets.only(
padding: const pw.EdgeInsets.only(
left: 60,
right: 60,
bottom: 30,
... ... @@ -90,7 +90,7 @@ Future<Uint8List> generateDocument(
destination: 'https://wikipedia.org/wiki/PDF',
child: pw.Text(
'https://wikipedia.org/wiki/PDF',
style: pw.TextStyle(
style: const pw.TextStyle(
color: PdfColors.pink100,
),
),
... ...
... ... @@ -288,7 +288,7 @@ Future<Uint8List> generateReport(
legend: '${data[0]}\n$pct%',
value: value,
color: color,
legendStyle: pw.TextStyle(fontSize: 10),
legendStyle: const pw.TextStyle(fontSize: 10),
);
}),
),
... ...
... ... @@ -19,10 +19,12 @@ import 'package:flutter/material.dart';
import 'app.dart';
void main() {
runApp(App());
runApp(const App());
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
const scrollbarTheme =
... ... @@ -32,7 +34,7 @@ class App extends StatelessWidget {
theme: ThemeData.light().copyWith(scrollbarTheme: scrollbarTheme),
darkTheme: ThemeData.dark().copyWith(scrollbarTheme: scrollbarTheme),
title: 'Flutter PDF Demo',
home: MyApp(),
home: const MyApp(),
);
}
}
... ...
... ... @@ -17,6 +17,7 @@ dependencies:
url_launcher: ^6.0.6
dev_dependencies:
flutter_lints: ^1.0.4
flutter_test:
sdk: flutter
test: ^1.16.5
... ...
... ... @@ -7,7 +7,7 @@ import 'package:printing_demo/examples/document.dart';
void main() {
testWidgets('Pdf Generate the document', (WidgetTester tester) async {
final data = CustomData();
const data = CustomData();
final doc = await generateDocument(PdfPageFormat.a4, data);
final file = File('document.pdf');
... ...
... ... @@ -3,6 +3,7 @@
## 3.6.0
- Fix text justify with multiple paragraphs
- Apply Flutter 2.5 coding style
## 3.5.0
... ...
include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
... ... @@ -8,6 +8,8 @@ analyzer:
missing_return: warning
public_member_api_docs: ignore
todo: ignore
constant_identifier_names: ignore
avoid_print: ignore
linter:
rules:
... ... @@ -15,52 +17,24 @@ linter:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_renaming_method_parameters
- avoid_returning_null_for_void
- avoid_slow_async_io
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- control_flow_in_finally
- directives_ordering
- empty_statements
- flutter_style_todos
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- non_constant_identifier_names
- omit_local_variable_types
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_final_locals
- prefer_foreach
- prefer_if_elements_to_conditional_expressions
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- prefer_single_quotes
- public_member_api_docs
- sort_constructors_first
- sort_pub_dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_null_aware_assignments
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- use_full_hex_values_for_flutter_colors
... ...
... ... @@ -15,7 +15,6 @@
*/
export 'src/pdf/annotation.dart';
export 'src/pdf/arabic.dart';
export 'src/pdf/border.dart';
export 'src/pdf/color.dart';
export 'src/pdf/colors.dart';
... ...
... ... @@ -14,387 +14,380 @@
* limitations under the License.
*/
/// Arabic shape substitutions functions
class PdfArabic {
/// Arabic shape substitutions: char code => (isolated, final, initial, medial).
/// Arabic Substition A
static const Map<int, dynamic> _arabicSubstitionA = <int, dynamic>{
0x0640: <int>[0x0640, 0x0640, 0x0640, 0x0640], // ARABIC TATWEEL
0x0621: <int>[0xFE80], // ARABIC LETTER HAMZA
0x0622: <int>[0xFE81, 0xFE82], // ARABIC LETTER ALEF WITH MADDA ABOVE
0x0623: <int>[0xFE83, 0xFE84], // ARABIC LETTER ALEF WITH HAMZA ABOVE
0x0624: <int>[0xFE85, 0xFE86], // ARABIC LETTER WAW WITH HAMZA ABOVE
0x0625: <int>[0xFE87, 0xFE88], // ARABIC LETTER ALEF WITH HAMZA BELOW
0x0626: <int>[
0xFE89,
0xFE8A,
0xFE8B,
0xFE8C
], // ARABIC LETTER YEH WITH HAMZA ABOVE
0x0627: <int>[0xFE8D, 0xFE8E], // ARABIC LETTER ALEF
0x0628: <int>[0xFE8F, 0xFE90, 0xFE91, 0xFE92], // ARABIC LETTER BEH
0x0629: <int>[0xFE93, 0xFE94], // ARABIC LETTER TEH MARBUTA
0x062A: <int>[0xFE95, 0xFE96, 0xFE97, 0xFE98], // ARABIC LETTER TEH
0x062B: <int>[0xFE99, 0xFE9A, 0xFE9B, 0xFE9C], // ARABIC LETTER THEH
0x062C: <int>[0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0], // ARABIC LETTER JEEM
0x062D: <int>[0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4], // ARABIC LETTER HAH
0x062E: <int>[0xFEA5, 0xFEA6, 0xFEA7, 0xFEA8], // ARABIC LETTER KHAH
0x062F: <int>[0xFEA9, 0xFEAA], // ARABIC LETTER DAL
0x0630: <int>[0xFEAB, 0xFEAC], // ARABIC LETTER THAL
0x0631: <int>[0xFEAD, 0xFEAE], // ARABIC LETTER REH
0x0632: <int>[0xFEAF, 0xFEB0], // ARABIC LETTER ZAIN
0x0633: <int>[0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4], // ARABIC LETTER SEEN
0x0634: <int>[0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8], // ARABIC LETTER SHEEN
0x0635: <int>[0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC], // ARABIC LETTER SAD
0x0636: <int>[0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0], // ARABIC LETTER DAD
0x0637: <int>[0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4], // ARABIC LETTER TAH
0x0638: <int>[0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8], // ARABIC LETTER ZAH
0x0639: <int>[0xFEC9, 0xFECA, 0xFECB, 0xFECC], // ARABIC LETTER AIN
0x063A: <int>[0xFECD, 0xFECE, 0xFECF, 0xFED0], // ARABIC LETTER GHAIN
0x0641: <int>[0xFED1, 0xFED2, 0xFED3, 0xFED4], // ARABIC LETTER FEH
0x0642: <int>[0xFED5, 0xFED6, 0xFED7, 0xFED8], // ARABIC LETTER QAF
0x0643: <int>[0xFED9, 0xFEDA, 0xFEDB, 0xFEDC], // ARABIC LETTER KAF
0x0644: <int>[0xFEDD, 0xFEDE, 0xFEDF, 0xFEE0], // ARABIC LETTER LAM
0x0645: <int>[0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4], // ARABIC LETTER MEEM
0x0646: <int>[0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8], // ARABIC LETTER NOON
0x0647: <int>[0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC], // ARABIC LETTER HEH
0x0648: <int>[0xFEED, 0xFEEE], // ARABIC LETTER WAW
0x0649: <int>[0xFEEF, 0xFEF0, 64488, 64489], // ARABIC LETTER ALEF MAKSURA
0x064A: <int>[0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4], // ARABIC LETTER YEH
0x0671: <int>[0xFB50, 0xFB51], // ARABIC LETTER ALEF WASLA
0x0677: <int>[0xFBDD], // ARABIC LETTER U WITH HAMZA ABOVE
0x0679: <int>[0xFB66, 0xFB67, 0xFB68, 0xFB69], // ARABIC LETTER TTEH
0x067A: <int>[0xFB5E, 0xFB5F, 0xFB60, 0xFB61], // ARABIC LETTER TTEHEH
0x067B: <int>[0xFB52, 0xFB53, 0xFB54, 0xFB55], // ARABIC LETTER BEEH
0x067E: <int>[0xFB56, 0xFB57, 0xFB58, 0xFB59], // ARABIC LETTER PEH
0x067F: <int>[0xFB62, 0xFB63, 0xFB64, 0xFB65], // ARABIC LETTER TEHEH
0x0680: <int>[0xFB5A, 0xFB5B, 0xFB5C, 0xFB5D], // ARABIC LETTER BEHEH
0x0683: <int>[0xFB76, 0xFB77, 0xFB78, 0xFB79], // ARABIC LETTER NYEH
0x0684: <int>[0xFB72, 0xFB73, 0xFB74, 0xFB75], // ARABIC LETTER DYEH
0x0686: <int>[0xFB7A, 0xFB7B, 0xFB7C, 0xFB7D], // ARABIC LETTER TCHEH
0x0687: <int>[0xFB7E, 0xFB7F, 0xFB80, 0xFB81], // ARABIC LETTER TCHEHEH
0x0688: <int>[0xFB88, 0xFB89], // ARABIC LETTER DDAL
0x068C: <int>[0xFB84, 0xFB85], // ARABIC LETTER DAHAL
0x068D: <int>[0xFB82, 0xFB83], // ARABIC LETTER DDAHAL
0x068E: <int>[0xFB86, 0xFB87], // ARABIC LETTER DUL
0x0691: <int>[0xFB8C, 0xFB8D], // ARABIC LETTER RREH
0x0698: <int>[0xFB8A, 0xFB8B], // ARABIC LETTER JEH
0x06A4: <int>[0xFB6A, 0xFB6B, 0xFB6C, 0xFB6D], // ARABIC LETTER VEH
0x06A6: <int>[0xFB6E, 0xFB6F, 0xFB70, 0xFB71], // ARABIC LETTER PEHEH
0x06A9: <int>[0xFB8E, 0xFB8F, 0xFB90, 0xFB91], // ARABIC LETTER KEHEH
0x06AD: <int>[0xFBD3, 0xFBD4, 0xFBD5, 0xFBD6], // ARABIC LETTER NG
0x06AF: <int>[0xFB92, 0xFB93, 0xFB94, 0xFB95], // ARABIC LETTER GAF
0x06B1: <int>[0xFB9A, 0xFB9B, 0xFB9C, 0xFB9D], // ARABIC LETTER NGOEH
0x06B3: <int>[0xFB96, 0xFB97, 0xFB98, 0xFB99], // ARABIC LETTER GUEH
0x06BA: <int>[0xFB9E, 0xFB9F], // ARABIC LETTER NOON GHUNNA
0x06BB: <int>[0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3], // ARABIC LETTER RNOON
0x06BE: <int>[
0xFBAA,
0xFBAB,
0xFBAC,
0xFBAD
], // ARABIC LETTER HEH DOACHASHMEE
0x06C0: <int>[0xFBA4, 0xFBA5], // ARABIC LETTER HEH WITH YEH ABOVE
0x06C1: <int>[0xFBA6, 0xFBA7, 0xFBA8, 0xFBA9], // ARABIC LETTER HEH GOAL
0x06C5: <int>[0xFBE0, 0xFBE1], // ARABIC LETTER KIRGHIZ OE
0x06C6: <int>[0xFBD9, 0xFBDA], // ARABIC LETTER OE
0x06C7: <int>[0xFBD7, 0xFBD8], // ARABIC LETTER U
0x06C8: <int>[0xFBDB, 0xFBDC], // ARABIC LETTER YU
0x06C9: <int>[0xFBE2, 0xFBE3], // ARABIC LETTER KIRGHIZ YU
0x06CB: <int>[0xFBDE, 0xFBDF], // ARABIC LETTER VE
0x06CC: <int>[0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF], // ARABIC LETTER FARSI YEH
0x06D0: <int>[0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7], //ARABIC LETTER E
0x06D2: <int>[0xFBAE, 0xFBAF], // ARABIC LETTER YEH BARREE
0x06D3: <int>[0xFBB0, 0xFBB1], // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE
};
/*
/// Arabic shape substitutions: char code => (isolated, final, initial, medial).
/// Arabic Substition A
const Map<int, dynamic> _arabicSubstitionA = <int, dynamic>{
0x0640: <int>[0x0640, 0x0640, 0x0640, 0x0640], // ARABIC TATWEEL
0x0621: <int>[0xFE80], // ARABIC LETTER HAMZA
0x0622: <int>[0xFE81, 0xFE82], // ARABIC LETTER ALEF WITH MADDA ABOVE
0x0623: <int>[0xFE83, 0xFE84], // ARABIC LETTER ALEF WITH HAMZA ABOVE
0x0624: <int>[0xFE85, 0xFE86], // ARABIC LETTER WAW WITH HAMZA ABOVE
0x0625: <int>[0xFE87, 0xFE88], // ARABIC LETTER ALEF WITH HAMZA BELOW
0x0626: <int>[
0xFE89,
0xFE8A,
0xFE8B,
0xFE8C
], // ARABIC LETTER YEH WITH HAMZA ABOVE
0x0627: <int>[0xFE8D, 0xFE8E], // ARABIC LETTER ALEF
0x0628: <int>[0xFE8F, 0xFE90, 0xFE91, 0xFE92], // ARABIC LETTER BEH
0x0629: <int>[0xFE93, 0xFE94], // ARABIC LETTER TEH MARBUTA
0x062A: <int>[0xFE95, 0xFE96, 0xFE97, 0xFE98], // ARABIC LETTER TEH
0x062B: <int>[0xFE99, 0xFE9A, 0xFE9B, 0xFE9C], // ARABIC LETTER THEH
0x062C: <int>[0xFE9D, 0xFE9E, 0xFE9F, 0xFEA0], // ARABIC LETTER JEEM
0x062D: <int>[0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4], // ARABIC LETTER HAH
0x062E: <int>[0xFEA5, 0xFEA6, 0xFEA7, 0xFEA8], // ARABIC LETTER KHAH
0x062F: <int>[0xFEA9, 0xFEAA], // ARABIC LETTER DAL
0x0630: <int>[0xFEAB, 0xFEAC], // ARABIC LETTER THAL
0x0631: <int>[0xFEAD, 0xFEAE], // ARABIC LETTER REH
0x0632: <int>[0xFEAF, 0xFEB0], // ARABIC LETTER ZAIN
0x0633: <int>[0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4], // ARABIC LETTER SEEN
0x0634: <int>[0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8], // ARABIC LETTER SHEEN
0x0635: <int>[0xFEB9, 0xFEBA, 0xFEBB, 0xFEBC], // ARABIC LETTER SAD
0x0636: <int>[0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0], // ARABIC LETTER DAD
0x0637: <int>[0xFEC1, 0xFEC2, 0xFEC3, 0xFEC4], // ARABIC LETTER TAH
0x0638: <int>[0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8], // ARABIC LETTER ZAH
0x0639: <int>[0xFEC9, 0xFECA, 0xFECB, 0xFECC], // ARABIC LETTER AIN
0x063A: <int>[0xFECD, 0xFECE, 0xFECF, 0xFED0], // ARABIC LETTER GHAIN
0x0641: <int>[0xFED1, 0xFED2, 0xFED3, 0xFED4], // ARABIC LETTER FEH
0x0642: <int>[0xFED5, 0xFED6, 0xFED7, 0xFED8], // ARABIC LETTER QAF
0x0643: <int>[0xFED9, 0xFEDA, 0xFEDB, 0xFEDC], // ARABIC LETTER KAF
0x0644: <int>[0xFEDD, 0xFEDE, 0xFEDF, 0xFEE0], // ARABIC LETTER LAM
0x0645: <int>[0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4], // ARABIC LETTER MEEM
0x0646: <int>[0xFEE5, 0xFEE6, 0xFEE7, 0xFEE8], // ARABIC LETTER NOON
0x0647: <int>[0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC], // ARABIC LETTER HEH
0x0648: <int>[0xFEED, 0xFEEE], // ARABIC LETTER WAW
0x0649: <int>[0xFEEF, 0xFEF0, 64488, 64489], // ARABIC LETTER ALEF MAKSURA
0x064A: <int>[0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4], // ARABIC LETTER YEH
0x0671: <int>[0xFB50, 0xFB51], // ARABIC LETTER ALEF WASLA
0x0677: <int>[0xFBDD], // ARABIC LETTER U WITH HAMZA ABOVE
0x0679: <int>[0xFB66, 0xFB67, 0xFB68, 0xFB69], // ARABIC LETTER TTEH
0x067A: <int>[0xFB5E, 0xFB5F, 0xFB60, 0xFB61], // ARABIC LETTER TTEHEH
0x067B: <int>[0xFB52, 0xFB53, 0xFB54, 0xFB55], // ARABIC LETTER BEEH
0x067E: <int>[0xFB56, 0xFB57, 0xFB58, 0xFB59], // ARABIC LETTER PEH
0x067F: <int>[0xFB62, 0xFB63, 0xFB64, 0xFB65], // ARABIC LETTER TEHEH
0x0680: <int>[0xFB5A, 0xFB5B, 0xFB5C, 0xFB5D], // ARABIC LETTER BEHEH
0x0683: <int>[0xFB76, 0xFB77, 0xFB78, 0xFB79], // ARABIC LETTER NYEH
0x0684: <int>[0xFB72, 0xFB73, 0xFB74, 0xFB75], // ARABIC LETTER DYEH
0x0686: <int>[0xFB7A, 0xFB7B, 0xFB7C, 0xFB7D], // ARABIC LETTER TCHEH
0x0687: <int>[0xFB7E, 0xFB7F, 0xFB80, 0xFB81], // ARABIC LETTER TCHEHEH
0x0688: <int>[0xFB88, 0xFB89], // ARABIC LETTER DDAL
0x068C: <int>[0xFB84, 0xFB85], // ARABIC LETTER DAHAL
0x068D: <int>[0xFB82, 0xFB83], // ARABIC LETTER DDAHAL
0x068E: <int>[0xFB86, 0xFB87], // ARABIC LETTER DUL
0x0691: <int>[0xFB8C, 0xFB8D], // ARABIC LETTER RREH
0x0698: <int>[0xFB8A, 0xFB8B], // ARABIC LETTER JEH
0x06A4: <int>[0xFB6A, 0xFB6B, 0xFB6C, 0xFB6D], // ARABIC LETTER VEH
0x06A6: <int>[0xFB6E, 0xFB6F, 0xFB70, 0xFB71], // ARABIC LETTER PEHEH
0x06A9: <int>[0xFB8E, 0xFB8F, 0xFB90, 0xFB91], // ARABIC LETTER KEHEH
0x06AD: <int>[0xFBD3, 0xFBD4, 0xFBD5, 0xFBD6], // ARABIC LETTER NG
0x06AF: <int>[0xFB92, 0xFB93, 0xFB94, 0xFB95], // ARABIC LETTER GAF
0x06B1: <int>[0xFB9A, 0xFB9B, 0xFB9C, 0xFB9D], // ARABIC LETTER NGOEH
0x06B3: <int>[0xFB96, 0xFB97, 0xFB98, 0xFB99], // ARABIC LETTER GUEH
0x06BA: <int>[0xFB9E, 0xFB9F], // ARABIC LETTER NOON GHUNNA
0x06BB: <int>[0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3], // ARABIC LETTER RNOON
0x06BE: <int>[
0xFBAA,
0xFBAB,
0xFBAC,
0xFBAD
], // ARABIC LETTER HEH DOACHASHMEE
0x06C0: <int>[0xFBA4, 0xFBA5], // ARABIC LETTER HEH WITH YEH ABOVE
0x06C1: <int>[0xFBA6, 0xFBA7, 0xFBA8, 0xFBA9], // ARABIC LETTER HEH GOAL
0x06C5: <int>[0xFBE0, 0xFBE1], // ARABIC LETTER KIRGHIZ OE
0x06C6: <int>[0xFBD9, 0xFBDA], // ARABIC LETTER OE
0x06C7: <int>[0xFBD7, 0xFBD8], // ARABIC LETTER U
0x06C8: <int>[0xFBDB, 0xFBDC], // ARABIC LETTER YU
0x06C9: <int>[0xFBE2, 0xFBE3], // ARABIC LETTER KIRGHIZ YU
0x06CB: <int>[0xFBDE, 0xFBDF], // ARABIC LETTER VE
0x06CC: <int>[0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF], // ARABIC LETTER FARSI YEH
0x06D0: <int>[0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7], //ARABIC LETTER E
0x06D2: <int>[0xFBAE, 0xFBAF], // ARABIC LETTER YEH BARREE
0x06D3: <int>[0xFBB0, 0xFBB1], // ARABIC LETTER YEH BARREE WITH HAMZA ABOVE
};
/*
var ligaturesSubstitutionA = {
0xFBEA: []// ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF ISOLATED FORM
};
*/
static const Map<int, dynamic> _diacriticLigatures = <int, dynamic>{
0x0651: <int, int>{
0x064C: 0xFC5E, // Shadda + Dammatan
0x064D: 0xFC5F, // Shadda + Kasratan
0x064E: 0xFC60, // Shadda + Fatha
0x064F: 0xFC61, // Shadda + Damma
0x0650: 0xFC62, // Shadda + Kasra
0x0670: 0xFC63, // Shadda + Dagger alif
},
};
static const Map<int, dynamic> _ligatures = <int, dynamic>{
0xFEDF: <int, int>{
0xFE82:
0xFEF5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
0xFE84:
0xFEF7, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
0xFE88:
0xFEF9, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM
0xFE8E: 0xFEFB // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
},
0xFEE0: <int, int>{
0xFE82:
0xFEF6, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
0xFE84:
0xFEF8, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
0xFE88:
0xFEFA, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM
0xFE8E: 0xFEFC // ARABIC LIGATURE LAM WITH ALEF FINAL FORM
},
const Map<int, dynamic> _diacriticLigatures = <int, dynamic>{
0x0651: <int, int>{
0x064C: 0xFC5E, // Shadda + Dammatan
0x064D: 0xFC5F, // Shadda + Kasratan
0x064E: 0xFC60, // Shadda + Fatha
0x064F: 0xFC61, // Shadda + Damma
0x0650: 0xFC62, // Shadda + Kasra
0x0670: 0xFC63, // Shadda + Dagger alif
},
};
const Map<int, dynamic> _ligatures = <int, dynamic>{
0xFEDF: <int, int>{
0xFE82:
0xFEF5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
0xFE84:
0xFEF7, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
0xFE88:
0xFEF9, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM
0xFE8E: 0xFEFB // ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
},
0xFEE0: <int, int>{
0xFE82: 0xFEF6, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
0xFE84: 0xFEF8, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
0xFE88: 0xFEFA, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM
0xFE8E: 0xFEFC // ARABIC LIGATURE LAM WITH ALEF FINAL FORM
},
// 0xFE8D: <int, dynamic>{
// 0xFEDF: <int, dynamic>{
// 0xFEE0: <int, int>{0xFEEA: 0xFDF2}
// }
// }, // ALLAH
};
static const List<int> _alfletter = <int>[1570, 1571, 1573, 1575];
static const Map<int, int> _arabicDiacritics = <int, int>{
0x064B: 0x064B, // Fathatan
0x064C: 0x064C, // Dammatan
0x064D: 0x064D, // Kasratan
0x064E: 0x064E, // Fatha
0x064F: 0x064F, // Damma
0x0650: 0x0650, // Kasra
0x0651: 0x0651, // Shadda
0x0652: 0x0652, // Sukun
0x0670: 0x0670, // Dagger alif
0xFC5E: 0xFC5E, // Shadda + Dammatan
0xFC5F: 0xFC5F, // Shadda + Kasratan
0xFC60: 0xFC60, // Shadda + Fatha
0xFC61: 0xFC61, // Shadda + Damma
0xFC62: 0xFC62, // Shadda + Kasra
0xFC63: 0xFC63, // Shadda + Dagger alif
// 1548: 1548,
};
static const int _noChangeInForm = -1;
static const int _isolatedForm = 0;
static const int _finalForm = 1;
static const int _initialForm = 2;
static const int _medialForm = 3;
static bool _isInArabicSubstitutionA(int letter) {
return _arabicSubstitionA.containsKey(letter);
}
};
const List<int> _alfletter = <int>[1570, 1571, 1573, 1575];
const Map<int, int> _arabicDiacritics = <int, int>{
0x064B: 0x064B, // Fathatan
0x064C: 0x064C, // Dammatan
0x064D: 0x064D, // Kasratan
0x064E: 0x064E, // Fatha
0x064F: 0x064F, // Damma
0x0650: 0x0650, // Kasra
0x0651: 0x0651, // Shadda
0x0652: 0x0652, // Sukun
0x0670: 0x0670, // Dagger alif
0xFC5E: 0xFC5E, // Shadda + Dammatan
0xFC5F: 0xFC5F, // Shadda + Kasratan
0xFC60: 0xFC60, // Shadda + Fatha
0xFC61: 0xFC61, // Shadda + Damma
0xFC62: 0xFC62, // Shadda + Kasra
0xFC63: 0xFC63, // Shadda + Dagger alif
// 1548: 1548,
};
const int _noChangeInForm = -1;
const int _isolatedForm = 0;
const int _finalForm = 1;
const int _initialForm = 2;
const int _medialForm = 3;
bool _isInArabicSubstitutionA(int letter) {
return _arabicSubstitionA.containsKey(letter);
}
static bool _isArabicLetter(int letter) {
return (letter >= 0x0600 && letter <= 0x06FF) ||
(letter >= 0x0750 && letter <= 0x077F) ||
(letter >= 0x08FF && letter <= 0xFB50) ||
(letter >= 0xFDFF && letter <= 0xFEFF);
}
bool _isArabicLetter(int letter) {
return (letter >= 0x0600 && letter <= 0x06FF) ||
(letter >= 0x0750 && letter <= 0x077F) ||
(letter >= 0x08FF && letter <= 0xFB50) ||
(letter >= 0xFDFF && letter <= 0xFEFF);
}
static bool _isArabicEndLetter(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
_arabicSubstitionA[letter].length <= 2;
}
bool _isArabicEndLetter(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
_arabicSubstitionA[letter].length <= 2;
}
static bool _isArabicAlfLetter(int letter) {
return _isArabicLetter(letter) && _alfletter.contains(letter);
}
bool _isArabicAlfLetter(int letter) {
return _isArabicLetter(letter) && _alfletter.contains(letter);
}
static bool _arabicLetterHasFinalForm(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
(_arabicSubstitionA[letter].length >= 2);
}
bool _arabicLetterHasFinalForm(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
(_arabicSubstitionA[letter].length >= 2);
}
static bool _arabicLetterHasMedialForm(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
_arabicSubstitionA[letter].length == 4;
}
bool _arabicLetterHasMedialForm(int letter) {
return _isArabicLetter(letter) &&
_isInArabicSubstitutionA(letter) &&
_arabicSubstitionA[letter].length == 4;
}
static bool _isArabicDiacritic(int letter) {
return _arabicDiacritics.containsKey(letter);
}
bool _isArabicDiacritic(int letter) {
return _arabicDiacritics.containsKey(letter);
}
static bool isArabicDiacriticValue(int letter) {
return _arabicDiacritics.containsValue(letter);
}
bool isArabicDiacriticValue(int letter) {
return _arabicDiacritics.containsValue(letter);
}
static List<int> _resolveLigatures(List<int> lettersq) {
final result = <int>[];
dynamic tmpLigatures = _ligatures;
dynamic tmpDiacritic = _diacriticLigatures;
final letters = lettersq.reversed.toList();
List<int> _resolveLigatures(List<int> lettersq) {
final result = <int>[];
dynamic tmpLigatures = _ligatures;
dynamic tmpDiacritic = _diacriticLigatures;
final letters = lettersq.reversed.toList();
final effectedLetters = <int>[];
final effectedDiacritics = <int>[];
final effectedLetters = <int>[];
final effectedDiacritics = <int>[];
final finalDiacritics = <int>[];
final finalDiacritics = <int>[];
for (var i = 0; i < letters.length; i++) {
if (isArabicDiacriticValue(letters[i])) {
effectedDiacritics.insert(0, letters[i]);
if (tmpDiacritic.containsKey(letters[i])) {
tmpDiacritic = tmpDiacritic[letters[i]];
for (var i = 0; i < letters.length; i++) {
if (isArabicDiacriticValue(letters[i])) {
effectedDiacritics.insert(0, letters[i]);
if (tmpDiacritic.containsKey(letters[i])) {
tmpDiacritic = tmpDiacritic[letters[i]];
if (tmpDiacritic is int) {
finalDiacritics.insert(0, tmpDiacritic);
tmpDiacritic = _diacriticLigatures;
effectedDiacritics.clear();
}
} else {
if (tmpDiacritic is int) {
finalDiacritics.insert(0, tmpDiacritic);
tmpDiacritic = _diacriticLigatures;
// add all Diacritics if there is no letter Ligatures.
if (effectedLetters.isEmpty) {
result.insertAll(0, finalDiacritics);
result.insertAll(0, effectedDiacritics);
finalDiacritics.clear();
effectedDiacritics.clear();
}
}
} else if (tmpLigatures.containsKey(letters[i])) {
effectedLetters.insert(0, letters[i]);
tmpLigatures = tmpLigatures[letters[i]];
if (tmpLigatures is int) {
result.insert(0, tmpLigatures);
tmpLigatures = _ligatures;
effectedLetters.clear();
effectedDiacritics.clear();
}
} else {
tmpLigatures = _ligatures;
// add effected letters if they aren't ligature.
if (effectedLetters.isNotEmpty) {
result.insertAll(0, effectedLetters);
effectedLetters.clear();
}
tmpDiacritic = _diacriticLigatures;
// add Diacritics after or before letter ligature.
if (effectedLetters.isEmpty && effectedDiacritics.isNotEmpty) {
// add all Diacritics if there is no letter Ligatures.
if (effectedLetters.isEmpty) {
result.insertAll(0, finalDiacritics);
result.insertAll(0, effectedDiacritics);
finalDiacritics.clear();
effectedDiacritics.clear();
}
}
} else if (tmpLigatures.containsKey(letters[i])) {
effectedLetters.insert(0, letters[i]);
tmpLigatures = tmpLigatures[letters[i]];
result.insert(0, letters[i]);
if (tmpLigatures is int) {
result.insert(0, tmpLigatures);
tmpLigatures = _ligatures;
effectedLetters.clear();
}
} else {
tmpLigatures = _ligatures;
// add Diacritic ligatures.
if (effectedLetters.isEmpty && finalDiacritics.isNotEmpty) {
result.insertAll(0, finalDiacritics);
finalDiacritics.clear();
// add effected letters if they aren't ligature.
if (effectedLetters.isNotEmpty) {
result.insertAll(0, effectedLetters);
effectedLetters.clear();
}
}
return result;
}
// add Diacritics after or before letter ligature.
if (effectedLetters.isEmpty && effectedDiacritics.isNotEmpty) {
result.insertAll(0, effectedDiacritics);
effectedDiacritics.clear();
}
static int _getCorrectForm(int currentChar, int beforeChar, int nextChar) {
if (_isInArabicSubstitutionA(currentChar) == false) {
return _noChangeInForm;
}
if (!_arabicLetterHasFinalForm(currentChar) ||
(!_isArabicLetter(beforeChar) && !_isArabicLetter(nextChar)) ||
(!_isArabicLetter(nextChar) && _isArabicEndLetter(beforeChar)) ||
(_isArabicEndLetter(currentChar) && !_isArabicLetter(beforeChar)) ||
(_isArabicEndLetter(currentChar) && _isArabicAlfLetter(beforeChar)) ||
(_isArabicEndLetter(currentChar) && _isArabicEndLetter(beforeChar))) {
return _isolatedForm;
result.insert(0, letters[i]);
}
if (_arabicLetterHasMedialForm(currentChar) &&
_isArabicLetter(beforeChar) &&
!_isArabicEndLetter(beforeChar) &&
_isArabicLetter(nextChar) &&
_arabicLetterHasFinalForm(nextChar)) {
return _medialForm;
// add Diacritic ligatures.
if (effectedLetters.isEmpty && finalDiacritics.isNotEmpty) {
result.insertAll(0, finalDiacritics);
finalDiacritics.clear();
}
}
if (_isArabicEndLetter(currentChar) || (!_isArabicLetter(nextChar))) {
return _finalForm;
}
return _initialForm;
return result;
}
int _getCorrectForm(int currentChar, int beforeChar, int nextChar) {
if (_isInArabicSubstitutionA(currentChar) == false) {
return _noChangeInForm;
}
if (!_arabicLetterHasFinalForm(currentChar) ||
(!_isArabicLetter(beforeChar) && !_isArabicLetter(nextChar)) ||
(!_isArabicLetter(nextChar) && _isArabicEndLetter(beforeChar)) ||
(_isArabicEndLetter(currentChar) && !_isArabicLetter(beforeChar)) ||
(_isArabicEndLetter(currentChar) && _isArabicAlfLetter(beforeChar)) ||
(_isArabicEndLetter(currentChar) && _isArabicEndLetter(beforeChar))) {
return _isolatedForm;
}
if (_arabicLetterHasMedialForm(currentChar) &&
_isArabicLetter(beforeChar) &&
!_isArabicEndLetter(beforeChar) &&
_isArabicLetter(nextChar) &&
_arabicLetterHasFinalForm(nextChar)) {
return _medialForm;
}
if (_isArabicEndLetter(currentChar) || (!_isArabicLetter(nextChar))) {
return _finalForm;
}
return _initialForm;
}
static Iterable<String> _parse(String text) sync* {
final words = text.split(' ');
Iterable<String> _parse(String text) sync* {
final words = text.split(' ');
final notArabicWords = <List<int>>[];
final notArabicWords = <List<int>>[];
var first = true;
for (var word in words) {
final newWord = <int>[];
var isNewWordArabic = false;
var first = true;
for (var word in words) {
final newWord = <int>[];
var isNewWordArabic = false;
var prevLetter = 0;
var prevLetter = 0;
for (var j = 0; j < word.length; j += 1) {
final currentLetter = word.codeUnitAt(j);
for (var j = 0; j < word.length; j += 1) {
final currentLetter = word.codeUnitAt(j);
if (_isArabicDiacritic(currentLetter)) {
newWord.insert(0, _arabicDiacritics[currentLetter]!);
continue;
if (_isArabicDiacritic(currentLetter)) {
newWord.insert(0, _arabicDiacritics[currentLetter]!);
continue;
}
final nextLetter = word
.split('')
.skip(j + 1)
.map((String e) => e.codeUnitAt(0))
.firstWhere(
(int element) => !_isArabicDiacritic(element),
orElse: () => 0,
);
if (_isArabicLetter(currentLetter)) {
isNewWordArabic = true;
final position = _getCorrectForm(currentLetter, prevLetter, nextLetter);
prevLetter = currentLetter;
if (position != -1) {
newWord.insert(0, _arabicSubstitionA[currentLetter][position]);
} else {
newWord.add(currentLetter);
}
final nextLetter = word
.split('')
.skip(j + 1)
.map((String e) => e.codeUnitAt(0))
.firstWhere(
(int element) => !_isArabicDiacritic(element),
orElse: () => 0,
);
if (_isArabicLetter(currentLetter)) {
isNewWordArabic = true;
final position =
_getCorrectForm(currentLetter, prevLetter, nextLetter);
prevLetter = currentLetter;
if (position != -1) {
newWord.insert(0, _arabicSubstitionA[currentLetter][position]);
} else {
newWord.add(currentLetter);
}
} else {
prevLetter = 0;
if (isNewWordArabic && currentLetter > 32) {
newWord.insert(0, currentLetter);
} else {
prevLetter = 0;
if (isNewWordArabic && currentLetter > 32) {
newWord.insert(0, currentLetter);
} else {
newWord.add(currentLetter);
}
newWord.add(currentLetter);
}
}
}
if (!first && isNewWordArabic) {
yield ' ';
}
first = false;
if (!first && isNewWordArabic) {
yield ' ';
}
first = false;
if (isNewWordArabic) {
isNewWordArabic = false;
for (var notArabicNewWord in notArabicWords) {
yield '${String.fromCharCodes(notArabicNewWord)} ';
}
notArabicWords.clear();
yield String.fromCharCodes(_resolveLigatures(newWord));
} else {
notArabicWords.insert(0, newWord);
if (isNewWordArabic) {
isNewWordArabic = false;
for (var notArabicNewWord in notArabicWords) {
yield '${String.fromCharCodes(notArabicNewWord)} ';
}
notArabicWords.clear();
yield String.fromCharCodes(_resolveLigatures(newWord));
} else {
notArabicWords.insert(0, newWord);
}
// if notArabicWords.length != 0, that means all sentence doesn't contain Arabic.
for (var i = 0; i < notArabicWords.length; i++) {
yield String.fromCharCodes(notArabicWords[i]);
if (i != notArabicWords.length - 1) {
yield ' ';
}
}
// if notArabicWords.length != 0, that means all sentence doesn't contain Arabic.
for (var i = 0; i < notArabicWords.length; i++) {
yield String.fromCharCodes(notArabicWords[i]);
if (i != notArabicWords.length - 1) {
yield ' ';
}
}
}
/// Apply Arabic shape substitutions
static String convert(String input) {
return List<String>.from(_parse(input)).join('');
}
/// Apply Arabic shape substitutions
String convert(String input) {
return List<String>.from(_parse(input)).join('');
}
... ...
... ... @@ -49,7 +49,7 @@ class PdfCatalog extends PdfObjectDict {
final PdfNames names;
/// These map the page modes just defined to the pagemodes setting of Pdf.
static const List<String> _PdfPageModes = <String>[
static const List<String> _pdfPageModes = <String>[
'/UseNone',
'/UseOutlines',
'/UseThumbs',
... ... @@ -78,7 +78,7 @@ class PdfCatalog extends PdfObjectDict {
params['/Names'] = names.ref();
// the /PageMode setting
params['/PageMode'] = PdfName(_PdfPageModes[pageMode.index]);
params['/PageMode'] = PdfName(_pdfPageModes[pageMode.index]);
if (pdfDocument.sign != null) {
if (pdfDocument.sign!.value.hasMDP) {
... ...
... ... @@ -199,10 +199,10 @@ class PdfString extends PdfDataType {
final encoding = <int>[];
final add = (int unit) {
void add(int unit) {
encoding.add((unit & UNICODE_BYTE_ONE_MASK) >> 8);
encoding.add(unit & UNICODE_BYTE_ZERO_MASK);
};
}
for (var unit in str.codeUnits) {
if ((unit >= 0 && unit < UNICODE_UTF16_RESERVED_LO) ||
... ...
... ... @@ -139,7 +139,7 @@ class PdfGraphicState {
@override
bool operator ==(dynamic other) {
if (!(other is PdfGraphicState)) {
if (other is! PdfGraphicState) {
return false;
}
return other.fillOpacity == fillOpacity &&
... ...
... ... @@ -17,7 +17,7 @@
import 'dart:convert';
import 'dart:typed_data';
import 'arabic.dart';
import 'arabic.dart' as arabic;
import 'array.dart';
import 'data_types.dart';
import 'document.dart';
... ... @@ -74,7 +74,7 @@ class PdfTtfFont extends PdfFont {
return PdfFontMetrics.zero;
}
if (PdfArabic.isArabicDiacriticValue(charCode)) {
if (arabic.isArabicDiacriticValue(charCode)) {
final metric = font.glyphInfoMap[g] ?? PdfFontMetrics.zero;
return metric.copyWith(advanceWidth: 0);
}
... ...
... ... @@ -33,6 +33,7 @@ class PdfType1Font extends PdfFont {
PdfType1Font.create(PdfDocument pdfDocument, this.fontName, this.ascent,
this.descent, this.widths)
: assert(() {
// ignore: avoid_print
print(
'$fontName has no Unicode support see https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management');
return true;
... ...
... ... @@ -101,5 +101,5 @@ class SvgTransform {
static const none = SvgTransform(null);
static final _transformRegExp =
RegExp('(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)\s*');
RegExp(r'(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)\s*');
}
... ...
... ... @@ -148,7 +148,7 @@ class Stack extends MultiChildWidget {
}
for (var child in children) {
if (!(child is Positioned)) {
if (child is! Positioned) {
hasNonPositionedChildren = true;
child.layout(context, nonPositionedConstraints, parentUsesSize: true);
... ... @@ -169,7 +169,7 @@ class Stack extends MultiChildWidget {
}
for (var child in children) {
if (!(child is Positioned)) {
if (child is! Positioned) {
child.box = PdfRect.fromPoints(
alignment.inscribe(child.box!.size, box!).offset, child.box!.size);
} else {
... ...
... ... @@ -18,6 +18,7 @@ import 'dart:math' as math;
import 'package:meta/meta.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/src/pdf/arabic.dart' as arabic;
import 'annotations.dart';
import 'document.dart';
... ... @@ -682,7 +683,7 @@ class RichText extends Widget with SpanningWidget {
font.stringMetrics(' ') * (style.fontSize! * textScaleFactor);
final spanLines = (_textDirection == TextDirection.rtl
? PdfArabic.convert(span.text!)
? arabic.convert(span.text!)
: span.text)!
.split('\n');
... ...
name: pdf
author: David PHAM-VAN <dev.nfet.net@gmail.com>
description: A pdf producer for Dart. It can create pdf files for both web or flutter.
homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository: https://github.com/DavBfr/dart_pdf
... ... @@ -20,5 +19,5 @@ dependencies:
xml: ^5.1.0
dev_dependencies:
pedantic: ^1.11.0
flutter_lints: ^1.0.4
test: ^1.16.0
... ...
... ... @@ -16,7 +16,7 @@
import 'dart:io';
import 'package:pdf/pdf.dart';
import 'package:pdf/src/pdf/arabic.dart' as arabic;
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
... ... @@ -51,11 +51,11 @@ void main() {
<int>[1612, 65249, 1618, 1614, 65276, 1614, 65204, 65247, 65165]);
expect(
PdfArabic.convert(a.original).codeUnits,
arabic.convert(a.original).codeUnits,
equals(a.reshaped),
);
expect(
PdfArabic.convert(b.original).codeUnits,
arabic.convert(b.original).codeUnits,
equals(b.reshaped),
);
});
... ... @@ -453,7 +453,7 @@ void main() {
for (var item in cases) {
try {
expect(
PdfArabic.convert(item.original).codeUnits,
arabic.convert(item.original).codeUnits,
equals(item.reshaped),
);
} catch (e) {
... ...
... ... @@ -105,7 +105,8 @@ class ColorWheel extends Widget {
large: false, sweep: true)
..lineTo(endBottom.x, endBottom.y)
..bezierArc(endBottom.x, endBottom.y, radius2, radius2, startBottom.x,
startBottom.y, large: false)
startBottom.y,
large: false)
..lineTo(startTop.x, startTop.y)
..fillPath()
..moveTo(startTop.x, startTop.y)
... ...
... ... @@ -16,9 +16,9 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -16,9 +16,9 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -16,9 +16,9 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -16,9 +16,9 @@
import 'dart:io';
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -48,7 +48,7 @@ void main() {
.where((file) => file.path.endsWith('.svg'))
.map<String>((file) => file.path)
.toList()
..sort();
..sort();
pdf.addPage(
MultiPage(
... ...
... ... @@ -55,7 +55,7 @@ List<TableRow> buildTable(
height: Theme.of(context).tableCell.fontSize),
Container(
margin: const EdgeInsets.all(5),
child: Text('${color.toHex()}', style: Theme.of(context).tableCell)),
child: Text(color.toHex(), style: Theme.of(context).tableCell)),
];
rows.add(TableRow(children: tableRow));
}
... ...
... ... @@ -220,7 +220,7 @@ void main() {
for (var word in para.split(' ')) {
spans.add(
TextSpan(
text: '$word',
text: word,
style: TextStyle(
font: ttf,
fontSize: rnd.nextDouble() * 20 + 20,
... ...
... ... @@ -17,9 +17,9 @@
import 'dart:io';
import 'dart:math' as math;
import 'package:test/test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'package:test/test.dart';
late Document pdf;
... ...
... ... @@ -8,6 +8,7 @@
- Fix pdfium memory leak
- Fix error while loading shared libraries on Linux
- Update pdfium library to 4627
- Apply Flutter 2.5 coding style
## 5.5.0
... ...
include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
... ... @@ -6,8 +6,10 @@ analyzer:
errors:
missing_required_param: warning
missing_return: warning
public_member_api_docs: warning
public_member_api_docs: ignore
todo: ignore
constant_identifier_names: ignore
avoid_print: ignore
linter:
rules:
... ... @@ -15,52 +17,24 @@ linter:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_renaming_method_parameters
- avoid_returning_null_for_void
- avoid_slow_async_io
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- control_flow_in_finally
- directives_ordering
- empty_statements
- flutter_style_todos
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- non_constant_identifier_names
- omit_local_variable_types
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_final_locals
- prefer_foreach
- prefer_if_elements_to_conditional_expressions
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- prefer_single_quotes
- public_member_api_docs
- sort_constructors_first
- sort_pub_dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_null_aware_assignments
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- use_full_hex_values_for_flutter_colors
... ...
... ... @@ -152,7 +152,11 @@ class PrintingPlugin extends PrintingPlatform {
stopWatch.stop();
completer.complete(true);
} catch (e) {
print(e);
assert(() {
// ignore: avoid_print
print('Error: $e');
return true;
}());
completer.complete(_getPdf(result));
}
});
... ...
... ... @@ -50,7 +50,7 @@ Future<ImageProvider> flutterImageProvider(
stream.removeListener(listener);
}, onError: (dynamic exception, StackTrace? stackTrace) {
if (!completer.isCompleted) {
completer.complete(null);
completer.completeError('image failed to load');
}
if (onError != null) {
onError(exception, stackTrace);
... ...
... ... @@ -68,7 +68,12 @@ class DownloadbleFont {
protect: protect,
);
} catch (e) {
print('$e\nError loading $name, fallback to Helvetica.');
assert(() {
// ignore: avoid_print
print('$e\nError loading $name, fallback to Helvetica.');
return true;
}());
return Font.helvetica();
}
}
... ...
... ... @@ -42,7 +42,12 @@ mixin AssetManifest {
final jsonData = json.decode(jsonString) as Map<String, dynamic>;
_assets.addAll(jsonData.keys);
} catch (e) {
print('Error loading AssetManifest.json $e');
assert(() {
// ignore: avoid_print
print('Error loading AssetManifest.json $e');
return true;
}());
rootBundle.evict('AssetManifest.json');
_failed = true;
_ready = true;
... ...
... ... @@ -152,7 +152,12 @@ class MethodChannelPrinting extends PrintingPlatform {
<String, dynamic>{},
);
} catch (e) {
print('Error getting printing info: $e');
assert(() {
// ignore: avoid_print
print('Error getting printing info: $e');
return true;
}());
return PrintingInfo.unavailable;
}
... ...
... ... @@ -24,6 +24,7 @@ import 'dart:typed_data';
import 'package:js/js.dart';
// ignore: avoid_classes_with_only_static_members
@JS('pdfjsLib')
class PdfJs {
external static PdfJsDocLoader getDocument(Settings data);
... ...
name: printing
author: David PHAM-VAN <dev.nfet.net@gmail.com>
description: >
Plugin that allows Flutter apps to generate and print documents to
compatible printers on Android, iOS, macOS, Windows, and Linux,
... ... @@ -27,6 +26,7 @@ dependencies:
plugin_platform_interface: ^2.0.0
dev_dependencies:
flutter_lints: ^1.0.4
flutter_test:
sdk: flutter
mockito: ^5.0.0
... ...
... ... @@ -32,6 +32,7 @@ void main() {
setUp(() {
channel.setMockMethodCallHandler((MethodCall methodCall) async {
// ignore: avoid_print
print(methodCall);
return '1';
});
... ...
name: readme_to_dart
author: David PHAM-VAN <dev.nfet.net@gmail.com>
description: Readme Markdown to dart source converter.
homepage: https://github.com/DavBfr/dart_pdf/tree/master/test
repository: https://github.com/DavBfr/dart_pdf
... ...