Is it possible to add textField to SystemAlertWindow overlay in Flutter?

60 views Asked by At

My question is similar to Is possible to implement TextField in system_alert_window Fluttter? , though no solution has been provided yet.

I'm asking so as to bump up the question to the flutter gurus and also to get a solution for the problem in my project.

For context:

I have implemented an overlay which works fine within the default parameters provided in https://github.com/pvsvamsi/SystemAlertWindow

but I've found that I require to add a TextField in the overlay window which will accept input from the user when the parent app is closed, then when the user presses the button "Done" on the overlay window, the data in the TextField will be passed back to the parent app for processing.

How can this be done? Please help!

void _showOverlayWindow(String amount) {
    if (!_isShowingWindow) {
      SystemWindowHeader header = SystemWindowHeader(
          title: SystemWindowText(
              text: "Go and Pay", fontSize: 10, textColor: Colors.black45),
          padding: SystemWindowPadding.setSymmetricPadding(6, 6),
          subTitle: SystemWindowText(
              text: "Account No: 012688781276754",
              fontSize: 20,
              fontWeight: FontWeight.BOLD,
              textColor: Colors.black87),
          decoration: SystemWindowDecoration(startColor: Colors.indigo),
      );
      SystemWindowBody body = SystemWindowBody(
        rows: [
          EachRow(
            columns: [
              EachColumn(
                text: SystemWindowText(
                    text: "This window will stay in place as you proceed to make payment. You may drag it out of the way.", fontSize: 12, textColor: Colors.black45),
              ),
            ],
            gravity: ContentGravity.CENTER,
          ),
          EachRow(columns: [
            EachColumn(
                text: SystemWindowText(
                    text: "Amount to pay is $amount",
                    fontSize: 12,
                    textColor: Colors.black87,
                    fontWeight: FontWeight.BOLD),
                padding: SystemWindowPadding.setSymmetricPadding(6, 8),
                decoration: SystemWindowDecoration(
                    startColor: Colors.black12, borderRadius: 25.0),
                margin: SystemWindowMargin(top: 4)),
          ], gravity: ContentGravity.CENTER),
          EachRow(
            columns: [
              EachColumn(
                text: SystemWindowText(
                    text: "Description",
                    fontSize: 10,
                    textColor: Colors.black45),
              ),
            ],
            gravity: ContentGravity.LEFT,
            margin: SystemWindowMargin(top: 8),
          ),
          EachRow(
            columns: [
              EachColumn(
                text: SystemWindowText(
                    text: "Once done click on the button below to return to APP to complete your order.",
                    fontSize: 13,
                    textColor: Colors.black54,
                    fontWeight: FontWeight.BOLD),
              ),
            ],
            gravity: ContentGravity.LEFT,
          ),
        ],
        padding: SystemWindowPadding(left: 6, right: 6, bottom: 6, top: 6),
      );
      SystemWindowFooter footer = SystemWindowFooter(
          buttons: [
            SystemWindowButton(
              text: SystemWindowText(
                  text: "Done", fontSize: 12, textColor: Colors.white),
              tag: "focus_button",
              width: 0,
              padding:
              SystemWindowPadding(left: 10, right: 10, bottom: 10, top: 10),
              height: SystemWindowButton.WRAP_CONTENT,
              decoration: SystemWindowDecoration(
                  startColor: Colors.lightBlueAccent,
                  endColor: Colors.blue,
                  borderWidth: 0,
                  borderRadius: 10.0),
            )
          ],
          padding:
          SystemWindowPadding(left: 16, right: 16, bottom: 12, top: 10),
          decoration: SystemWindowDecoration(startColor: Colors.white),
          buttonsPosition: ButtonPosition.CENTER);
      SystemAlertWindow.showSystemWindow(
          height: 300,
          width: 200,
          header: header,
          body: body,
          footer: footer,
          margin: SystemWindowMargin(left: 8, right: 8, top: 180, bottom: 0),
          gravity: SystemWindowGravity.TOP,
          notificationTitle: "Pay Goods",
          notificationBody: "Pay For Items: $.0.00",
          prefMode: prefMode,
          backgroundColor: Colors.white,
          isDisableClicks: false);
      setState(() {
        _isShowingWindow = false;
      });
    } else {
      setState(() {
        _isShowingWindow = false;
        _isUpdatedWindow = false;
      });
      SystemAlertWindow.closeSystemWindow(prefMode: prefMode);
    }
  }
}
0

There are 0 answers