Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies, refactor code for newer dart version #72

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="photofilters_example"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -23,13 +23,9 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
android:name="flutterEmbedding"
android:value="2" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package com.skkallayath.photofiltersexample;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
73 changes: 37 additions & 36 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,69 @@ import 'package:photofilters/photofilters.dart';
import 'package:image/image.dart' as imageLib;
import 'package:image_picker/image_picker.dart';

void main() => runApp(new MaterialApp(home: MyApp()));
void main() => runApp(const MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
const MyApp({super.key});

@override
_MyAppState createState() => new _MyAppState();
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
String fileName;
List<Filter> filters = presetFiltersList;
final picker = ImagePicker();
File imageFile;
File? imageFile;

Future getImage(context) async {
final pickedFile = await picker.getImage(source: ImageSource.gallery);
final pickedFile = await picker.pickImage(source: ImageSource.gallery);
if(pickedFile!=null){
imageFile = new File(pickedFile.path);
fileName = basename(imageFile.path);
var image = imageLib.decodeImage(await imageFile.readAsBytes());
image = imageLib.copyResize(image, width: 600);
Map imagefile = await Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new PhotoFilterSelector(
title: Text("Photo Filter Example"),
image: image,
filters: presetFiltersList,
filename: fileName,
loader: Center(child: CircularProgressIndicator()),
fit: BoxFit.contain,
final File imageFile = File(pickedFile.path);
final String fileName = basename(imageFile.path);
var image = imageLib.decodeImage(await imageFile.readAsBytes())!;
image = imageLib.copyResize(image, width: 600);
Map imagefile = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PhotoFilterSelector(
title: Text("Photo Filter Example"),
image: image,
filters: presetFiltersList,
filename: fileName,
loader: Center(child: CircularProgressIndicator()),
fit: BoxFit.contain,
),
),
),
);

if (imagefile != null && imagefile.containsKey('image_filtered')) {
setState(() {
imageFile = imagefile['image_filtered'];
});
print(imageFile.path);
}
);

if (imagefile.containsKey('image_filtered')) {
setState(() {
this.imageFile = imagefile['image_filtered'];
});
print(imageFile.path);
}
}
}

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Photo Filter Example'),
return Scaffold(
appBar: AppBar(
title: Text('Photo Filter Example'),
),
body: Center(
child: new Container(
child: Container(
child: imageFile == null
? Center(
child: new Text('No image selected.'),
child: Text('No image selected.'),
)
: Image.file(new File(imageFile.path)),
: Image.file(File(imageFile!.path)),
),
),
floatingActionButton: new FloatingActionButton(
floatingActionButton: FloatingActionButton(
onPressed: () => getImage(context),
tooltip: 'Pick Image',
child: new Icon(Icons.add_a_photo),
child: Icon(Icons.add_a_photo),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: Demonstrates how to use the photofilters plugin.
version: 1.0.0+1

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.19.0 <3.0.0"

dependencies:
flutter:
Expand Down
4 changes: 2 additions & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import '../lib/main.dart';
void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(new MyApp());
await tester.pumpWidget(MyApp());

// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) =>
widget is Text && widget.data.startsWith('Running on:'),
widget is Text && (widget.data?.startsWith('Running on:') ?? false),
),
findsOneWidget);
});
Expand Down
32 changes: 16 additions & 16 deletions lib/filters/convolution_filters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ import 'package:photofilters/filters/image_filters.dart';
import 'package:photofilters/filters/subfilters.dart';
import 'package:photofilters/utils/convolution_kernels.dart';

var presetConvolutionFiltersList = [
new ImageFilter(name: "Identity")
final presetConvolutionFiltersList = [
ImageFilter(name: "Identity")
..addSubFilter(ConvolutionSubFilter.fromKernel(identityKernel)),
new ImageFilter(name: "Sharpen")
ImageFilter(name: "Sharpen")
..addSubFilter(ConvolutionSubFilter.fromKernel(sharpenKernel)),
new ImageFilter(name: "Emboss")
ImageFilter(name: "Emboss")
..addSubFilter(ConvolutionSubFilter.fromKernel(embossKernel)),
new ImageFilter(name: "Colored Edge Detection")
ImageFilter(name: "Colored Edge Detection")
..subFilters
.add(ConvolutionSubFilter.fromKernel(coloredEdgeDetectionKernel)),
new ImageFilter(name: "Edge Detection Medium")
ImageFilter(name: "Edge Detection Medium")
..subFilters
.add(ConvolutionSubFilter.fromKernel(edgeDetectionMediumKernel)),
new ImageFilter(name: "Edge Detection Hard")
ImageFilter(name: "Edge Detection Hard")
..addSubFilter(ConvolutionSubFilter.fromKernel(edgeDetectionHardKernel)),
new ImageFilter(name: "Blur")
ImageFilter(name: "Blur")
..addSubFilter(ConvolutionSubFilter.fromKernel(blurKernel)),
new ImageFilter(name: "Guassian 3x3")
ImageFilter(name: "Guassian 3x3")
..addSubFilter(ConvolutionSubFilter.fromKernel(guassian3x3Kernel)),
new ImageFilter(name: "Guassian 5x5")
ImageFilter(name: "Guassian 5x5")
..addSubFilter(ConvolutionSubFilter.fromKernel(guassian5x5Kernel)),
new ImageFilter(name: "Guassian 7x7")
ImageFilter(name: "Guassian 7x7")
..addSubFilter(ConvolutionSubFilter.fromKernel(guassian7x7Kernel)),
new ImageFilter(name: "Mean 3x3")
ImageFilter(name: "Mean 3x3")
..addSubFilter(ConvolutionSubFilter.fromKernel(mean3x3Kernel)),
new ImageFilter(name: "Mean 5x5")
ImageFilter(name: "Mean 5x5")
..addSubFilter(ConvolutionSubFilter.fromKernel(mean5x5Kernel)),
new ImageFilter(name: "Low Pass 3x3")
ImageFilter(name: "Low Pass 3x3")
..addSubFilter(ConvolutionSubFilter.fromKernel(lowPass3x3Kernel)),
new ImageFilter(name: "Low Pass 5x5")
ImageFilter(name: "Low Pass 5x5")
..addSubFilter(ConvolutionSubFilter.fromKernel(lowPass5x5Kernel)),
new ImageFilter(name: "High Pass 3x3")
ImageFilter(name: "High Pass 3x3")
..addSubFilter(ConvolutionSubFilter.fromKernel(highPass3x3Kernel)),
];
2 changes: 1 addition & 1 deletion lib/filters/filters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:typed_data';
///The [Filter] class to define a Filter consists of multiple [SubFilter]s
abstract class Filter extends Object {
final String name;
Filter({required this.name});
const Filter({required this.name});

///Apply the [SubFilter] to an Image.
void apply(Uint8List pixels, int width, int height);
Expand Down
2 changes: 1 addition & 1 deletion lib/filters/image_filters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mixin ImageSubFilter on SubFilter {
}

class ImageFilter extends Filter {
List<ImageSubFilter> subFilters;
final List<ImageSubFilter> subFilters;

ImageFilter({required String name})
: subFilters = [],
Expand Down
Loading