flutter_scan icon indicating copy to clipboard operation
flutter_scan copied to clipboard

dark screen in android

Open DJafari opened this issue 3 years ago • 7 comments

image

library version : 1.6.0 android sdk : 31

DJafari avatar Dec 25 '21 16:12 DJafari

I will check

chavesgu avatar Dec 28 '21 02:12 chavesgu

We meet this issue on Android as well

Here is what happens:

  • There is a page on our app with a button to open the scan, and a textfield
  • When clicking on the textfield, the keyboard appears
  • If we click on the button that opens the scan camera while the keyboard is opened, we also see that dark screen

ℹ️ Note that the scanning system still works though. We can still scan barcodes but we don't see what we scan (as the screen is fully dark)

NayMak-Adeo avatar Jan 03 '22 14:01 NayMak-Adeo

        oh、someone meet this issue too、you can solve this problem just close the keyboard before scan---- On 星期一, 03 一月 2022 22:12:41 +0800  ***@***.******@***.***> wrote ----  

We meet this issue on Android as well
Here is what happens:

There is a page on our app with a button to open the scan, and a textfield
When clicking on the textfield, the keyboard appears
If we click on the button that opens the scan camera while the keyboard is opened, we also see that dark screen

ℹ️ Note that the scanning system still works though. We can still scan barcodes but we don't see what we scan (as the screen is fully dark)

—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you commented.Message ID: @.***>

chavesgu avatar Jan 03 '22 14:01 chavesgu

#31

chavesgu avatar Jan 03 '22 14:01 chavesgu

@DJafari Just use it like this :

Future goToScanPage() async { await unfocus(); Future.delayed(const Duration(milliseconds: 500), () { Navigator.push( context, MaterialPageRoute( builder: (context) { return Scan(); } ) ); } ); }

Future unFocus() async { FocusManager.instance.primaryFocus?.unfocus(); }

mahdinazmi avatar Mar 03 '22 13:03 mahdinazmi

any update on this?

pro100svitlo avatar Mar 16 '22 16:03 pro100svitlo

write like this can resolve this problem:

///  Use WidgetsBindingObserver to monitor keyboard pop-up and retract events
class _ScanToolState extends State<ScanTool>  with  WidgetsBindingObserver {

  /// A completer that monitors whether the keyboard is retracted or not
  Completer _keyboardBackCompleter = Completer()..complete(true);

  @override
  void initState() {
     /// Add listener object
    WidgetsBinding.instance.addObserver(this);
    super.initState();
  }

  @override
  void didChangeMetrics() {
    /// add callback
    WidgetsBinding.instance.addPostFrameCallback((_) {
      setState(() {
        if(MediaQuery.of(context).viewInsets.bottom==0){
          /// The keyboard is retracted (the keyboard retracts once, and it will be triggered several times here)
          if(!_keyboardBackCompleter.isCompleted) {
            _keyboardBackCompleter.complete(true);
          }
        }else{
          /// The keyboard pops up (once the keyboard pops up, it will be triggered several times here)
          if(_keyboardBackCompleter.isCompleted) {
            _keyboardBackCompleter = Completer();
          }
        }
      });
    });
    super.didChangeMetrics();
  }

 /// enter scanPage method
 scanCode() async {
    /// here write your unfocus method
    unfocus();
    await _keyboardBackCompleter.future;
    /// Here you can ensure that the keyboard must be retracted,then you can jump to the scan page
    Navigator.of(context).push.........
 }

maxwellcatoo avatar May 12 '23 03:05 maxwellcatoo