reason

上传头像

......@@ -19,12 +19,16 @@
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<meta-data
android:name="flutterEmbedding"
android:value="2" />
......
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:Parlando/extension/int_extension.dart';
import 'package:Parlando/widgets/my_app_bar.dart';
import 'package:flutter_gen/gen_l10n/Parlando_localizations.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';
class AccountEditPage extends StatefulWidget {
......@@ -95,7 +94,17 @@ class MapScreenState extends State<AccountEditPage>
),
),
onTap: () {
_getImage();
Navigator.pop(context);
onImageButtonPressed(
ImageSource.camera,
context: context,
capturedImageFile: (s) {
setState(() {
print(s);
// _imageFile = s;
});
},
);
},
),
ListTile(
......@@ -108,10 +117,13 @@ class MapScreenState extends State<AccountEditPage>
),
),
onTap: () {
Navigator.pop(context);
onImageButtonPressed(
ImageSource.gallery, context: context,
ImageSource.gallery,
context: context,
capturedImageFile: (s) {
print("file path ${s}");
print(
"file path ${s}");
setState(() {
// _imageFile = s;
});
......@@ -463,32 +475,46 @@ class MapScreenState extends State<AccountEditPage>
}
}
typedef CapturedImageFile = String Function(String);
typedef OnPickImageCallback = void Function(
double maxWidth, double maxHeight, int quality);
onImageButtonPressed(ImageSource source,
{required BuildContext context, capturedImageFile}) async {
final ImagePicker _picker = ImagePicker();
File val;
final pickedFile = await _picker.pickImage(
source: source,
);
val = await ImageCropper.cropImage(
if (pickedFile == null) {
capturedImageFile(pickedFile!.path);
return;
}
CroppedFile? croppedFile = await ImageCropper().cropImage(
sourcePath: pickedFile.path,
aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1),
aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1),
compressQuality: 100,
maxHeight: 700,
maxWidth: 700,
compressFormat: ImageCompressFormat.jpg,
androidUiSettings: AndroidUiSettings(
toolbarColor: Colors.white,
toolbarTitle: "genie cropper",
),
compressFormat: ImageCompressFormat.png,
aspectRatioPresets: [
CropAspectRatioPreset.square,
CropAspectRatioPreset.ratio3x2,
CropAspectRatioPreset.original,
CropAspectRatioPreset.ratio4x3,
CropAspectRatioPreset.ratio16x9
],
uiSettings: [
AndroidUiSettings(
toolbarTitle: '裁剪',
toolbarColor: Colors.deepOrange,
toolbarWidgetColor: Colors.white,
initAspectRatio: CropAspectRatioPreset.original,
lockAspectRatio: false),
IOSUiSettings(
title: '裁剪',
),
],
);
print("cropper ${val.runtimeType}");
capturedImageFile(val.path);
capturedImageFile(croppedFile!.path);
}
typedef capturedImageFile = String Function(String);
typedef void OnPickImageCallback(
double maxWidth, double maxHeight, int quality);
\ No newline at end of file
......
This diff is collapsed. Click to expand it.