content: import 'package:cached_network_image/cached_network_image.dart';
  import 'package:flutter/material.dart';
  import 'package:flutter_image_upload/controller.dart';
  import 'package:flutter_svg/svg.dart';
  import 'package:get/get.dart';
  import 'package:image_picker/image_picker.dart';
  
  void main() {
    runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return GetMaterialApp(
        title: 'Image Upload',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          primarySwatch: Colors.blue,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        home: MyHomePage(title: 'Flutter Demo Home Page'),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    MyHomePage({Key key, this.title}) : super(key: key);
    final String title;
  
    @override
    _MyHomePageState createState() => _MyHomePageState();
  }
  
  class _MyHomePageState extends State<MyHomePage> {
    final ProfileController profilerController = Get.put(ProfileController());
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Center(
          child: Container(
            decoration: BoxDecoration(
              boxShadow: <BoxShadow>[
                BoxShadow(
                  color: Colors.grey.withOpacity(0.3),
                  blurRadius: 40,
                ),
              ],
            ),
            child: SizedBox(
              height: 115,
              width: 115,
              child: Stack(
                fit: StackFit.expand,
                overflow: Overflow.visible,
                children: [
                  Obx((){
                    if(profilerController.isLoading.value){
                      return CircleAvatar(
                        backgroundImage: AssetImage('assets/icons/no_user.jpg'),
                        child: Center(
                            child: CircularProgressIndicator(
                              backgroundColor: Colors.white,
                            )),
                      );
                    } else {
                      if(profilerController.imageURL.length != 0){
                        return CachedNetworkImage(
                          imageUrl: profilerController.imageURL,
                          fit: BoxFit.cover,
                          imageBuilder: (context, imageProvider) => CircleAvatar(
                            backgroundColor: Colors.white,
                            backgroundImage: imageProvider,
                          ),
                          placeholder: (context, url) => CircleAvatar(
                            backgroundImage: AssetImage('assets/icons/no_user.jpg'),
                            child: Center(
                                child: CircularProgressIndicator(
                                  backgroundColor: Colors.white,
                                )),
                          ),
                          errorWidget: (context, url, error) => Icon(Icons.error),
                        );
                      } else {
                        return CircleAvatar(
                          backgroundImage: AssetImage('assets/icons/no_user.jpg'),
                        );
                      }
                    }
                  }),
                  Positioned(
                    right: -16,
                    bottom: 0,
                    child: SizedBox(
                      height: 46,
                      width: 46,
                      child: FlatButton(
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(50),
                          side: BorderSide(color: Colors.white),
                        ),
                        color: Colors.grey[200],
                        onPressed: () {
                          Get.bottomSheet(
                            Container(
                              decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: const BorderRadius.only(
                                    topLeft: Radius.circular(16.0),
                                    topRight: Radius.circular(16.0)),
                              ),
                              child: Wrap(
                                alignment: WrapAlignment.end,
                                crossAxisAlignment: WrapCrossAlignment.end,
                                children: [
                                  ListTile(
                                    leading: Icon(Icons.camera),
                                    title: Text('Camera'),
                                    onTap: () {
                                      Get.back();
                                      profilerController.uploadImage(ImageSource.camera);
                                    },
                                  ),
                                  ListTile(
                                    leading: Icon(Icons.image),
                                    title: Text('Gallery'),
                                    onTap: () {
                                      Get.back();
                                      profilerController
                                          .uploadImage(ImageSource.gallery);
                                    },
                                  ),
                                ],
                              ),
                            ),
                          );
                        },
                        child: SvgPicture.asset("assets/icons/Camera Icon.svg"),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        )
      );
    }
  }
  