mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-25 01:05:36 +00:00
refactor: standardize Dart and Android config across all 54 apps
- Bump all apps to sdk >=3.0.0 <4.0.0 and add flutter_lints + a shared analysis_options.yaml to every app (flutter analyze is now green repo-wide) - Fix real compile errors in firebase_google_authentication and image_editor, plus deprecated APIs (Matrix4, SvgPicture.color, textScaleFactor), missing async 'mounted' guards, and misc lints via dart fix + manual fixes - Align pubspec 'name' with each folder and Android namespace/applicationId with the documented github.nisrulz.* convention - Convert bmi_calculator from a legacy Flutter module to a standard app with a proper android/ scaffold; fix missing android:exported in launcher manifests across 22 apps so all Android builds pass - Untrack generated build files (GeneratedPluginRegistrant, .flutter-plugins-dependencies) and ignore them
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import 'package:photofilters/photofilters.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:image/image.dart' as imageLib;
|
||||
import 'package:image/image.dart' as image_lib;
|
||||
|
||||
ApplyFilters(context, _image) async {
|
||||
var image = imageLib.decodeImage(_image.readAsBytesSync())!;
|
||||
image = imageLib.copyResize(image, width: 600);
|
||||
String fileName = basename(_image.path);
|
||||
Future<dynamic> ApplyFilters(context, image) async {
|
||||
var decoded = image_lib.decodeImage(image.readAsBytesSync())!;
|
||||
decoded = image_lib.copyResize(decoded, width: 600);
|
||||
String fileName = basename(image.path);
|
||||
Map imagefile = await Navigator.push(
|
||||
context,
|
||||
new MaterialPageRoute(
|
||||
builder: (context) => new PhotoFilterSelector(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PhotoFilterSelector(
|
||||
title: Text("Photo Filter Example"),
|
||||
image: image,
|
||||
image: decoded,
|
||||
appBarColor: Colors.greenAccent[400]!,
|
||||
filters: presetFiltersList,
|
||||
filename: fileName,
|
||||
@@ -21,9 +21,8 @@ ApplyFilters(context, _image) async {
|
||||
),
|
||||
),
|
||||
);
|
||||
if (imagefile != null && imagefile.containsKey('image_filtered')) {
|
||||
_image = imagefile['image_filtered'];
|
||||
return _image;
|
||||
if (imagefile.containsKey('image_filtered')) {
|
||||
return imagefile['image_filtered'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
|
||||
EditImg(_image) async {
|
||||
Future<dynamic> EditImg(image) async {
|
||||
var CroppedImg =
|
||||
await ImageCropper().cropImage(sourcePath: _image.path, uiSettings: [
|
||||
await ImageCropper().cropImage(sourcePath: image.path, uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: 'Cropper',
|
||||
toolbarColor: Colors.greenAccent[400],
|
||||
@@ -15,8 +15,9 @@ EditImg(_image) async {
|
||||
),
|
||||
]);
|
||||
if (CroppedImg != null) {
|
||||
_image = CroppedImg;
|
||||
return _image;
|
||||
} else
|
||||
image = CroppedImg;
|
||||
return image;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'dart:io';
|
||||
|
||||
GetiImg(_image) async {
|
||||
Future<dynamic> GetiImg(image) async {
|
||||
var pickedFile = await ImagePicker().pickImage(source: ImageSource.gallery);
|
||||
if (pickedFile != null) {
|
||||
_image = File(pickedFile.path);
|
||||
return _image;
|
||||
image = File(pickedFile.path);
|
||||
return image;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:image_editor/ApplyFilters.dart';
|
||||
import 'package:image_editor/EditImg.dart';
|
||||
import 'package:image_editor/GetImg.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:image_editor/SaveInGallery.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
@@ -15,7 +16,8 @@ class _HomePageState extends State<HomePage> {
|
||||
bool _selected = false; //to check if a image is selected or not
|
||||
late File
|
||||
_image; //here we will store the selected image and apply modifications
|
||||
double _ImageContainerHeight = 450, _ImageContainerWidth = 400;
|
||||
final double _ImageContainerHeight = 450;
|
||||
final double _ImageContainerWidth = 400;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -27,7 +29,7 @@ class _HomePageState extends State<HomePage> {
|
||||
body: Container(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
SizedBox(
|
||||
height: _ImageContainerHeight,
|
||||
width: _ImageContainerWidth,
|
||||
child: _selected // checks if a image is selected or not
|
||||
@@ -46,11 +48,11 @@ class _HomePageState extends State<HomePage> {
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () async {
|
||||
var _Ifile = await GetiImg(
|
||||
var Ifile = await GetiImg(
|
||||
_image); // function called from GetImg.dart
|
||||
if (_Ifile != null) {
|
||||
if (Ifile != null) {
|
||||
setState(() {
|
||||
_image = _Ifile;
|
||||
_image = Ifile;
|
||||
_selected = true;
|
||||
});
|
||||
}
|
||||
@@ -66,23 +68,12 @@ class _HomePageState extends State<HomePage> {
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () async {
|
||||
if (_image != null) {
|
||||
var _Ifile = await EditImg(
|
||||
_image); // function called from EditImg.dart
|
||||
if (_Ifile != null) {
|
||||
setState(() {
|
||||
_image = _Ifile;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: "Select a image first :-(",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
timeInSecForIosWeb: 1,
|
||||
backgroundColor: Colors.green,
|
||||
textColor: Colors.white,
|
||||
fontSize: 16.0);
|
||||
var Ifile0 = await EditImg(
|
||||
_image); // function called from EditImg.dart
|
||||
if (Ifile0 != null) {
|
||||
setState(() {
|
||||
_image = Ifile0;
|
||||
});
|
||||
}
|
||||
}),
|
||||
Spacer(
|
||||
@@ -103,23 +94,12 @@ class _HomePageState extends State<HomePage> {
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () async {
|
||||
if (_image != null) {
|
||||
var _Ifile = await ApplyFilters(context,
|
||||
_image); // function called from ApplyFilters.dart
|
||||
if (_Ifile != null) {
|
||||
setState(() {
|
||||
_image = _Ifile;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: "Select a image first :-(",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
timeInSecForIosWeb: 1,
|
||||
backgroundColor: Colors.green,
|
||||
textColor: Colors.white,
|
||||
fontSize: 16.0);
|
||||
var Ifile0 = await ApplyFilters(context,
|
||||
_image); // function called from ApplyFilters.dart
|
||||
if (Ifile0 != null) {
|
||||
setState(() {
|
||||
_image = Ifile0;
|
||||
});
|
||||
}
|
||||
}),
|
||||
Spacer(
|
||||
@@ -133,19 +113,8 @@ class _HomePageState extends State<HomePage> {
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () async {
|
||||
if (_image != null) {
|
||||
await SaveImg(
|
||||
_image); // function called from SaveInGallery.dart
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: "Select a image first :-(",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
timeInSecForIosWeb: 1,
|
||||
backgroundColor: Colors.green,
|
||||
textColor: Colors.white,
|
||||
fontSize: 16.0);
|
||||
}
|
||||
await SaveImg(
|
||||
_image); // function called from SaveInGallery.dart
|
||||
}),
|
||||
Spacer(
|
||||
flex: 2,
|
||||
|
||||
@@ -2,10 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:gallery_saver_plus/gallery_saver.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
SaveImg(_image) async {
|
||||
var result =
|
||||
await GallerySaver.saveImage(_image.path, albumName: 'ImageEditor')
|
||||
.then((bool? success) {
|
||||
Future<void> SaveImg(image) async {
|
||||
await GallerySaver.saveImage(image.path, albumName: 'ImageEditor')
|
||||
.then((bool? success) {
|
||||
success == true
|
||||
? Fluttertoast.showToast(
|
||||
msg: "Image saved in gallery/ImageEditor",
|
||||
|
||||
@@ -6,6 +6,8 @@ void main() {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user