Showing
4 changed files
with
20 additions
and
18 deletions
@@ -117,7 +117,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { | @@ -117,7 +117,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { | ||
117 | 117 | ||
118 | final appDocDir = await getApplicationDocumentsDirectory(); | 118 | final appDocDir = await getApplicationDocumentsDirectory(); |
119 | final appDocPath = appDocDir.path; | 119 | final appDocPath = appDocDir.path; |
120 | - final file = File(appDocPath + '/' + 'document.pdf'); | 120 | + final file = File('$appDocPath/document.pdf'); |
121 | print('Save as file ${file.path} ...'); | 121 | print('Save as file ${file.path} ...'); |
122 | await file.writeAsBytes(bytes); | 122 | await file.writeAsBytes(bytes); |
123 | await OpenFile.open(file.path); | 123 | await OpenFile.open(file.path); |
@@ -93,7 +93,7 @@ class Calendar extends StatelessWidget { | @@ -93,7 +93,7 @@ class Calendar extends StatelessWidget { | ||
93 | } | 93 | } |
94 | 94 | ||
95 | if (date.day == 1) { | 95 | if (date.day == 1) { |
96 | - text += ' ' + DateFormat.MMM().format(date); | 96 | + text += ' ${DateFormat.MMM().format(date)}'; |
97 | } | 97 | } |
98 | 98 | ||
99 | return Container( | 99 | return Container( |
@@ -109,12 +109,12 @@ class Calendar extends StatelessWidget { | @@ -109,12 +109,12 @@ class Calendar extends StatelessWidget { | ||
109 | 109 | ||
110 | @override | 110 | @override |
111 | Widget build(Context context) { | 111 | Widget build(Context context) { |
112 | - final _date = date ?? DateTime.now(); | ||
113 | - final _year = year ?? _date.year; | ||
114 | - final _month = month ?? _date.month; | 112 | + final localDate = date ?? DateTime.now(); |
113 | + final localYear = year ?? localDate.year; | ||
114 | + final localMnth = month ?? localDate.month; | ||
115 | 115 | ||
116 | - final start = DateTime(_year, _month, 1, 12); | ||
117 | - final end = DateTime(_year, _month + 1, 1, 12).subtract( | 116 | + final start = DateTime(localYear, localMnth, 1, 12); |
117 | + final end = DateTime(localYear, localMnth + 1, 1, 12).subtract( | ||
118 | const Duration(days: 1), | 118 | const Duration(days: 1), |
119 | ); | 119 | ); |
120 | 120 | ||
@@ -148,9 +148,9 @@ class Calendar extends StatelessWidget { | @@ -148,9 +148,9 @@ class Calendar extends StatelessWidget { | ||
148 | children: List<Widget>.generate(42, (int index) { | 148 | children: List<Widget>.generate(42, (int index) { |
149 | final d = start.add(Duration(days: index - startId)); | 149 | final d = start.add(Duration(days: index - startId)); |
150 | final currentMonth = index >= startId && index < endId; | 150 | final currentMonth = index >= startId && index < endId; |
151 | - final currentDay = d.year == _date.year && | ||
152 | - d.month == _date.month && | ||
153 | - d.day == _date.day; | 151 | + final currentDay = d.year == localDate.year && |
152 | + d.month == localDate.month && | ||
153 | + d.day == localDate.day; | ||
154 | return Container( | 154 | return Container( |
155 | foregroundDecoration: BoxDecoration( | 155 | foregroundDecoration: BoxDecoration( |
156 | border: Border( | 156 | border: Border( |
@@ -170,7 +170,7 @@ class Calendar extends StatelessWidget { | @@ -170,7 +170,7 @@ class Calendar extends StatelessWidget { | ||
170 | mainAxisAlignment: MainAxisAlignment.start, | 170 | mainAxisAlignment: MainAxisAlignment.start, |
171 | mainAxisSize: MainAxisSize.min, | 171 | mainAxisSize: MainAxisSize.min, |
172 | children: <Widget>[ | 172 | children: <Widget>[ |
173 | - title(context, DateTime(_year, _month)), | 173 | + title(context, DateTime(localYear, localMnth)), |
174 | head, | 174 | head, |
175 | Expanded(child: body), | 175 | Expanded(child: body), |
176 | ], | 176 | ], |
@@ -62,7 +62,7 @@ Future<Uint8List> generateDocument( | @@ -62,7 +62,7 @@ Future<Uint8List> generateDocument( | ||
62 | pw.RichText( | 62 | pw.RichText( |
63 | text: pw.TextSpan(children: [ | 63 | text: pw.TextSpan(children: [ |
64 | pw.TextSpan( | 64 | pw.TextSpan( |
65 | - text: DateTime.now().year.toString() + '\n', | 65 | + text: '${DateTime.now().year}\n', |
66 | style: pw.TextStyle( | 66 | style: pw.TextStyle( |
67 | fontWeight: pw.FontWeight.bold, | 67 | fontWeight: pw.FontWeight.bold, |
68 | color: PdfColors.grey600, | 68 | color: PdfColors.grey600, |
@@ -10,18 +10,20 @@ environment: | @@ -10,18 +10,20 @@ environment: | ||
10 | dependencies: | 10 | dependencies: |
11 | flutter: | 11 | flutter: |
12 | sdk: flutter | 12 | sdk: flutter |
13 | - intl: ^0.17.0 | 13 | + intl: ^0.18.0 |
14 | open_file: ^3.2.1 | 14 | open_file: ^3.2.1 |
15 | - path_provider: ^2.0.2 | ||
16 | - printing: ^5.3.0 | ||
17 | - url_launcher: ^6.0.6 | 15 | + path_provider: ^2.0.12 |
16 | + pdf: | ||
17 | + printing: | ||
18 | + url_launcher: ^6.1.8 | ||
19 | + vector_math: ^2.1.4 | ||
18 | 20 | ||
19 | dev_dependencies: | 21 | dev_dependencies: |
20 | # flutter_launcher_icons: ^0.10.0 | 22 | # flutter_launcher_icons: ^0.10.0 |
21 | - flutter_lints: ^1.0.4 | 23 | + flutter_lints: ^2.0.1 |
22 | flutter_test: | 24 | flutter_test: |
23 | sdk: flutter | 25 | sdk: flutter |
24 | - test: ^1.16.5 | 26 | + test: ^1.22.0 |
25 | 27 | ||
26 | dependency_overrides: | 28 | dependency_overrides: |
27 | pdf: | 29 | pdf: |
-
Please register or login to post a comment