Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The argument type 'RxString' can't be assigned to the parameter type 'String'

I try to use the GetX framework in flutter for my project. but it shows the Error regarding RxString. whenever I try to use the Obx method to call the controller object inside a text widget or a other String parameter widget it shows the error

The argument type 'RxString' can't be assigned to the parameter type 'String'

this is my controller class

var qrValue = "waiting".obs;

socket.on('event', (data) 
{
    var qr = data['final'];
    qrValue.value = qr;
    print(qrValue);
 }

this want to pass the data to generate the qrcode

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Obx(() => QrImage(
data: _controller.qrValue,
version: QrVersions.auto,
size: 200.0,
 ),
 )),

when i pass the qrvalue to the argument it show the error

The argument type ‘RxString’ can’t be assigned to the parameter type
‘String’

>Solution :

You are passing directly the Rx to the data property of QrImage. You need to pass the value of the Rx:

data: _controller.qrValue.value,
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading