Home > Net >  I am getting "constraintsError"
I am getting "constraintsError"

Time:12-02

I tried to create an addImage page but getting "constraintsError" every time.

I tried to solve this with "Flexible", "Expanded", "Container" etc. widgets. But I dont get the solution.

Here is the my current page.

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text('Soru Ekleyin'),
    ),
    body: Padding(
      padding: const EdgeInsets.all(8.0),
      child: SingleChildScrollView(
        child: Column(
          children: [
            TextFormField(
              controller: _nameController,
              decoration: InputDecoration(
                labelText: '_nameController',
                hintText: '_nameController',
                filled: true,
                fillColor: Color.fromARGB(255, 249, 249, 249),
                errorBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(color: Colors.green),
                ),
                focusedBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(
                    // style: BorderStyle.none,
                    color: Colors.blue,
                  ),
                ),
                enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(
                      style: BorderStyle.none, color: Colors.green),
                ),
                disabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(
                      // style: BorderStyle.none,
                      color: Colors.green),
                ),
                // border: OutlineInputBorder(
                //     borderRadius: BorderRadius.circular(20.0)
                // ),
              ),
            ),
            TextFormField(
              controller: _categoryController,
              decoration: InputDecoration(
                labelText: '_categoryController',
                hintText: '_categoryController',
                filled: true,
                fillColor: Color.fromARGB(255, 249, 249, 249),
                errorBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(color: Colors.green),
                ),
                focusedBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(
                    // style: BorderStyle.none,
                    color: Colors.blue,
                  ),
                ),
                enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(
                      style: BorderStyle.none, color: Colors.green),
                ),
                disabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(25.0),
                  borderSide: BorderSide(
                      // style: BorderStyle.none,
                      color: Colors.green),
                ),
                // border: OutlineInputBorder(
                //     borderRadius: BorderRadius.circular(20.0)
                // ),
              ),
            ),
            ElevatedButton(
                onPressed: () {
                  question = Question(
                    _nameController.text.trim(),
                    false,
                    _categoryController.text.trim(),

                  );
                  _snackbarGoster(context, 'Soru eklendi.');

                  //Created the question variable.
                  // addQuestion(question!);
                },
                child: Text('Ekle')),
            Spacer(),
            image != null ? Image.file(image!) : FlutterLogo(),
            ElevatedButton(
                child: Text('Görsel Ekle'),
                onPressed: () {
                  addImage();
                  _snackbarGoster(context, 'Görsel eklendi.');
                }),
            TextField(
              decoration: InputDecoration(
                  labelText: 'Soru ve Açıklama',
                  hintText: 'Soru ve Açıklama'),
            ),
            ElevatedButton(
                onPressed: () async {
                  await uploadQuestion(question!);
                },
                child: Text('Yükle'))
          ],
        ),
      ),
    ),
  );
}

Can someone help me with this. How can I solve this. The error is coming from "flex.dart".

CodePudding user response:

I think you need to place your SingleChildScrollView inside sized widget.

  • Related