Skip to content

Commit e71bab0

Browse files
committed
fix: lint issues
feat: enable back gesture
1 parent ccad26b commit e71bab0

File tree

7 files changed

+23
-17
lines changed

7 files changed

+23
-17
lines changed

android/app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<uses-permission android:name="android.permission.INTERNET"/>
77
<application
88
android:label="Heartry"
9+
android:enableOnBackInvokedCallback="true"
910
android:icon="@mipmap/ic_launcher">
1011
<activity
1112
android:name=".MainActivity"

lib/screens/image_screen/image_screen.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class _ImageScreenState extends State<ImageScreen> {
308308
),
309309
),
310310
maxLines: maxLines,
311-
textScaleFactor: scale,
311+
textScaler: TextScaler.linear(scale),
312312
textDirection: TextDirection.ltr,
313313
)..layout(maxWidth: constraints.maxWidth - 140);
314314

lib/screens/image_screen/widgets/poem_image_text.dart

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:math' as math;
2+
13
import 'package:flutter/material.dart';
24
import 'package:flutter_riverpod/flutter_riverpod.dart';
35

@@ -27,7 +29,7 @@ class PoemImageText extends ConsumerWidget {
2729
Text(
2830
title,
2931
textAlign: TextAlign.center,
30-
textScaleFactor: scale <= 1.2 ? scale : 1.2,
32+
textScaler: TextScaler.linear(math.min(scale, 1.2)),
3133
style: TextStyle(
3234
fontSize: TITLE_TEXT_SIZE,
3335
color: color,
@@ -40,7 +42,7 @@ class PoemImageText extends ConsumerWidget {
4042
...poem.map(
4143
(e) => Text(
4244
e,
43-
textScaleFactor: scale,
45+
textScaler: TextScaler.linear(scale),
4446
style: TextStyle(
4547
fontSize: POEM_TEXT_SIZE,
4648
color: color,
@@ -52,7 +54,7 @@ class PoemImageText extends ConsumerWidget {
5254
Text(
5355
"-$poet",
5456
textAlign: TextAlign.center,
55-
textScaleFactor: scale <= 1.2 ? scale : 1.2,
57+
textScaler: TextScaler.linear(math.min(scale, 1.2)),
5658
style: TextStyle(
5759
fontSize: POET_TEXT_SIZE,
5860
color: color,

lib/screens/intro_screen/intro_screen.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ class _ProfilePage extends ConsumerWidget {
437437
WidgetRef ref, BuildContext context, ImageSource source) async {
438438
final config = ref.read(configProvider.notifier);
439439
final picker = ImagePicker();
440+
final scaffoldMessenger = ScaffoldMessenger.of(context);
441+
440442
try {
441443
final pickedImage = await picker.pickImage(
442444
source: source,
@@ -446,7 +448,7 @@ class _ProfilePage extends ConsumerWidget {
446448

447449
config.profile = await _saveImageInAppStorage(pickedImage);
448450
} on PlatformException {
449-
ScaffoldMessenger.of(context).showSnackBar(
451+
scaffoldMessenger.showSnackBar(
450452
const SnackBar(content: Text("Permission denied")),
451453
);
452454
}

lib/screens/profile_screen/profile_screen.dart

+9-6
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,22 @@ class _ProfileScreenState extends State<ProfileScreen> {
4949
final isAndroid = theme.platform == TargetPlatform.android;
5050

5151
return Scaffold(
52-
body: WillPopScope(
53-
onWillPop: () {
52+
body: PopScope(
53+
canPop: false,
54+
onPopInvoked: (didPop) {
55+
if (didPop) return;
56+
5457
final name = _nameController.text;
5558
if (name.isEmpty) {
5659
ScaffoldMessenger.of(context).showSnackBar(
5760
const SnackBar(content: Text(noNameError)),
5861
);
59-
60-
return Future.value(false);
62+
return;
6163
}
6264
if (_name != _nameController.text)
6365
_config.name = _nameController.text;
6466

65-
return Future.value(true);
67+
Navigator.pop(context);
6668
},
6769
child: SafeArea(
6870
child: Column(
@@ -238,6 +240,7 @@ class _ProfileUpdateDialog extends ConsumerWidget {
238240
Future<void> _updateImage(BuildContext context, ImageSource source) async {
239241
final navigator = Navigator.of(context);
240242
final picker = ImagePicker();
243+
final scaffoldMessenger = ScaffoldMessenger.of(context);
241244
try {
242245
final pickedImage = await picker.pickImage(
243246
source: source,
@@ -247,7 +250,7 @@ class _ProfileUpdateDialog extends ConsumerWidget {
247250

248251
navigator.pop(pickedImage);
249252
} on PlatformException {
250-
ScaffoldMessenger.of(context).showSnackBar(
253+
scaffoldMessenger.showSnackBar(
251254
const SnackBar(content: Text("Permission denied")),
252255
);
253256
}

lib/screens/writing_screen/writing_screen.dart

+2-4
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ class _WritingScreenState extends State<WritingScreen>
7474
@override
7575
Widget build(BuildContext context) {
7676
return Scaffold(
77-
body: WillPopScope(
78-
onWillPop: () {
77+
body: PopScope(
78+
onPopInvoked: (_) {
7979
if (_isEmpty && widget.model != null)
8080
poemDB.deletePoem(widget.model!);
81-
82-
return Future.value(true);
8381
},
8482
child: SafeArea(
8583
child: Stack(

lib/utils/custom_email_report_handler.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class CustomEmailReportHandler extends ReportHandler {
1515
];
1616

1717
@override
18-
Future<bool> handle(Report error, BuildContext? context) async {
19-
return _sendMail(_getBody(error), "Error <${error.error}>");
18+
Future<bool> handle(Report report, BuildContext? context) async {
19+
return _sendMail(_getBody(report), "Error <${report.error}>");
2020
}
2121

2222
String _getBody(Report report) {

0 commit comments

Comments
 (0)