How to solve: Using nearest neighbour interpolation for flutter image

Question

Asked by Giffesnaffen on September 16, 2018 (source).

How do I get flutter to resize my Image widgets using nearest neighbour interpolation if the size of the widget is not the same as the asset size?

class PlayContainer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color.fromARGB(255, 0, 110, 255),
      child: SafeArea(
        child: Image(
          fit: BoxFit.contain,
          image: AssetImage("assets/knight.png")
        )
      )
    );
  }
}

This resizes the image correctly, but it is blurry due to the bilinear interpolation used to resize it.

Based on the source seems to be rather hard coded?

Answer

Question answered by Giffesnaffen (source).

This is now possible in the master branch thanks to this Pull request:

I've added the possibility to set the filterQuality on Images. This was hardcoded.
The previously hardcoded value is set as default parameter.

Some images look better when scaled with no filter quality (like pixelart). That's why I added the parameter.

FLUTTER
SHARE: