title: Flutter CircleAvatar - Using Image object as (background) image / typecasting it to ImageProvider
body: <p>I am trying to show a <code>CircleAvatar</code> at the top of the main screen of my App, but I am running into a rather silly issue. I am unable to figure out how to provide an object of the class <code>Image</code> (that is a property of a user) as an <code>ImageProvider</code>, which is what <code>CircleAvatar</code> <a href="https://api.flutter.dev/flutter/material/CircleAvatar-class.html" rel="nofollow noreferrer">expects</a>. Is there an easy way to "typecast" here or some other way people have resolved this?</p>
  
  <pre><code>class _HomePageState extends State&lt;PictureShowcaseHome&gt;{
    Appuser appuser = new Appuser();
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          leading: InkWell(          
            child: CircleAvatar(                               
                    backgroundImage: appuser.img, 
                    child: Text(appuser.name.substring(0,1).toUpperCase()),
                  ) ,
          ),
  
  ...
  </code></pre>
  
  <p>To simplify things, assume an <code>Appuser</code> has just the following properties:</p>
  
  <pre><code>class Appuser{
    String name;
    Image img;  
    Appuser(){
      this.name = "Unknown user";
      this.img = Image.asset('assets/imgs/default1.jpg');        
    }
  }
  </code></pre>
  
  <p>My idea is that I have a default image that is included in the assets, but the user can replace it with their own image (seems like a rather standard idea). I considered switching to <code>AssetImage img;</code> and <code>img = new AssetImage('assets/imgs/default1.jpg');</code> in the constructor for <code>Appuser</code>, but that sort of seems backwards. It also gets me into the "opposite" problem, when I display the user image on a user information details page (I thought of just having a <code>ListTile( title: appuser.img,),</code>) or when I let the user take a new user picture with the camera. For those purposes, it is easiest to directly work with an object of class <code>Image</code>, not an <code>AssetImage</code>.</p>
  
  <p>Or am I somehow looking at this the wrong way?</p>