Flutter: how to create custom shader

Viewed 817

I want to create custom camera preview pixelate filter: Example Pixelate IMG

Code to add gradient filter:

home: Scaffold(
      appBar: AppBar(
        title: Text('Welcome to Flutter'),
      ),
      body: ShaderMask(
        shaderCallback: (Rect bounds) {
          return LinearGradient(
            colors: <Color>[Colors.green, Colors.deepOrange, Colors.blue],
            tileMode: TileMode.mirror,
          ).createShader(bounds);
        },
        child: AspectRatio(
            aspectRatio:
            controller.value.aspectRatio,
            child: CameraPreview(controller)
        ),
      )
  )

Example Gradient IMG

There is no shader in flutter for this and I didn't find how to create custom shader.

0 Answers
Related