@@ -49,20 +49,22 @@ class _ProfileScreenState extends State<ProfileScreen> {
49
49
final isAndroid = theme.platform == TargetPlatform .android;
50
50
51
51
return Scaffold (
52
- body: WillPopScope (
53
- onWillPop: () {
52
+ body: PopScope (
53
+ canPop: false ,
54
+ onPopInvoked: (didPop) {
55
+ if (didPop) return ;
56
+
54
57
final name = _nameController.text;
55
58
if (name.isEmpty) {
56
59
ScaffoldMessenger .of (context).showSnackBar (
57
60
const SnackBar (content: Text (noNameError)),
58
61
);
59
-
60
- return Future .value (false );
62
+ return ;
61
63
}
62
64
if (_name != _nameController.text)
63
65
_config.name = _nameController.text;
64
66
65
- return Future . value ( true );
67
+ Navigator . pop (context );
66
68
},
67
69
child: SafeArea (
68
70
child: Column (
@@ -238,6 +240,7 @@ class _ProfileUpdateDialog extends ConsumerWidget {
238
240
Future <void > _updateImage (BuildContext context, ImageSource source) async {
239
241
final navigator = Navigator .of (context);
240
242
final picker = ImagePicker ();
243
+ final scaffoldMessenger = ScaffoldMessenger .of (context);
241
244
try {
242
245
final pickedImage = await picker.pickImage (
243
246
source: source,
@@ -247,7 +250,7 @@ class _ProfileUpdateDialog extends ConsumerWidget {
247
250
248
251
navigator.pop (pickedImage);
249
252
} on PlatformException {
250
- ScaffoldMessenger . of (context) .showSnackBar (
253
+ scaffoldMessenger .showSnackBar (
251
254
const SnackBar (content: Text ("Permission denied" )),
252
255
);
253
256
}
0 commit comments