HttpInput for image_size_getter



  1. normally, you should use the api provided by your application server or image server to get the image size instead of using this method.

  2. If you don't have an application server or if the server can't provide the information, then there is another suggestion.

    • The server support range header and provide content-length header.
    • Image files larger than 5m or even 10m, as range fetching may require 5 ~ 20 interactions with the server to get the image size.


import 'package:image_size_getter/image_size_getter.dart';
import 'package:image_size_getter_http_input/image_size_getter_http_input.dart';

Future<void> foo() async{
  final testUrl =
  final httpInput = await HttpInput.createHttpInput(testUrl);

  final size = await ImageSizeGetter.getSizeAsync(httpInput);
  print('size: $size');


If you are using a non-web environment, then when you request a server that does not support range load, if you are worried about using too much memory, then you can use file as a cache, use httpCachePath to set it, or if not, it will use the memory cache. The cache file will be deleted automatically when the fetch size is done.


Apache License 2.0


Support for doing something awesome.