You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When calling Navigator.of(context).pop('page2'); from inside the onImageEditingComplete event no data is returned.
i expect the string 'page2' to be retuned but the return value remains null. I also tried to use a explicit context that is consitend over the navigation but this still results in null being returned.
I made a simple app to reproduce the issue. Page1 returns 'page1' successfully while Page2 containing the ProImageEditor does not return 'page2'.
main.dart
import 'package:flutter/material.dart';
import 'package:poptest/page1.dart';
import 'package:poptest/page2.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextButton(
onPressed: () => _goToPage1(), child: Text('Go to Page1')),
TextButton(
onPressed: () => _goToPage2(), child: Text('Go to Page2')),
],
),
),
);
}
void _goToPage1() async {
final result = await Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => Page1()));
print(result);
}
void _goToPage2() async {
final result = await Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => Page2()));
print(result);
}
}
Thanks for reporting that issue. I've fixed it in the latest release 2.4.1 by a solution that allows you to close the editor with custom parameters. That update includes a new callback function onCloseEditor that triggers when the editor needs to be closed. You can use this callback to pass your parameters when closing the editor.
class_Page2StateextendsState<Page2> {
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
body:ProImageEditor.network(
'https://picsum.photos/id/237/2000',
onImageEditingComplete: (byte) async {
/* `Your code for handling the edited image. Upload it to your server as an example.` You can choose whether you want to use await, so that the loading-dialog remains visible until your code is also ready, or without async, so that the loading-dialog closes immediately. Close the page in the function `onCloseEditor` for the case you need to return your own parameters */
},
onCloseEditor: () {
Navigator.of(context).pop('page2');
},
),
);
}
}
Describe the bug
When calling
Navigator.of(context).pop('page2');
from inside the onImageEditingComplete event no data is returned.i expect the string 'page2' to be retuned but the return value remains null. I also tried to use a explicit context that is consitend over the navigation but this still results in null being returned.
I made a simple app to reproduce the issue. Page1 returns 'page1' successfully while Page2 containing the ProImageEditor does not return 'page2'.
main.dart
page1.dart
page2.dart
The text was updated successfully, but these errors were encountered: