neo
neo

Reputation: 31

Flutter Information Does not want to appear on screen

I want to print the results from the results I get from the results method, now it returns nothing on the screen. May I please get help on where am I wrong. This is my code below

class BarcodeItemWidget extends StatelessWidget {
  BarcodeItem item;

  BarcodeItemWidget(this.item);

    String results(){
      String result = "";
    if( barcodeFormatEnumMap[item.barcodeFormat]! == "pdf_417"){
         result = "MVL code:" + item.text.split('%')[1] ;
    }else{ if (barcodeFormatEnumMap[item.barcodeFormat]! == "code_128"){
      result = "item code:" + item.text ;
    }

    }

    return result;

}


  @override
  Widget build(BuildContext context) {
    return Card(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[

          Row(
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text("Barcode Type:",
                  style: TextStyle(inherit: true, color: Colors.black),
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  barcodeFormatEnumMap[item.barcodeFormat]!,
                  style: TextStyle(inherit: true, color: Colors.black),
                ),
              ),
            ],
          ),

          Row(
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                    results()
                ),
              ),

may someone please see what I am not doing right. Thank you

Upvotes: 0

Views: 52

Answers (2)

Patrick G.
Patrick G.

Reputation: 475

Try adding a debug point on the line you are calling results() or better try add a variable String result = results(); inside your build method so you can see if the value returned from results() is correct..

Then if it is correct the problem is with the widget you are displaying.. it can be size, position, color etc..

Upvotes: 0

neo
neo

Reputation: 31

Hi everyone I found the issue. The way item.barcodeFormat is declared like PDF_417 and I used pdf_417, so that was it. Thank you

I just need one more thing, it only prints one line and I want to print many lines with all that info, may u please assist check my updated code below

 String results(){
      String result = "";
    if( barcodeFormatEnumMap[item.barcodeFormat]! == 'PDF_417'){
         result = "MVL code:" + item.text.split('%')[1] ;
         result = "Auth code:" + item.text.split('%')[2] ;
         result = "License Number:" + item.text.split('%')[3] ;
         result = "Issue Number:" + item.text.split('%')[4] ;
         result = "Disc Number:" + item.text.split('%')[5] ;
         result = "License Plate:" + item.text.split('%')[6] ;
         result = "Vehicle Registration:" + item.text.split('%')[7] ;
         result = "Vehicle Type:" + item.text.split('%')[8] ;
         result = "Make:" + item.text.split('%')[9] ;
         result = "Model:" + item.text.split('%')[10] ;
         result = "Colour:" + item.text.split('%')[11] ;
         result = "Vin Number:" + item.text.split('%')[12] ;
         result = "Engine Number:" + item.text.split('%')[13] ;
         result = "Disk Expiry:" + item.text.split('%')[14] ;

    }else{ if (barcodeFormatEnumMap[item.barcodeFormat]! == 'CODE_128'){
      result = "item code:" + item.text ;
    }

Upvotes: 1

Related Questions