I am building a Photo editing app in flutter which can apply built in photo filters on an image picked from gallery

Can anyone help me on how to write code for the same ?

@Sucharita Welcome to FlutterForum!

I would strongly suggest you against asking for code here directly. Always do your own research, try some things and then you can ask here if you are stuck somewhere.

Having said that, I am leaving a resource here that can help you get started. Its a plugin for photo filters.

I have already tried this. It’s not working. Is there no other way?

Can you be more clear than “It’s not working”. Perhaps if you share the problem/error we can give a solution. Also, if the package is maintained then you should try opening an issue on their Github.

It is working till the point of selecting a picture and applying a filter. Now I need to save the photo in my phone. But when I touch the tick mark button it goes back to initial screen. Also how do I put my own customised filters ?

Hi, please share code snippet that you feel is causing the problem.

1 Like

Below is the code snippet :

Also, I want to include my own custom filters instead of the inbuilt ones. I have my filters in the form of DNG files or Presets for Lightroom.

import ‘package:flutter/material.dart’;
import ‘dart:io’;
import ‘package:path/path.dart’;
import ‘package:photofilters/photofilters.dart’;
import ‘package:image_picker/image_picker.dart’;
import ‘package:image/image.dart’ as imageLib;

class Edit extends StatefulWidget {
@override
_EditState createState() => _EditState();
}

class _EditState extends State {
imageLib.Image _image;
//File _image;
String fileName;
Filter _filter;
List filters = presetFiltersList;
final picker = ImagePicker();
Future getImage() async {
PickedFile pickedFile = await picker.getImage(source: ImageSource.gallery);
fileName = basename(pickedFile.path);
File _file = File(pickedFile.path);
_image = imageLib.decodeImage(_file.readAsBytesSync());
setState(() {
if (pickedFile != null) {
//_image = File(pickedFile.path);
} else {
print(‘No image selected.’);
}
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton.extended(
onPressed: () async {
await getImage();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PhotoFilterSelector(
title: Text(“Photo Filter Example”),
image: _image,
filters: filters,
filename: fileName,
loader: Center(child: CircularProgressIndicator()),
),
));
},
label: Text(""),
icon: Icon(
Icons.camera,
color: Colors.black,
),
),

);

}
}