0

I tried to make circleImage Widget and use it. but when it's used, it makes error that needs argument. What argument needs in that position?




 @override
 Widget build(BuildContext context) {
   return MaterialApp(
       home: Scaffold(
     appBar: AppBar(
       leading: Text('eyes'),
       actions: <Widget>[
           **CircleImage();**
       ],
     ),  
       ],

     ),
   )
   );
 }
}

// making CircleImage

class CircleImage extends StatelessWidget {
 CircleImage(
     this.imageProvider,  {
       this.radius = 10,
     }
     );

 final double radius;
 final ImageProvider imageProvider;


 @override
 Widget build(BuildContext context) {
   return Column(
     mainAxisAlignment: MainAxisAlignment.center,
     children: <Widget>[
       CircleAvatar(
         radius: radius,
         backgroundImage: imageProvider,
       )
     ],
   );
 }
}

It appers in AppBar's widget. That makes error. Could I workaround that?

Uranus_ly
  • 121
  • 1
  • 6

1 Answers1

2

You need to pass image provider to CircleImage widget.

For example if you have image in assets,

actions: <Widget>[
    CircleImage(AssetImage('assets/image_name.png')),
]

Else if you have image url,you can do something like this.

actions: <Widget>[
    CircleImage(NetworkImage("https:/somedomain.com/a.png")) //Your image url
]
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
Gowtham K K
  • 3,123
  • 1
  • 11
  • 29