David PHAM-VAN

Fix demo project

... ... @@ -117,7 +117,7 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
final appDocDir = await getApplicationDocumentsDirectory();
final appDocPath = appDocDir.path;
final file = File(appDocPath + '/' + 'document.pdf');
final file = File('$appDocPath/document.pdf');
print('Save as file ${file.path} ...');
await file.writeAsBytes(bytes);
await OpenFile.open(file.path);
... ...
... ... @@ -93,7 +93,7 @@ class Calendar extends StatelessWidget {
}
if (date.day == 1) {
text += ' ' + DateFormat.MMM().format(date);
text += ' ${DateFormat.MMM().format(date)}';
}
return Container(
... ... @@ -109,12 +109,12 @@ class Calendar extends StatelessWidget {
@override
Widget build(Context context) {
final _date = date ?? DateTime.now();
final _year = year ?? _date.year;
final _month = month ?? _date.month;
final localDate = date ?? DateTime.now();
final localYear = year ?? localDate.year;
final localMnth = month ?? localDate.month;
final start = DateTime(_year, _month, 1, 12);
final end = DateTime(_year, _month + 1, 1, 12).subtract(
final start = DateTime(localYear, localMnth, 1, 12);
final end = DateTime(localYear, localMnth + 1, 1, 12).subtract(
const Duration(days: 1),
);
... ... @@ -148,9 +148,9 @@ class Calendar extends StatelessWidget {
children: List<Widget>.generate(42, (int index) {
final d = start.add(Duration(days: index - startId));
final currentMonth = index >= startId && index < endId;
final currentDay = d.year == _date.year &&
d.month == _date.month &&
d.day == _date.day;
final currentDay = d.year == localDate.year &&
d.month == localDate.month &&
d.day == localDate.day;
return Container(
foregroundDecoration: BoxDecoration(
border: Border(
... ... @@ -170,7 +170,7 @@ class Calendar extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
title(context, DateTime(_year, _month)),
title(context, DateTime(localYear, localMnth)),
head,
Expanded(child: body),
],
... ...
... ... @@ -62,7 +62,7 @@ Future<Uint8List> generateDocument(
pw.RichText(
text: pw.TextSpan(children: [
pw.TextSpan(
text: DateTime.now().year.toString() + '\n',
text: '${DateTime.now().year}\n',
style: pw.TextStyle(
fontWeight: pw.FontWeight.bold,
color: PdfColors.grey600,
... ...
... ... @@ -10,18 +10,20 @@ environment:
dependencies:
flutter:
sdk: flutter
intl: ^0.17.0
intl: ^0.18.0
open_file: ^3.2.1
path_provider: ^2.0.2
printing: ^5.3.0
url_launcher: ^6.0.6
path_provider: ^2.0.12
pdf:
printing:
url_launcher: ^6.1.8
vector_math: ^2.1.4
dev_dependencies:
# flutter_launcher_icons: ^0.10.0
flutter_lints: ^1.0.4
flutter_lints: ^2.0.1
flutter_test:
sdk: flutter
test: ^1.16.5
test: ^1.22.0
dependency_overrides:
pdf:
... ...