reason

上传头像

...@@ -19,12 +19,16 @@ ...@@ -19,12 +19,16 @@
19 while the Flutter UI initializes. After that, this theme continues 19 while the Flutter UI initializes. After that, this theme continues
20 to determine the Window background behind the Flutter UI. --> 20 to determine the Window background behind the Flutter UI. -->
21 <intent-filter> 21 <intent-filter>
22 - <action android:name="android.intent.action.MAIN"/> 22 + <action android:name="android.intent.action.MAIN" />
23 - <category android:name="android.intent.category.LAUNCHER"/> 23 + <category android:name="android.intent.category.LAUNCHER" />
24 </intent-filter> 24 </intent-filter>
25 </activity> 25 </activity>
26 <!-- Don't delete the meta-data below. 26 <!-- Don't delete the meta-data below.
27 This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> 27 This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
28 + <activity
29 + android:name="com.yalantis.ucrop.UCropActivity"
30 + android:screenOrientation="portrait"
31 + android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
28 <meta-data 32 <meta-data
29 android:name="flutterEmbedding" 33 android:name="flutterEmbedding"
30 android:value="2" /> 34 android:value="2" />
......
1 -import 'dart:io';
2 -
3 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
4 import 'package:Parlando/extension/int_extension.dart'; 2 import 'package:Parlando/extension/int_extension.dart';
5 import 'package:Parlando/widgets/my_app_bar.dart'; 3 import 'package:Parlando/widgets/my_app_bar.dart';
6 import 'package:flutter_gen/gen_l10n/Parlando_localizations.dart'; 4 import 'package:flutter_gen/gen_l10n/Parlando_localizations.dart';
5 +import 'package:image_cropper/image_cropper.dart';
7 import 'package:image_picker/image_picker.dart'; 6 import 'package:image_picker/image_picker.dart';
8 7
9 class AccountEditPage extends StatefulWidget { 8 class AccountEditPage extends StatefulWidget {
...@@ -95,7 +94,17 @@ class MapScreenState extends State<AccountEditPage> ...@@ -95,7 +94,17 @@ class MapScreenState extends State<AccountEditPage>
95 ), 94 ),
96 ), 95 ),
97 onTap: () { 96 onTap: () {
98 - _getImage(); 97 + Navigator.pop(context);
98 + onImageButtonPressed(
99 + ImageSource.camera,
100 + context: context,
101 + capturedImageFile: (s) {
102 + setState(() {
103 + print(s);
104 + // _imageFile = s;
105 + });
106 + },
107 + );
99 }, 108 },
100 ), 109 ),
101 ListTile( 110 ListTile(
...@@ -108,10 +117,13 @@ class MapScreenState extends State<AccountEditPage> ...@@ -108,10 +117,13 @@ class MapScreenState extends State<AccountEditPage>
108 ), 117 ),
109 ), 118 ),
110 onTap: () { 119 onTap: () {
120 + Navigator.pop(context);
111 onImageButtonPressed( 121 onImageButtonPressed(
112 - ImageSource.gallery, context: context, 122 + ImageSource.gallery,
123 + context: context,
113 capturedImageFile: (s) { 124 capturedImageFile: (s) {
114 - print("file path ${s}"); 125 + print(
126 + "file path ${s}");
115 setState(() { 127 setState(() {
116 // _imageFile = s; 128 // _imageFile = s;
117 }); 129 });
...@@ -463,32 +475,46 @@ class MapScreenState extends State<AccountEditPage> ...@@ -463,32 +475,46 @@ class MapScreenState extends State<AccountEditPage>
463 } 475 }
464 } 476 }
465 477
478 +typedef CapturedImageFile = String Function(String);
479 +typedef OnPickImageCallback = void Function(
480 + double maxWidth, double maxHeight, int quality);
481 +
466 onImageButtonPressed(ImageSource source, 482 onImageButtonPressed(ImageSource source,
467 {required BuildContext context, capturedImageFile}) async { 483 {required BuildContext context, capturedImageFile}) async {
468 final ImagePicker _picker = ImagePicker(); 484 final ImagePicker _picker = ImagePicker();
469 - File val;
470 -
471 final pickedFile = await _picker.pickImage( 485 final pickedFile = await _picker.pickImage(
472 source: source, 486 source: source,
473 ); 487 );
474 488
475 - val = await ImageCropper.cropImage( 489 + if (pickedFile == null) {
490 + capturedImageFile(pickedFile!.path);
491 + return;
492 + }
493 + CroppedFile? croppedFile = await ImageCropper().cropImage(
476 sourcePath: pickedFile.path, 494 sourcePath: pickedFile.path,
477 - aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1), 495 + aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1),
478 compressQuality: 100, 496 compressQuality: 100,
479 maxHeight: 700, 497 maxHeight: 700,
480 maxWidth: 700, 498 maxWidth: 700,
481 - compressFormat: ImageCompressFormat.jpg, 499 + compressFormat: ImageCompressFormat.png,
482 - androidUiSettings: AndroidUiSettings( 500 + aspectRatioPresets: [
483 - toolbarColor: Colors.white, 501 + CropAspectRatioPreset.square,
484 - toolbarTitle: "genie cropper", 502 + CropAspectRatioPreset.ratio3x2,
485 - ), 503 + CropAspectRatioPreset.original,
504 + CropAspectRatioPreset.ratio4x3,
505 + CropAspectRatioPreset.ratio16x9
506 + ],
507 + uiSettings: [
508 + AndroidUiSettings(
509 + toolbarTitle: '裁剪',
510 + toolbarColor: Colors.deepOrange,
511 + toolbarWidgetColor: Colors.white,
512 + initAspectRatio: CropAspectRatioPreset.original,
513 + lockAspectRatio: false),
514 + IOSUiSettings(
515 + title: '裁剪',
516 + ),
517 + ],
486 ); 518 );
487 - print("cropper ${val.runtimeType}"); 519 + capturedImageFile(croppedFile!.path);
488 - capturedImageFile(val.path);
489 -
490 } 520 }
491 -
492 -typedef capturedImageFile = String Function(String);
493 -typedef void OnPickImageCallback(
494 - double maxWidth, double maxHeight, int quality);
...\ No newline at end of file ...\ No newline at end of file
......
This diff is collapsed. Click to expand it.