0
votes

My Code is

 Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: Helper.of(context).onWillPop,
      child: Scaffold(
        key: _con.scaffoldKey,
        resizeToAvoidBottomInset: true,
        body: SingleChildScrollView(
          child: Column(
              children: <Widget>[
                SizedBox(height: 60),
                Center(
                  child: Image.asset(
                    'assets/img/villa_logo-transparent.png',
                    width: 230.0,
                    height: 230.0,
                  ),
                ),
                Stack(
                  children: [
createTextForm()
],
                ),
              ]),
        ),
      ),
    );
  }

This is how i am creating text form

Widget createTextForm() {
    return  Positioned(
      // top: config.App(context).appHeight(29.5) - 50,
      child: Container(
        // decoration: BoxDecoration(
        //     color: Theme.of(context).primaryColor,
        //     borderRadius: BorderRadius.all(Radius.circular(10)),
        //     boxShadow: [
        //       BoxShadow(
        //         blurRadius: 50,
        //         color: Theme.of(context).hintColor.withOpacity(0.2),
        //       )
        //     ]),
        margin: EdgeInsets.symmetric(
          horizontal: 20,
        ),
        padding: EdgeInsets.symmetric(vertical: 2, horizontal: 27),
        width: config.App(context).appWidth(88),
        // height: config.App(context).appHeight(70),

        // height: config.App(context).appHeight(80),
        child: Form(
          key: _con.loginFormKey,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              TextFormField(
                keyboardType: TextInputType.text,
                onSaved: (input) => _con.user.name = input,
                validator: (input) => input.length < 3
                    ? S.of(context).should_be_more_than_3_letters
                    : null,
                decoration: InputDecoration(
                  labelText: S.of(context).full_name,
                  labelStyle: TextStyle(color: Theme.of(context).accentColor),
                  contentPadding: EdgeInsets.all(12),
                  hintText: S.of(context).john_doe,
                  hintStyle: TextStyle(
                      color: Theme.of(context).focusColor.withOpacity(0.7)),
                  prefixIcon: Icon(Icons.person_outline,
                      color: Theme.of(context).accentColor),
                  border: OutlineInputBorder(
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.2))),
                  focusedBorder: OutlineInputBorder(
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.5))),
                  enabledBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(20)),
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.2))),
                ),
              ),
              SizedBox(height: 30),
              TextFormField(
                keyboardType: TextInputType.phone,
                onSaved: (input) => _con.user.phone = input,
                validator: (input) => input.length < 3
                    ? S.of(context).should_be_more_than_3_letters
                    : null,
                decoration: InputDecoration(
                  labelText: "Phone Number",
                  labelStyle: TextStyle(color: Theme.of(context).accentColor),
                  contentPadding: EdgeInsets.all(12),
                  hintText: "+1 234 56789",
                  hintStyle: TextStyle(
                      color: Theme.of(context).focusColor.withOpacity(0.7)),
                  prefixIcon: Icon(Icons.person_outline,
                      color: Theme.of(context).accentColor),
                  border: OutlineInputBorder(
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.2))),
                  focusedBorder: OutlineInputBorder(
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.5))),
                  enabledBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(20)),
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.2))),
                ),
              ),
              SizedBox(height: 30),
              TextFormField(
                keyboardType: TextInputType.emailAddress,
                onSaved: (input) => _con.user.email = input,
                validator: (input) => !input.contains('@')
                    ? S.of(context).should_be_a_valid_email
                    : null,
                decoration: InputDecoration(
                  labelText: S.of(context).email,
                  labelStyle: TextStyle(color: Theme.of(context).accentColor),
                  contentPadding: EdgeInsets.all(12),
                  hintText: '',
                  hintStyle: TextStyle(
                      color: Theme.of(context).focusColor.withOpacity(0.7)),
                  prefixIcon: Icon(Icons.alternate_email,
                      color: Theme.of(context).accentColor),
                  border: OutlineInputBorder(
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.2))),
                  focusedBorder: OutlineInputBorder(
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.5))),
                  enabledBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(20)),
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.2))),
                ),
              ),
              SizedBox(height: 30),
              TextFormField(
                obscureText: _con.hidePassword,
                onSaved: (input) => _con.user.password = input,
                validator: (input) => input.length < 6
                    ? S.of(context).should_be_more_than_6_letters
                    : null,
                decoration: InputDecoration(
                  labelText: S.of(context).password,
                  labelStyle: TextStyle(color: Theme.of(context).accentColor),
                  contentPadding: EdgeInsets.all(12),
                  hintText: '••••••••••••',
                  hintStyle: TextStyle(
                      color: Theme.of(context).focusColor.withOpacity(0.7)),
                  prefixIcon: Icon(Icons.lock_outline,
                      color: Theme.of(context).accentColor),
                  suffixIcon: IconButton(
                    onPressed: () {
                      setState(() {
                        _con.hidePassword = !_con.hidePassword;
                      });
                    },
                    color: Theme.of(context).focusColor,
                    icon: Icon(_con.hidePassword
                        ? Icons.visibility
                        : Icons.visibility_off),
                  ),
                  border: OutlineInputBorder(
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.2))),
                  focusedBorder: OutlineInputBorder(
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.5))),
                  enabledBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(20)),
                      borderSide: BorderSide(
                          color:
                              Theme.of(context).focusColor.withOpacity(0.2))),
                ),
              ),
              SizedBox(height: 30),
              registerButtonCall(),
              bottomLoginText(),
              
            ],
          ),
        ),
      ),
    );
    //
    // ]);
  }

Error The following assertion was thrown while applying parent data.: I/flutter (21259): Incorrect use of ParentDataWidget. I/flutter (21259): The ParentDataWidget Positioned(bottom: 10.0) wants to apply ParentData of type StackParentData to a I/flutter (21259): RenderObject, which has been set up to accept ParentData of incompatible type FlexParentData. I/flutter (21259): Usually, this means that the Positioned widget has the wrong ancestor RenderObjectWidget. Typically, I/flutter (21259): Positioned widgets are placed directly inside Stack widgets. I/flutter (21259): The offending Positioned is currently placed inside a Column widget. I/flutter (21259): The ownership chain for the RenderObject that received the incompatible parent data was: I/flutter (21259): Semantics ← RawMaterialButton ← FlatButton ← Positioned ← Column ← _FormScope ← WillPopScope ← I/flutter (21259): Form-[LabeledGlobalKey#ea070] ← Padding ← ConstrainedBox ← ⋯ I/flutter (21259): I/flutter (21259): When the exception was thrown, this was the stack: I/flutter (21259): #0 RenderObjectElement._updateParentData. (package:flutter/src/widgets/framework.dart:5770:11) I/flutter (21259): #1 RenderObjectElement._updateParentData (package:flutter/src/widgets/framework.dart:5786:6) I/flutter (21259): #2 RenderObjectElement.attachRenderObject (package:flutter/src/widgets/framework.dart:5808:7) I/flutter (21259): #3 RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5501:5) I/flutter (21259): #4 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6117:11) I/flutter (21259): ... Normal element mounting (21 frames) I/flutter (21259): #25 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) I/flutter (21259): #26 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6236:32) I/flutter (21259): ... Normal element mounting (44 frames) I/flutter (21259): #70 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) I/flutter (21259): #71 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6236:32) I/flutter (21259): #72 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) I/flutter (21259): #73 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6236:32) I/flutter (21259): ... Normal element mounting (109 frames) I/flutter (21259): #182 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) I/flutter (21259): #183 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6236:32) I/flutter (21259): ... Normal element mounting (218 frames) I/flutter (21259): #401 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) I/flutter (21259): #402 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18) I/flutter (21259): #403 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5705:32) I/flutter (21259): #404 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6246:17) I/flutter (21259): #405 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #406 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16) I/flutter (21259): #407 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11) I/flutter (21259): #408 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5) I/flutter (21259): #409 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5) I/flutter (21259): #410 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #411 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16) I/flutter (21259): #412 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5) I/flutter (21259): #413 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5) I/flutter (21259): #414 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:183:11) I/flutter (21259): #415 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #416 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14) I/flutter (21259): #417 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #418 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16) I/flutter (21259): #419 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11) I/flutter (21259): #420 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5) I/flutter (21259): #421 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5) I/flutter (21259): #422 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #423 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14) I/flutter (21259): #424 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #425 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14) I/flutter (21259): #426 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #427 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16) I/flutter (21259): #428 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5) I/flutter (21259): #429 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5) I/flutter (21259): #430 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #431 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16) I/flutter (21259): #432 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5) I/flutter (21259): #433 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5) I/flutter (21259): #434 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15) I/flutter (21259): #435 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16) I/flutter (21259): #436 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11) I/flutter (21259): #437 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5) I/flutter (21259): #438 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2730:33) I/flutter (21259): #439 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:913:20) I/flutter (21259): #440 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:302:5) I/flutter (21259): #441 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15) I/flutter (21259): #442 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1055:9) I/flutter (21259): #443 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:971:5) I/flutter (21259): #447 _invoke (dart:ui/hooks.dart:251:10) I/flutter (21259): #448 _drawFrame (dart:ui/hooks.dart:209:3) I/flutter (21259): (elided 3 frames from dart:async) I/flutter (21259): ════════════════════════════════════════════════════════════════════════════════════════════════════ I/flutter (21259): Another exception was thrown: Exception: Invalid image data

1

1 Answers

1
votes

Your Positioned widget must be directly inside Stack, not inside another widget that returns a Positioned.

Stack(
  children: [
    Positioned(
      child: TextForm()
    )
  ],
),

It's just the way Flutter does error checking to ensure Positioned is only used inside Stack.

Same with how Expanded & Flexible widgets can only be used inside Row or Column directly and not wrapped by any other widget.