Flutter Positioned Widget | RRTutors

Flutter Position Widget

This use controls the position of the widget, through which he can place a component at will, a bit like an absolute layout

Positioned({

  Key key,

  this.left,

  this.top,

  this.right,

  this.bottom,

  this.width,

  this.height,

  @required Widget child,

})


 

Example

 

class PositionedWidget extends StatelessWidget{

 GlobalKey<ScaffoldState>_scaffoldstate=GlobalKey();

 @override

 Widget build(BuildContext context) {

   final size = MediaQuery.of(context).size;

   return MaterialApp(

       home: Scaffold(

           key: _scaffoldstate,

           appBar: AppBar(title:Text("Positioned Widget"),backgroundColor: Colors.pink,),

           body:Container(

             width: size.width,

             height: size.height,

             child: Stack(

               children: <Widget>[

                 Positioned(

                   child: CircleAvatar(

                     backgroundImage: NetworkImage("https://cdn.pixabay.com/photo/2016/10/17/17/41/priyanka-chopra-1748248_960_720.jpg"),

                     radius: 80.0,

                   ),

                   right:10, top: 10,

                 ),

               Positioned(

                   child: CircleAvatar(

                     backgroundImage: NetworkImage("https://cdn.pixabay.com/photo/2016/10/17/17/41/priyanka-chopra-1748248_960_720.jpg"),

                     radius: 80.0,

                   ),

                     left: size.width / 2 * 0.8,

                     top: size.height / 2 * 0.7,

               ),

                 Positioned(

                   child: CircleAvatar(

                     backgroundImage: NetworkImage("https://cdn.pixabay.com/photo/2016/10/17/17/41/priyanka-chopra-1748248_960_720.jpg"),

                     radius: 80.0,

                   ),

                   left: 10,

                   bottom: 10,

               )],

             ), ),) );

 }}

Positioned Widget

Advertisements