builder method

  1. @override
Widget builder(
  1. BuildContext context,
  2. ImageViewModel viewModel,
  3. Widget? child
)

A function that builds the UI to be shown from the ViewModel - Required

viewModel is the ViewModel passed in and child is the staticChildBuilder result

Implementation

@override
Widget builder(
  BuildContext context,
  ImageViewModel viewModel,
  Widget? child,
) {
  return Scaffold(
    body: Stack(
      children: [
        PhotoView(
          imageProvider: NetworkImage(url),
        ),
        if (imageDownloadButton)
          Positioned(
            top: 50,
            right: 20,
            child: IconButton(
              onPressed: () {
                viewModel.saveImage(context, url);
              },
              icon: CircleAvatar(
                backgroundColor: Colors.grey.shade500,
                child: const Icon(
                  Icons.download,
                  color: Colors.white,
                ),
              ),
            ),
          ),
        // Positioned(
        //   top: 50,
        //   left: 20,
        //   child: IconButton(
        //     onPressed: () {
        //       Navigator.pop(context);
        //     },
        //     icon: const Icon(
        //       Icons.close,
        //       color: Colors.white,
        //     ),
        //   ),
        // ),
      ],
    ),
  );
}