feat:增加参数

This commit is contained in:
2025-11-14 11:35:45 +08:00
parent 74f412886c
commit f0f8d9ef69
12 changed files with 1063 additions and 54 deletions

View File

@@ -2,6 +2,9 @@ import 'package:dio/dio.dart';
import 'package:example/exif/customer_exif_Page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_common/upload_image/look_images_widget.dart';
import 'package:flutter_common/upload_image/upload_images_tool.dart';
import 'package:get/get.dart';
import 'package:image_editor_plus/image_editor_plus.dart';
void main() {
@@ -14,34 +17,21 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
return GetMaterialApp(
title: '熊猫文旅通',
debugShowCheckedModeBanner: false,
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
appBarTheme: AppBarTheme(surfaceTintColor: Colors.transparent),
scaffoldBackgroundColor: const Color(0xffF5F5F5),
// useMaterial3: true,
// colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple)
// .copyWith(background: const Color(0xffF5F5F5)),
),
// home: const MyHomePage(title: 'Flutter Demo Home Page'),
home: CustomerExifPage(),
home: const MyHomePage(title: '编辑图片'),
);
}
}
/// Dio 最简版:网络图片转 Uint8List
Future<Uint8List?> networkImageToUint8ListWithDio(String imageUrl) async {
final dio = Dio(); // 初始化 Dio 实例
@@ -52,16 +42,13 @@ Future<Uint8List?> networkImageToUint8ListWithDio(String imageUrl) async {
options: Options(responseType: ResponseType.bytes),
);
// 响应成功且数据非空时,直接转为 Uint8List
return response.statusCode == 200 && response.data != null
? Uint8List.fromList(response.data!)
: null;
return response.statusCode == 200 && response.data != null ? Uint8List.fromList(response.data!) : null;
} catch (e) {
print('图片转换失败:$e'); // 捕获网络错误、URL 非法等异常
return null;
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
@@ -83,16 +70,15 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
final int _counter = 0;
Future<void> _incrementCounter()async {
String imageUrl = 'https://static.cop.jingheyijia.com/wxapp-map2/upload/moment/20251029/app-bpItvFOQufCL.jpg';
Uint8List? imageBytes = await networkImageToUint8ListWithDio(imageUrl);
Future<Uint8List?> editImage({required String url})async{
Uint8List? imageBytes = await networkImageToUint8ListWithDio(url);
ImageEditor.setI18n({
'crop': '裁剪',
'rotate left': '左旋转',
'rotate right': '右旋转',
'flip': '水平翻转',
'brush': '涂抹',
'link':'链接',
'link': '链接',
'save': '保存',
'text': '文本',
'blur': '模糊',
@@ -109,8 +95,8 @@ class _MyHomePageState extends State<MyHomePage> {
'color opacity': '透明度',
'blur radius': '模糊半径',
});
if(mounted){
final editedImage = await Navigator.push(
if (mounted) {
Uint8List? editedImage = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImageEditor(
@@ -123,10 +109,16 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
);
return editedImage;
}
return null;
}
Future<void> _incrementCounter() async {
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
@@ -181,4 +173,4 @@ class _MyHomePageState extends State<MyHomePage> {
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
}