Hello Team,
I spent almost 4 days now trying to solve this, really appriciate if someone expert can help me
I already followed the instruction from https://docs.flutterflow.io/customizing-your-app/custom-functions/custom-widgets#id-3.-adding-callback-action
and I have a text wdget in the page the should contain the value from the custom widget after the UI refresh, but it's not happening
it will only will happen if I touch the screen and scroll up or down then I get page refresh and the text widget get the new value from the app state variable
I'm using this custom widget https://pub.dev/packages/flutter_scalable_ocr/example
My code is below, I tried many many ways and now luck
Code:
class OcrPriceNumber extends StatefulWidget {
const OcrPriceNumber({
super.key,
this.width,
this.height,
required this.boxLeftOff,
required this.boxBottomOff,
required this.boxRightOff,
required this.boxTopOff,
required this.boxHeight,
required this.paintboxCustomStrokeWidth,
required this.paintboxCustomColor,
required this.refreshPageUI,
});
final double? width;
final double? height;
final double boxLeftOff;
final double boxBottomOff;
final double boxRightOff;
final double boxTopOff;
final int boxHeight;
final double paintboxCustomStrokeWidth;
final Color paintboxCustomColor;
final Future Function() refreshPageUI;
@override
State<OcrPriceNumber> createState() => _OcrPriceNumberState();
}
class _OcrPriceNumberState extends State<OcrPriceNumber> {
@override
String text = "";
final StreamController<String> controller = StreamController<String>();
void setText(value) {
controller.add(value);
}
@override
void dispose() {
controller.close();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
ScalableOCR(
paintboxCustom: Paint()
..style = PaintingStyle.stroke
..strokeWidth = widget.paintboxCustomStrokeWidth
..color = widget.paintboxCustomColor,
boxLeftOff: widget.boxLeftOff,
boxBottomOff: widget.boxBottomOff,
boxRightOff: widget.boxRightOff,
boxTopOff: widget.boxTopOff,
boxHeight:
MediaQuery.of(context).size.height / widget.boxHeight,
getScannedText: (value) {
setText(value); // tried with and without this one
// setState(() { tried with and without setState
FFAppState().OCRFoundPrice = value;
// });
widget.refreshPageUI();
}),
],
),
));
}
}