Home > Enterprise >  How to add custom container to form
How to add custom container to form

Time:08-09

I'm new to flutter. I'm trying to build register and login app. but I faced an issue. My problem is that I have this container

class Background extends StatelessWidget {
  final Widget child;

  const Background({
    Key? key,
    required this.child,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;

    return Container(
      child: Stack(
        alignment: Alignment.center,
        children: <Widget>[
          Positioned(
            top: 0,
            right: 0,
            child: Image.asset(
                "assets/images/img1.png",
                width: size.width
            ),
          ),
          Positioned(
            top: 0,
            right: 0,
            child: Image.asset(
                "assets/images/img2.png",
                width: size.width
            ),
          ),
          child
        ],
      ),
    );
  }
}

I need to include this container in Scaffold here to take the design but I didn't know how can I do that.

 return Scaffold(
      body: Form(
        key: formkey,
        child: Column()));
                                        

Can Anyone help me to do that please

CodePudding user response:

Background is a wrapper widget. Do it like

 Scaffold(
  body: Background(
    child: Form(
      child: Column(
        children: [],
      ),
    ),
  ),
),
  • Related