Reason Pun

U

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_picker/image_picker.dart';
class AccountEditPage extends StatefulWidget {
const AccountEditPage({Key? key}) : super(key: key);
......@@ -66,13 +69,60 @@ class MapScreenState extends State<AccountEditPage>
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircleAvatar(
InkWell(
child: CircleAvatar(
backgroundColor: Colors.red,
radius: 25.px,
child: const Icon(
Icons.camera_alt,
color: Colors.white,
),
),
onTap: () {
showModalBottomSheet(
context: context,
builder: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
title: const Center(
child: Text(
'拍照',
style: TextStyle(
fontSize: 18,
),
),
),
onTap: () {
_getImage();
},
),
ListTile(
title: const Center(
child: Text(
'相册',
style: TextStyle(
fontSize: 18,
),
),
),
onTap: () {
onImageButtonPressed(
ImageSource.gallery, context: context,
capturedImageFile: (s) {
print("file path ${s}");
setState(() {
// _imageFile = s;
});
},
);
},
),
],
);
});
},
)
],
)),
......@@ -412,3 +462,33 @@ class MapScreenState extends State<AccountEditPage>
);
}
}
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(
sourcePath: pickedFile.path,
aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1),
compressQuality: 100,
maxHeight: 700,
maxWidth: 700,
compressFormat: ImageCompressFormat.jpg,
androidUiSettings: AndroidUiSettings(
toolbarColor: Colors.white,
toolbarTitle: "genie cropper",
),
);
print("cropper ${val.runtimeType}");
capturedImageFile(val.path);
}
typedef capturedImageFile = String Function(String);
typedef void OnPickImageCallback(
double maxWidth, double maxHeight, int quality);
\ No newline at end of file
......
......@@ -52,7 +52,8 @@ dependencies:
# 启动URL的插件(支持Web) https://github.com/flutter/plugins/tree/master/packages/url_launcher
url_launcher: ^6.0.18
# 图片选择插件(支持Web) https://github.com/flutter/plugins/tree/master/packages/image_picker
image_picker: ^0.8.4+5
image_picker: ^0.8.5
image_cropper: ^2.0.0
# 侧滑删除 https://github.com/letsar/flutter_slidable
flutter_slidable: ^1.1.0
# WebView插件 https://github.com/flutter/plugins/tree/master/packages/webview_flutter
......