Compare commits

...

3 Commits

Author SHA1 Message Date
be5b5bb951 Merge branch 'main_2.0'
# Conflicts:
#	.dart_tool/package_config.json
#	.flutter-plugins-dependencies
#	.idea/libraries/Dart_Packages.xml
#	example/pubspec.lock
2026-04-16 10:43:36 +08:00
6da78ca2a5 feat(date):更新日期组件 2026-04-16 10:35:06 +08:00
7b2dd68ab3 feat(http):更新 2026-04-14 16:54:47 +08:00
9 changed files with 399 additions and 234 deletions

View File

@@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>

View File

@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'
# platform :ios, '13.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View File

@@ -9,8 +9,10 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3810EC0B833FB696ECB0E8F1 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C882210DAC37E00C12DB920 /* Pods_RunnerTests.framework */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
795E4793D6FDF6E686105DA3 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C1BE5193813D44D03691616 /* Pods_Runner.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
@@ -42,12 +44,19 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2542757634BAD53EAB262497 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
3254D74A400007A51BA693BA /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3986E8E115937116F3ADD579 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
59B1152CF608C2E887BB3A53 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
5C882210DAC37E00C12DB920 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6983FF8A8204756CC5DB0EB7 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
8C1BE5193813D44D03691616 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -55,13 +64,23 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C78B74FD1ABB9E4E1C458A91 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
183633CEAFA3873F811B38A7 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3810EC0B833FB696ECB0E8F1 /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
795E4793D6FDF6E686105DA3 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -76,6 +95,20 @@
path = RunnerTests;
sourceTree = "<group>";
};
66209D553BE7631C913C10E7 /* Pods */ = {
isa = PBXGroup;
children = (
C78B74FD1ABB9E4E1C458A91 /* Pods-Runner.debug.xcconfig */,
3254D74A400007A51BA693BA /* Pods-Runner.release.xcconfig */,
3986E8E115937116F3ADD579 /* Pods-Runner.profile.xcconfig */,
2542757634BAD53EAB262497 /* Pods-RunnerTests.debug.xcconfig */,
6983FF8A8204756CC5DB0EB7 /* Pods-RunnerTests.release.xcconfig */,
59B1152CF608C2E887BB3A53 /* Pods-RunnerTests.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
@@ -94,6 +127,8 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
66209D553BE7631C913C10E7 /* Pods */,
DBECA8DE6659EEB94DE7D5DF /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -121,6 +156,15 @@
path = Runner;
sourceTree = "<group>";
};
DBECA8DE6659EEB94DE7D5DF /* Frameworks */ = {
isa = PBXGroup;
children = (
8C1BE5193813D44D03691616 /* Pods_Runner.framework */,
5C882210DAC37E00C12DB920 /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -128,8 +172,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
47B214803720B7D4C8CD5254 /* [CP] Check Pods Manifest.lock */,
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
183633CEAFA3873F811B38A7 /* Frameworks */,
);
buildRules = (
);
@@ -145,12 +191,15 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
91CC7839FB8AB75F3451971B /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
C872E8491C8002F335779847 /* [CP] Embed Pods Frameworks */,
197332DD48574943AF74C0E1 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -222,6 +271,23 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
197332DD48574943AF74C0E1 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@@ -238,6 +304,50 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
47B214803720B7D4C8CD5254 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
91CC7839FB8AB75F3451971B /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@@ -253,6 +363,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
C872E8491C8002F335779847 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -346,7 +473,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@@ -379,6 +506,7 @@
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 2542757634BAD53EAB262497 /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@@ -396,6 +524,7 @@
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 6983FF8A8204756CC5DB0EB7 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@@ -411,6 +540,7 @@
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 59B1152CF608C2E887BB3A53 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@@ -473,7 +603,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -524,7 +654,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;

View File

@@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
@@ -54,11 +55,13 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">

View File

@@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -1,11 +1,6 @@
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:flutter_common/flutter_common.dart';
import 'package:get/get.dart';
import 'package:image_editor_plus/image_editor_plus.dart';
void main() {
runApp(const MyApp());
@@ -14,163 +9,189 @@ void main() {
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: '熊猫文旅通',
title: 'flutter_common Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
appBarTheme: AppBarTheme(surfaceTintColor: Colors.transparent),
scaffoldBackgroundColor: const Color(0xffF5F5F5),
// useMaterial3: true,
// colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple)
// .copyWith(background: const Color(0xffF5F5F5)),
scaffoldBackgroundColor: const Color(0xFFF5F7FB),
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF4D6FD5)),
cardTheme: const CardThemeData(
color: Colors.white,
margin: EdgeInsets.zero,
elevation: 0,
),
),
home: const MyHomePage(title: '编辑图片'),
home: const MyHomePage(),
);
}
}
/// Dio 最简版:网络图片转 Uint8List
Future<Uint8List?> networkImageToUint8ListWithDio(String imageUrl) async {
final dio = Dio(); // 初始化 Dio 实例
try {
// 发起 GET 请求,响应类型设为字节数组(关键)
final response = await dio.get<List<int>>(
imageUrl,
options: Options(responseType: ResponseType.bytes),
);
// 响应成功且数据非空时,直接转为 Uint8List
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});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final int _counter = 0;
Future<Uint8List?> editImage({required String url})async{
Uint8List? imageBytes = await networkImageToUint8ListWithDio(url);
ImageEditor.setI18n({
'crop': '裁剪',
'rotate left': '左旋转',
'rotate right': '右旋转',
'flip': '水平翻转',
'brush': '涂抹',
'link': '链接',
'save': '保存',
'text': '文本',
'blur': '模糊',
'filter': '滤镜',
'size': '大小',
'color': '颜色',
'background color': '背景颜色',
'background opacity': '背景透明度',
'reset': '重置',
'freeform': '自由裁剪',
'remove': '移除',
'emoji': '表情',
'slider color': '滑块颜色',
'color opacity': '透明度',
'blur radius': '模糊半径',
});
if (mounted) {
Uint8List? editedImage = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImageEditor(
image: imageBytes,
blurOption: null,
filtersOption: null,
brushOption: null,
textOption: null,
emojiOption: null,
),
),
);
return editedImage;
}
return null;
}
Future<void> _incrementCounter() async {
}
String _singleDateText = '未选择';
String _rangeDateText = '未选择';
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
title: const Text('flutter_common 示例首页'),
centerTitle: true,
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
body: SafeArea(
child: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildIntroCard(),
const SizedBox(height: 16),
_buildDemoCard(
title: '单日选择组件',
description: '使用 `CalendarChooseWidget` 的单选模式,适合筛选某一天的数据。',
child: CalendarChooseWidget(
chooseIndex: 1,
selectedDate: DateTime.now(),
dateTimeUtilsType: DateTimeUtilsType.yearMonthDayWord,
fontSize: 18,
fontWeight: FontWeight.w600,
tapAction: (value) {
final startTime = value['startTime'] as DateTime?;
setState(() {
_singleDateText = _formatDate(startTime);
});
},
),
resultText: _singleDateText,
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
const SizedBox(height: 16),
_buildDemoCard(
title: '区间选择组件',
description: '默认展示开始和结束日期,适合做报表、订单或运营时间筛选。',
child: CalendarChooseWidget(
selectedDate: DateTime.now(),
dateTimeUtilsType: DateTimeUtilsType.yearMonthDay,
fontSize: 18,
fontWeight: FontWeight.w600,
tapAction: (value) {
final startTime = value['startTime'] as DateTime?;
final endTime = value['endTime'] as DateTime?;
setState(() {
_rangeDateText =
'${_formatDate(startTime)}${_formatDate(endTime)}';
});
},
),
resultText: _rangeDateText,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
Widget _buildIntroCard() {
return Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
'项目结构速览',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Color(0xFF1A1A1A),
),
),
SizedBox(height: 12),
Text(
'lib/calendarcalendar 里提供了日期选择相关组件,'
'lib/upload_image 聚合图片上传与预览能力,'
'lib/utils 则放了日期、弹窗等通用工具。',
style: TextStyle(
fontSize: 15,
height: 1.6,
color: Color(0xFF4F5B67),
),
),
],
),
),
);
}
Widget _buildDemoCard({
required String title,
required String description,
required Widget child,
required String resultText,
}) {
return Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: Color(0xFF1A1A1A),
),
),
const SizedBox(height: 8),
Text(
description,
style: const TextStyle(
fontSize: 14,
height: 1.6,
color: Color(0xFF5C6670),
),
),
const SizedBox(height: 16),
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18),
decoration: BoxDecoration(
color: const Color(0xFFF7F9FC),
borderRadius: BorderRadius.circular(16),
border: Border.all(color: const Color(0xFFD9E1F2)),
),
child: child,
),
const SizedBox(height: 14),
Text(
'当前结果:$resultText',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Color(0xFF4D6FD5),
),
),
],
),
),
);
}
String _formatDate(DateTime? date) {
if (date == null) {
return '未选择';
}
return DateTimeUtils.dateTimeUtilsTool(
dateTime: date.toIso8601String(),
dateTimeUtilsType: DateTimeUtilsType.yearMonthDay,
);
}
}

View File

@@ -1,5 +1,6 @@
/// A Calculator.
class Calculator {
/// Returns [value] plus 1.
int addOne(int value) => value + 1;
}
library flutter_common;
export 'calendarcalendar/calendar_choose_widget.dart';
export 'calendarcalendar/custom_calendar_range_picker_widget.dart';
export 'calendarcalendar/custom_date_picker.dart';
export 'utils/date_utils.dart';

View File

@@ -59,100 +59,106 @@ class ToastUtils {
bool isShowConfirm = false,
Color? barrierColor,
EdgeInsetsGeometry? padding,
bool useSafeArea = true,
bool useSafeArea = false,
}) {
cancelToast();
return showDialog(
useSafeArea: useSafeArea,
context: context,
builder: (BuildContext ctx) {
return Container(
width: double.infinity,
height: MediaQuery.of(context).size.height / 2,
margin: EdgeInsets.only(
top: height == null
? MediaQuery.of(context).size.height / 2
: (MediaQuery.of(context).size.height - height),
),
padding: padding ?? const EdgeInsets.only(bottom: 40),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
),
),
child: Column(
children: [
header ??
Container(
padding: const EdgeInsets.only(bottom: 5),
decoration: const BoxDecoration(
border: Border(
bottom:
BorderSide(color: Color(0xffE1E1E1), width: 0.5),
),
),
child: Row(
children: [
GestureDetector(
onTap: () => Navigator.of(context).pop(),
child: Container(
padding:
const EdgeInsets.only(left: 6, right: 10),
color: Colors.transparent,
child: Icon(
Icons.keyboard_arrow_down_rounded,
size: leftIconSize ?? 40,
final dialogHeight = height ?? MediaQuery.of(ctx).size.height / 2;
final bottomInset = MediaQuery.of(ctx).padding.bottom;
return Material(
type: MaterialType.transparency,
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity,
height: dialogHeight,
padding: (padding ?? const EdgeInsets.only(bottom: 40))
.add(EdgeInsets.only(bottom: bottomInset)),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
),
),
child: Column(
children: [
header ??
Container(
padding: const EdgeInsets.only(bottom: 5),
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color(0xffE1E1E1),
width: 0.5,
),
),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Text(
title ?? '头部',
style: TextStyle(
color: const Color(0xff333333),
fontSize: titleFontSize ?? 18,
fontWeight: FontWeight.bold,
child: Row(
children: [
GestureDetector(
onTap: () => Navigator.of(ctx).pop(),
child: Container(
padding:
const EdgeInsets.only(left: 6, right: 10),
color: Colors.transparent,
child: Icon(
Icons.keyboard_arrow_down_rounded,
size: leftIconSize ?? 40,
),
),
),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Text(
title ?? '头部',
style: TextStyle(
color: const Color(0xff333333),
fontSize: titleFontSize ?? 18,
fontWeight: FontWeight.bold,
),
),
),
),
GestureDetector(
onTap: () {
if (isShowConfirm) {
if (onConfirm != null) {
onConfirm();
Navigator.of(ctx).pop();
}
}
},
child: Container(
padding: const EdgeInsets.only(
left: 10,
top: 8,
bottom: 8,
right: 18,
),
alignment: Alignment.center,
color: Colors.transparent,
child: Text(
'确定',
style: TextStyle(
color: isShowConfirm
? const Color(0xff4D6FD5)
: Colors.transparent,
fontSize: 16),
),
),
)
],
),
GestureDetector(
onTap: () {
if (isShowConfirm) {
if (onConfirm != null) {
onConfirm();
Navigator.pop(context);
}
}
},
child: Container(
padding: const EdgeInsets.only(
left: 10,
top: 8,
bottom: 8,
right: 18,
),
alignment: Alignment.center,
color: Colors.transparent,
child: Text(
'确定',
style: TextStyle(
color: isShowConfirm
? const Color(0xff4D6FD5)
: Colors.transparent,
fontSize: 16),
),
),
)
],
),
),
Expanded(child: contentWidget ?? const SizedBox())
],
),
Expanded(child: contentWidget ?? const SizedBox())
],
),
),
),
);
});

View File

@@ -1,12 +1,13 @@
import 'package:flutter_common/flutter_common.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_common/flutter_common.dart';
void main() {
test('adds one to input values', () {
final calculator = Calculator();
expect(calculator.addOne(2), 3);
expect(calculator.addOne(-7), -6);
expect(calculator.addOne(0), 1);
test('exports date utility helpers', () {
final formatted = DateTimeUtils.dateTimeUtilsTool(
dateTime: DateTime(2026, 4, 15).toIso8601String(),
dateTimeUtilsType: DateTimeUtilsType.yearMonthDay,
);
expect(formatted, '2026-04-15');
});
}