Want to use Stack to align Containers in flutter? I’ve made changes to your code to do what you are trying to achieve. Please take a look:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | SingleChildScrollView( child: Container( color: Colors.white, child: Column( children: <Widget>[ Stack( children: <Widget>[ Container( margin: EdgeInsets.only(bottom: 20.0), alignment: Alignment.topCenter, height:250.0, decoration: BoxDecoration( borderRadius: BorderRadius.only( bottomLeft: Radius.elliptical(30,8), bottomRight: Radius.elliptical(30,8), ), color:Colors.blueAccent, ), //child: Image.asset("assets/bgImage.jpg"), ), Container( //color: Colors.white, width: 400.0, padding: EdgeInsets.only(top: 223, left: 55, right: 55), child: TextField( decoration: InputDecoration( fillColor: Colors.white, contentPadding: EdgeInsets.symmetric(vertical: 15.0), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.grey), borderRadius: BorderRadius.all(Radius.circular(20.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.grey), borderRadius: BorderRadius.all(Radius.circular(20.0)), ), hintText: 'Search', hintStyle: TextStyle( fontSize: 18.0 ), prefixIcon: Icon( Icons.search, size: 30.0, ), filled: true, ), //onSubmitted : ), ), ], ), Padding( padding: const EdgeInsets.only(left: 20.0,right: 20.0, top: 20), child: Card( elevation: 6.0, child: Padding( padding: const EdgeInsets.all(15.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: Column( children: <Widget>[ CircleAvatar( radius: 30.0, backgroundColor: Colors.blue, ), SizedBox(height: 5.0,), Text('Jaipur') ], ), ), Padding( padding: const EdgeInsets.all(8.0), child: Column( children: <Widget>[ CircleAvatar( radius: 30.0, backgroundColor: Colors.blue, ), SizedBox(height: 5.0,), Text('Jaipur') ], ), ), ], ), ), ), ), ] ), ), ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.