0

I'm trying to build a custom widget for QR code scanning in my app but I'm encountering a compile error and the error message is not being shown. How can I resolve this issue and see the error message to understand what is causing the issue? If someone knows how to correct the code, could you please share the solution as well?

Despite attempting several troubleshooting steps, such as restarting and rewriting the code, correcting any shown errors, and checking the parameters and dependencies, the compile error in the QR code scanning custom widget still persists. The error message is not being displayed, making it difficult to understand the root cause of the issue.

The code

// Automatic FlutterFlow imports
import '../../backend/backend.dart';
import '../../flutter_flow/flutter_flow_theme.dart';
import '../../flutter_flow/flutter_flow_util.dart';
import '../widgets/index.dart'; // Imports other custom widgets
import '../../flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

class Qrcode extends StatefulWidget {
  const Qrcode({
    required Key key,
    this.width,
    this.height,
    required this.data,
    required this.size,
    required this.backgroundColor,
    required this.foregroundColor,
    required this.semanticsLabel,
  }) : super(key: key);

  final double? width;
  final double? height;
  final String data;
  final double size;
  final Color backgroundColor;
  final Color foregroundColor;
  final String semanticsLabel;

  @override
  _QrcodeState createState() => _QrcodeState();
}

class _QrcodeState extends State<Qrcode> {
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

Print Screen of the project showing all dependencies and Parameters

2 Answers2

0

You are just retuning empty container from build method.

class _QrcodeState extends State<Qrcode> {
  @override
  Widget build(BuildContext context) {
    return Container( // add other properties like below
      width: widget.width,
      height: widget.height,
      decoration: BoxDecoration(
        color: widget.backgroundColor
      ),
    );
  }
}

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
0

You are returning an Empty Container that's why it is not showing anything try below Code and modify it according to your needs.

import '../../backend/backend.dart';
import '../../flutter_flow/flutter_flow_theme.dart';
import '../../flutter_flow/flutter_flow_util.dart';
import '../widgets/index.dart'; // Imports other custom widgets
import '../../flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';

class Qrcode extends StatefulWidget {
  const Qrcode({
    required Key key,
    this.width,
    this.height,
    required this.data,
    required this.size,
    required this.backgroundColor,
    required this.foregroundColor,
    required this.semanticsLabel,
  }) : super(key: key);

  final double? width;
  final double? height;
  final String data;
  final double size;
  final Color backgroundColor;
  final Color foregroundColor;
  final String semanticsLabel;

  @override
  _QrcodeState createState() => _QrcodeState();
}

class _QrcodeState extends State<Qrcode> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: double.infinity,
      width: double.infinity,
      child: Center(
        child: Text("Some Text"),
      ),
    );
  }
}

Muzammil Hassan
  • 336
  • 2
  • 10