├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── lib ├── aliyun_oss_flutter.dart └── src │ ├── client.dart │ ├── http.dart │ ├── model.dart │ └── signer.dart ├── pubspec.lock ├── pubspec.yaml └── test └── aliyun_oss_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | .vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Flutter.podspec 62 | **/ios/Flutter/Generated.xcconfig 63 | **/ios/Flutter/app.flx 64 | **/ios/Flutter/app.zip 65 | **/ios/Flutter/flutter_assets/ 66 | **/ios/Flutter/flutter_export_environment.sh 67 | **/ios/ServiceDefinitions.json 68 | **/ios/Runner/GeneratedPluginRegistrant.* 69 | 70 | # Exceptions to above rules. 71 | !**/ios/**/default.mode1v3 72 | !**/ios/**/default.mode2v3 73 | !**/ios/**/default.pbxuser 74 | !**/ios/**/default.perspectivev3 75 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 60bd88df915880d23877bfc1602e8ddcf4c4dd2a 8 | channel: unknown 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.0.1] - TODO: Add release date. 2 | ## [0.0.3] - putObject add disposable put config 3 | ## [1.0.0] - add null-safety 4 | ## [1.0.1] - Fixed signing error due to resourcePath 5 | ## [1.0.2] - Fix x-oss-security-token authentication 6 | ## [1.0.3] - Fix image form file UI freeze & Remove image compress 7 | ## [1.0.4] - Fix Uncaught LocaleDataException 8 | ## [1.0.5] - Fix video media type 9 | ## [1.0.6] - Upgrade sdk version 10 | ## [1.1.0] - Update analysis_options 11 | ## [1.1.1] - Upgrade some package 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 lucky1213 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aliyun_oss_flutter 2 | 3 | aliyun oss plugin for flutter. Use this plugin to upload files to aliyun oss. 4 | 5 | ## Usage 6 | 7 | To use this plugin, add `aliyun_oss_flutter` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels). 8 | 9 | `OSSClient` is a static class 10 | 11 | ## 压缩需求 12 | 现版本已移除图片压缩、宽高获取,如需对视频、图片进行压缩可以使用[media_asset_utils](https://pub.flutter-io.cn/packages/media_asset_utils) 13 | 14 | - [x] 视频硬编码压缩以及图片仿微信[Luban](https://github.com/Curzibn/Luban)压缩 15 | - [x] 视频缩略图获取 16 | - [x] 视频和图片的width、height、orientation等信息获取 17 | - [x] 保存到相册,支持Android Q+ 18 | 19 | ### Example 20 | ``` dart 21 | import 'package:flutter/material.dart'; 22 | import 'package:aliyun_oss_flutter/aliyun_oss_flutter.dart'; 23 | 24 | void main() { 25 | 26 | // 初始化OSSClient 27 | OSSClient.init( 28 | endpoint: 'oss-cn-hangzhou.aliyuncs.com', 29 | bucket: 'xxxx', 30 | credentials: () { 31 | // Future Credentials 32 | return Credentials.fromJson(response.data); 33 | // Or Credentials Config 34 | return Credentials( 35 | accessKeyId: 'xxxx', 36 | accessKeySecret: 'xxxx', 37 | ); 38 | }, 39 | ); 40 | 41 | runApp(...); 42 | } 43 | 44 | Future upload() async { 45 | final object = await OSSClient().putObject( 46 | object: OSSObject 47 | bucket: xxx, // String? 48 | endpoint: xxx, // String? 49 | path: xxx, // String? 50 | ); 51 | } 52 | ``` -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | analyzer: 13 | # For more information see: 14 | # https://dart.dev/guides/language/analysis-options#enabling-additional-type-checks 15 | language: 16 | strict-casts: true 17 | strict-inference: true 18 | strict-raw-types: true 19 | 20 | errors: 21 | # Without ignore here, we cause import of all_lint_rules to warn, because some rules conflict. 22 | # We explicitly enabled even conflicting rules and are fixing the conflicts in this file. 23 | # Put it to warning temporarily, if you need troubleshoot lint rule settings. 24 | included_file_warning: ignore 25 | 26 | # Treat missing required parameters as an error, not as a hint or a warning. 27 | missing_required_param: error 28 | 29 | # Treat missing returns as an error, not as a hint or a warning. 30 | missing_return: error 31 | 32 | # Allow self-reference to deprecated members. This is done because otherwise we have 33 | # to annotate every member in every test, assert, etc., when we deprecate something. 34 | deprecated_member_use_from_same_package: ignore 35 | 36 | # DON'T assign new values to parameters of methods or functions. 37 | # https://dart-lang.github.io/linter/lints/parameter_assignments.html 38 | parameter_assignments: warning 39 | 40 | # Allow having TODOs in the code. 41 | todo: ignore 42 | 43 | exclude: 44 | - "lib/src/http/**" 45 | 46 | linter: 47 | rules: 48 | # ALWAYS separate the control structure expression from its statement. 49 | # 50 | # https://dart-lang.github.io/linter/lints/always_put_control_body_on_new_line.html 51 | # 52 | # This sometimes makes things more unclear when one line is enough. 53 | # Also single line `if`s are fine as recommended in Effective Dart "DO format your code using dartfmt". 54 | # 55 | # Other known linters use: 56 | # 57 | # Core disabled : https://pub.dev/packages/lints 58 | # Recommended disabled : https://pub.dev/packages/lints 59 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 60 | # Pedantic disabled : https://pub.dev/packages/pedantic 61 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 62 | # Flutter repo enabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 63 | # Lint disabled : https://pub.dev/packages/lint 64 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 65 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 66 | always_put_control_body_on_new_line: false 67 | 68 | # ALWAYS specify @required on named parameter before other named parameters. 69 | # 70 | # https://dart-lang.github.io/linter/lints/always_put_required_named_parameters_first.html 71 | # 72 | # Conflicts with the convention used by Flutter, which puts `Key key` first 73 | # and `@required Widget child` last. 74 | # 75 | # Other known linters use: 76 | # Core disabled : https://pub.dev/packages/lints 77 | # Recommended disabled : https://pub.dev/packages/lints 78 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 79 | # Pedantic disabled : https://pub.dev/packages/pedantic 80 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 81 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 82 | # Lint disabled : https://pub.dev/packages/lint 83 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 84 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 85 | always_put_required_named_parameters_first: false 86 | 87 | # ALWAYS specify type annotations. 88 | # 89 | # https://dart-lang.github.io/linter/lints/always_specify_types.html 90 | # 91 | # Avoid var when specifying that a type is unknown and short-hands that elude type annotations. Use 92 | # dynamic if you are being explicit that the type is unknown. Use Object if you are being explicit 93 | # that you want an object that implements == and hashCode. 94 | # The linter rule link above states this rule is from the Flutter style guide. 95 | # 96 | # This makes most code intent very explicit, sometimes this may help you 97 | # reason about unfamiliar libs, but it might get tedious when dealing with very familiar ones. 98 | # For people used to more relaxed or no type declaration, it is probably the other way around. 99 | # This rule is of course also in conflict with some other lint rules, most notably it 100 | # violates Effective Dart "AVOID type annotating initialized local variables". 101 | # https://dart-lang.github.io/linter/lints/omit_local_variable_types.html 102 | # Which we find to be a strange rule, the package lint agrees, with the statement that 103 | # "Types for local variables may improve readability" and keeps that avoid rule disabled. 104 | # 105 | # Turning always_specify_types lint rule on in a project at later stage is very tedious, fixing 106 | # all the analyzer warnings will take quite some time. Having it on as you write new code 107 | # is not so bad though, the IDE will handle it most of the time. 108 | # Most people probably want this lint rule OFF, but for now we try to keep it on 109 | # in our projects. We might reconsider this choice later, for example this issue has requested 110 | # a new softer related lint rule that could be used only for declarations: 111 | # https://github.com/dart-lang/linter/issues/1620 112 | # If such a lint rule materializes, we might switch to using it instead and turning this one off. 113 | # 114 | # We felt the above long explanation was warranted as a reminder. Keeping the rule listed here 115 | # and the setting below, in order to easily turn it OFF permanently some day, or in some 116 | # projects. 117 | # 118 | # Other known linters use: 119 | # 120 | # Core disabled : https://pub.dev/packages/lints 121 | # Recommended disabled : https://pub.dev/packages/lints 122 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 123 | # Pedantic disabled : https://pub.dev/packages/pedantic 124 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 125 | # Flutter repo enabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 126 | # Lint disabled : https://pub.dev/packages/lint 127 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 128 | # RydMike enabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 129 | # always_specify_types: false 130 | 131 | # ALWAYS use package imports for files in lib/. 132 | # 133 | # https://dart-lang.github.io/linter/lints/always_use_package_imports.html 134 | # 135 | # This rule conflicts with `prefer_relative_imports` so we turn it OFF. 136 | # We are still conflicted about which version to use, keeping it this way for now, as support 137 | # for relative imports have improved in both IDE's, but adding imports still often get imported as 138 | # package imports, and then you have to edit them manually. The IDEs can help with fixing them. 139 | # The relative paths can be a bit messy to keep track off, package imports are actually 140 | # a bit easier from that point of view. 141 | # Flutter repo now also prefers relative imports over packages imports, so that is 142 | # another reason to use that. 143 | # 144 | # Use what you prefer, but you have to be consistent though, since mixing and matching can 145 | # cause issues as the same file imported with the different options are considered to be 146 | # different libs and code, even if it is the same file. This may impact functionality 147 | # of e.g. singletons, service locators and increase code size. 148 | # 149 | # When you refactor and move folders with a lot of code in them, that other code depends 150 | # on for imports via relative imports, then they get messed up by Flutter IDEs 151 | # VS-Code and AS/IntelliJ. Both main Flutter IDEs may fail to correctly refactor moved folders 152 | # and imports that depend on files in the moved folders. 153 | # 154 | # Other known linters use: 155 | # Core disabled : https://pub.dev/packages/lints 156 | # Recommended disabled : https://pub.dev/packages/lints 157 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 158 | # Pedantic disabled : https://pub.dev/packages/pedantic 159 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 160 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 161 | # Lint disabled : https://pub.dev/packages/lint 162 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 163 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 164 | always_use_package_imports: false 165 | 166 | # AVOID annotating with dynamic when not required. 167 | # 168 | # https://dart-lang.github.io/linter/lints/avoid_annotating_with_dynamic.html 169 | # 170 | # Violates Effective Dart "PREFER annotating with dynamic instead of letting inference fail", it 171 | # also conflicts with strong mode disabling `implicit-dynamic`. Turning it OFF. 172 | # 173 | # Other known linters use: 174 | # 175 | # Core disabled : https://pub.dev/packages/lints 176 | # Recommended disabled : https://pub.dev/packages/lints 177 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 178 | # Pedantic disabled : https://pub.dev/packages/pedantic 179 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 180 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 181 | # Lint disabled : https://pub.dev/packages/lint 182 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 183 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 184 | avoid_annotating_with_dynamic: false 185 | 186 | # AVOID catches without on clauses. 187 | # 188 | # https://dart-lang.github.io/linter/lints/avoid_catches_without_on_clauses.html 189 | # 190 | # Using catch clauses without on clauses make your code prone to encountering unexpected errors that 191 | # won't be thrown (and thus will go unnoticed). BUT, there are situations where we voluntarily want to 192 | # catch everything, especially as a library. https://github.com/dart-lang/linter/issues/3023 193 | # 194 | # Other known linters use: 195 | # 196 | # Core disabled : https://pub.dev/packages/lints 197 | # Recommended disabled : https://pub.dev/packages/lints 198 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 199 | # Pedantic disabled : https://pub.dev/packages/pedantic 200 | # Effective Dart enabled : https://pub.dev/packages/effective_dart 201 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 202 | # Lint disabled : https://pub.dev/packages/lint 203 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 204 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 205 | avoid_catches_without_on_clauses: false 206 | 207 | # AVOID defining a class that contains only static members. 208 | # 209 | # https://dart-lang.github.io/linter/lints/avoid_classes_with_only_static_members.html 210 | # 211 | # Creating classes with the sole purpose of providing utility or otherwise static methods is discouraged 212 | # in effective Dart. Dart allows functions to exist outside of classes for this very reason. 213 | # Effective Dart says avoid classes with only static members: 214 | # https://dart.dev/guides/language/effective-dart/design#avoid-defining-a-class-that-contains-only-static-members 215 | # However, the Flutter style guide says use them when it makes sense: 216 | # https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#begin-global-constant-names-with-prefix-k 217 | # Colors is an example of such a class, but they still enable this rule in the repo though, go figure. 218 | # 219 | # Like Pedantic, we like util and static classes too, so we use them. 220 | # We tried the Effective Dart style and used a of kConstants in different const files. This 221 | # is more cumbersome to use than static classes. The import is simpler with static classes and 222 | # the code looks cleaner. If you use a lot of constant files, importing them is more tedious, 223 | # and you cannot enforce a given 'as' name to have a consistent name space prefix. A static 224 | # class gives you that automatically, thus providing context for the constants and static functions. 225 | # 226 | # Other known linters use: 227 | # 228 | # Core disabled : https://pub.dev/packages/lints 229 | # Recommended disabled : https://pub.dev/packages/lints 230 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 231 | # Pedantic disabled : https://pub.dev/packages/pedantic 232 | # Effective Dart enabled : https://pub.dev/packages/effective_dart 233 | # Flutter repo enabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 234 | # Lint enabled : https://pub.dev/packages/lint 235 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 236 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 237 | avoid_classes_with_only_static_members: false 238 | 239 | # AVOID declaring parameters as final. 240 | # 241 | # https://dart-lang.github.io/linter/lints/avoid_final_parameters.html 242 | # 243 | # Declaring parameters as final can lead to unnecessarily verbose code, 244 | # especially when using the "parameter_assignments" rule. 245 | # 246 | # This rule is turned off, so we can define final parameters when it makes 247 | # sense to do so without triggering a lint rule. 248 | # 249 | # Other known linters use: 250 | # 251 | # Core disabled : https://pub.dev/packages/lints 252 | # Recommended disabled : https://pub.dev/packages/lints 253 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 254 | # Pedantic disabled : https://pub.dev/packages/pedantic 255 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 256 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 257 | # Lint disabled : https://pub.dev/packages/lint 258 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 259 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 260 | avoid_final_parameters: false 261 | 262 | # AVOID positional boolean parameters. 263 | # 264 | # https://dart-lang.github.io/linter/lints/avoid_positional_boolean_parameters.html 265 | # 266 | # Positional boolean parameters are considered a bad practice because they are very ambiguous. 267 | # Using named boolean parameters is much more readable because it inherently describes 268 | # what the boolean value represents. 269 | # In principle, we agree with the argument against positional booleans. However, positional booleans 270 | # are OK when they are the ONLY boolean parameter in a callback, and also very handy when used in a 271 | # model setter from the callback directly. 272 | # 273 | # Flutter API contains many callbacks with the signature: {void Function(bool) onChanged} often 274 | # for UI toggle switches. To keep things tidy and clean with a model setter for such a callback, 275 | # a setter method with a positional boolean is needed, a typical pattern is: 276 | # Switch.adaptive( 277 | # value: model.hideTooltips, 278 | # onChanged: model.setHideTooltips, 279 | # ), 280 | # 281 | # We are turning OFF this AVOID rule. Willing to reconsider if I get convinced there are better ways, 282 | # and it does not get in the way of single none named bool callbacks. 283 | # 284 | # Other known linters use: 285 | # 286 | # Core disabled : https://pub.dev/packages/lints 287 | # Recommended disabled : https://pub.dev/packages/lints 288 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 289 | # Pedantic disabled : https://pub.dev/packages/pedantic 290 | # Effective Dart enabled : https://pub.dev/packages/effective_dart 291 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 292 | # Lint enabled : https://pub.dev/packages/lint 293 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 294 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 295 | avoid_positional_boolean_parameters: false 296 | 297 | # AVOID print calls in production code. 298 | # 299 | # https://dart-lang.github.io/linter/lints/avoid_print.html 300 | # 301 | # Our default is to have this rule enabled. 302 | # 303 | # Examples may want to print to the console, you might want to do so during development too. We keep the rule here 304 | # to handily disable/enable as and when needed. This lint rule is a good way to find print statements that you 305 | # may have used during development in code that should not have them in production, so at least before 306 | # committing the code in such projects, make sure to keep this rule enabled by commenting it out here. 307 | # 308 | # Other known linters use: 309 | # 310 | # Core disabled : https://pub.dev/packages/lints 311 | # Recommended disabled : https://pub.dev/packages/lints 312 | # Flutter Lints enabled : https://pub.dev/packages/flutter_lints 313 | # Pedantic disabled : https://pub.dev/packages/pedantic 314 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 315 | # Flutter repo enabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 316 | # Lint enabled : https://pub.dev/packages/lint 317 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 318 | # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 319 | # RELEASE: enabled : By commenting it out. (default) 320 | # DEVELOPMENT: disabled : Uncomment below if the warnings bother you during dev or making a console app. 321 | # avoid_print: false 322 | 323 | # AVOID redundant argument values. 324 | # 325 | # https://dart-lang.github.io/linter/lints/avoid_redundant_argument_values.html 326 | # 327 | # Using redundant (default) argument values can be useful for in-code documentation 328 | # purposes and also handy as a template when trying different settings in Flutter. It is often 329 | # quicker when dealing with not well known APIs to see parameter values in the call/constructor, 330 | # instead of using the IDE to peek into its default to figure out what the defaults are. 331 | # Occasionally leaving a few redundant default valued parameters in the code is not that bad 332 | # when you are developing something new. For public packages you probably want to keep this 333 | # rule enabled. I like to sometimes be explicit and specify values that are same as default one. 334 | # 335 | # Other known linters use: 336 | # 337 | # Core disabled : https://pub.dev/packages/lints 338 | # Recommended disabled : https://pub.dev/packages/lints 339 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 340 | # Pedantic disabled : https://pub.dev/packages/pedantic 341 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 342 | # Flutter repo enabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 343 | # Lint enabled : https://pub.dev/packages/lint 344 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 345 | # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 346 | # PACKAGE: enabled : By commenting it out below, often a good idea in packages. 347 | # APPLICATION: disabled : With false value. 348 | avoid_redundant_argument_values: false 349 | 350 | # AVOID annotating types for function expression parameters. 351 | # 352 | # https://dart-lang.github.io/linter/lints/avoid_catches_without_on_clauses.html 353 | # 354 | # Annotating types for function expression parameters is usually unnecessary because the 355 | # parameter types can almost always be inferred from the context, thus making the practice redundant. 356 | # However, since we are using `always_specify_types` we should not have this one ON either 357 | # as it conflicts with it. Even if you do not do that, we still recommend keeping this rule OFF. 358 | # While always specifying type on callbacks is certainly a bit tedious and not necessary, 359 | # it can sometimes improve readability, so let's not force them to not be allowed. 360 | # Then even if you don't use `always_specify_types`, it is possible to sometimes possible to 361 | # specify them on closures when it improves readability of unfamiliar closures. 362 | # 363 | # Other known linters use: 364 | # 365 | # Core disabled : https://pub.dev/packages/lints 366 | # Recommended disabled : https://pub.dev/packages/lints 367 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 368 | # Pedantic disabled : https://pub.dev/packages/pedantic 369 | # Effective Dart enabled : https://pub.dev/packages/effective_dart 370 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 371 | # Lint disabled : https://pub.dev/packages/lint 372 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 373 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 374 | avoid_types_on_closure_parameters: false 375 | 376 | # DO Use the cascading style when successively invoking methods on the same reference. 377 | # 378 | # https://dart-lang.github.io/linter/lints/cascade_invocations.html 379 | # 380 | # We disable this rule, just a personal preference, using them is fine though, 381 | # but let's not enforce it. 382 | # 383 | # Other known linters use: 384 | # 385 | # Core disabled : https://pub.dev/packages/lints 386 | # Recommended disabled : https://pub.dev/packages/lints 387 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 388 | # Pedantic disabled : https://pub.dev/packages/pedantic 389 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 390 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 391 | # Lint disabled : https://pub.dev/packages/lint 392 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 393 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 394 | cascade_invocations: false 395 | 396 | # DO invoke close on instances of dart.core.Sink. 397 | # 398 | # https://dart-lang.github.io/linter/lints/close_sinks.html 399 | # 400 | # Disabling it, may generate false positives. https://github.com/dart-lang/linter/issues/1381. 401 | # 402 | # Other known linters use: 403 | # 404 | # Core disabled : https://pub.dev/packages/lints 405 | # Recommended disabled : https://pub.dev/packages/lints 406 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 407 | # Pedantic disabled : https://pub.dev/packages/pedantic 408 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 409 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 410 | # Lint disabled : https://pub.dev/packages/lint 411 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 412 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 413 | #close_sinks: false 414 | 415 | # DO reference all public properties in debug method implementations. 416 | # 417 | # https://dart-lang.github.io/linter/lints/diagnostic_describe_all_properties.html 418 | # 419 | # Consider using this lint rule if you are making a public Flutter package, for private ones and private apps 420 | # we recommend keeping it off as you probably won't be making diagnostic properties for all your 421 | # classes, unless you are using a data class lib that does it for you via code generation. 422 | # 423 | # Other known linters use: 424 | # 425 | # Core disabled : https://pub.dev/packages/lints 426 | # Recommended disabled : https://pub.dev/packages/lints 427 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 428 | # Pedantic disabled : https://pub.dev/packages/pedantic 429 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 430 | # Lint disabled : https://pub.dev/packages/lint 431 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 432 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 433 | # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 434 | # PACKAGE: enabled : By commenting it out. 435 | # APPLICATION: disabled : With false value. (Default, assume we are making an app most of the time.) 436 | diagnostic_describe_all_properties: false 437 | 438 | # DO Use Flutter TO-DO format. 439 | # 440 | # https://dart-lang.github.io/linter/lints/flutter_style_todos.html 441 | # 442 | # Use Flutter-style todos with GitHub username. Useful if you are coding in a 443 | # larger team, if not you may also consider turning off the rule by removing 444 | # its comment below. 445 | # 446 | # Other known linters use: 447 | # 448 | # Core disabled : https://pub.dev/packages/lints 449 | # Recommended disabled : https://pub.dev/packages/lints 450 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 451 | # Pedantic disabled : https://pub.dev/packages/pedantic 452 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 453 | # Flutter repo enabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 454 | # Lint disabled : https://pub.dev/packages/lint 455 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 456 | # RydMike enabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 457 | #flutter_style_todos: false 458 | 459 | # AVOID lines longer than 80 characters 460 | # 461 | # https://dart-lang.github.io/linter/lints/lines_longer_than_80_chars.html 462 | # 463 | # Using this rule will sometimes force a line of 81 characters to be split in two. 464 | # As long as we try to respect that 80 characters limit, going slightly above is fine. 465 | # 466 | # For packages keep this rule enabled though, because the pub.dev dart format check will 467 | # penalize package points if it does not adhere to strict Dart format rules, which 468 | # requires max 80 char lines. This rule will then help you find cases where you go over 469 | # and fix them manually when possible. Funny thing is that Flutter repo violates this rule, but 470 | # if you do it in packages for pub.dev you get score deductions. We often disable this rule 471 | # if this is not a package, so we keep it listed here as as a handy toggle. 472 | # 473 | # Other known linters use: 474 | # 475 | # Core disabled : https://pub.dev/packages/lints 476 | # Recommended disabled : https://pub.dev/packages/lints 477 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 478 | # Pedantic disabled : https://pub.dev/packages/pedantic 479 | # Effective Dart enabled : https://pub.dev/packages/effective_dart 480 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 481 | # Lint disabled : https://pub.dev/packages/lint 482 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 483 | # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 484 | # PACKAGE: enabled : By commenting it out. (Default, even if is not a package, we start with this.) 485 | # APPLICATION: disabled : With false value. (When/if short lines become problematic. We sometimes like 100 chars.) 486 | # lines_longer_than_80_chars: false 487 | 488 | # DO define default behavior outside switch statements. 489 | # 490 | # https://dart-lang.github.io/linter/lints/no_default_cases.html 491 | # 492 | # An experimental lint rule maturity wise. I enabled it, it seems to work well. 493 | # Remove the comment below if it is causing issues. 494 | # 495 | # Other known linters use: 496 | # 497 | # Core disabled : https://pub.dev/packages/lints 498 | # Recommended disabled : https://pub.dev/packages/lints 499 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 500 | # Pedantic disabled : https://pub.dev/packages/pedantic 501 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 502 | # Flutter repo enabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 503 | # Lint disabled : https://pub.dev/packages/lint 504 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 505 | # RydMike enabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 506 | #no_default_cases: false 507 | 508 | # CONSIDER omitting type annotations for local variables. 509 | # 510 | # https://dart-lang.github.io/linter/lints/omit_local_variable_types.html 511 | # 512 | # Conflicts with 'always_specify_types' that is used, so then we can't have this rule either, 513 | # besides we like being verbose and specific. Why and when would omitting the type for local 514 | # variables be a good thing anyway, be specific, is our take on this. 515 | # 516 | # Other known linters use: 517 | # 518 | # Core disabled : https://pub.dev/packages/lints 519 | # Recommended disabled : https://pub.dev/packages/lints 520 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 521 | # Pedantic enabled : https://pub.dev/packages/pedantic 522 | # Effective Dart enabled : https://pub.dev/packages/effective_dart 523 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 524 | # Lint disabled : https://pub.dev/packages/lint 525 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 526 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 527 | omit_local_variable_types: false 528 | 529 | # PREFER asserts with a message string. 530 | # 531 | # https://dart-lang.github.io/linter/lints/prefer_asserts_with_message.html 532 | # 533 | # When assertions fail it's not always simple to understand why. Adding a message to the 534 | # assert function helps the developer to understand why the AssertionError occurs. 535 | # 536 | # While this is true, Dart does nowadays create very clear messages from assert terms by default. 537 | # Flutter SDK does not use this rule or style. When you use code from it for customized 538 | # widgets you will end up having to write your own messages for the code snippet. 539 | # 540 | # Rationale for not using this in Flutter SDK: 541 | # "Assertions blocks don't require a message because they throw simple to understand errors" 542 | # 543 | # We agree, so we do not mind turning OFF this rule when it becomes tedious, but we start 544 | # with it ON. With NNBD you also usually a lot less asserts than you did before in Dart code, 545 | # since NNBD made almost all "not null" assertions unnecessary. 546 | # 547 | # Other known linters use: 548 | # 549 | # Core disabled : https://pub.dev/packages/lints 550 | # Recommended disabled : https://pub.dev/packages/lints 551 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 552 | # Pedantic disabled : https://pub.dev/packages/pedantic 553 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 554 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 555 | # Lint disabled : https://pub.dev/packages/lint 556 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 557 | # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 558 | # PACKAGE: enabled : By commenting it out. (default) 559 | # APPLICATION: disabled : With false value. (If it gets tedious in an app, we may turn it off) 560 | # prefer_asserts_with_message: false 561 | 562 | # PREFER to define constructors, instead of static methods to create instances. 563 | # 564 | # https://dart-lang.github.io/linter/lints/prefer_constructors_over_static_methods.html 565 | # 566 | # Dart has named constructors. Static methods in other languages (java) are a workaround which don't have 567 | # named constructors. We don't mind this lint rule, it is OK, BUT we noticed that 568 | # if you want/need to create instances of classes via static helpers in another class, that 569 | # this lint rules complains about it. We are OK with preferring a named 570 | # constructor over a static method to create an instance from within the same class. 571 | # But this lint rule complained about the above usage too where we think it makes sense to use this. 572 | # This rule currently complains about use cases that in some scenarios is impossible to comply with. 573 | # Maybe this is another issue with this lint rule. We should investigate it further and report 574 | # it, if it is. For now we disable this rule. 575 | # A past now resolved issue with this lint rule was: https://github.com/dart-lang/linter/issues/2149 576 | # 577 | # Other known linters use: 578 | # 579 | # Core disabled : https://pub.dev/packages/lints 580 | # Recommended disabled : https://pub.dev/packages/lints 581 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 582 | # Pedantic disabled : https://pub.dev/packages/pedantic 583 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 584 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 585 | # Lint enabled : https://pub.dev/packages/lint 586 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 587 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 588 | prefer_constructors_over_static_methods: false 589 | 590 | # DO use double quotes where they wouldn't require additional escapes. 591 | # 592 | # https://dart-lang.github.io/linter/lints/prefer_double_quotes.html 593 | # 594 | # This rule is mostly about what style you want to use and enforce, if any. 595 | # It of course conflicts with rule: 596 | # `prefer_single_quotes` : "DO use single quotes where they wouldn't require additional escapes." 597 | # https://dart-lang.github.io/linter/lints/prefer_single_quotes.html 598 | # 599 | # For us single quotes are easier to type. On our ISO keyboards it is next to Enter key, and 600 | # we don't need the Shift plus the far to reach nr 2 key on R1 to type it. Also, we don't think 601 | # they compromise on readability. 602 | # Then again if you don't care and don't mind mixing and matching, then ALSO 603 | # turning OFF `prefer_single_quotes` works fine too, and then you can use both options. 604 | # 605 | # We thought it was cleaner to stick to one style. Single quotes are easier to type for us, 606 | # thus we turn OFF this `prefer_double_quotes` rule. There is another lint rules that recommends you 607 | # to use double quotes when you otherwise would need to escape the single quote char, it works 608 | # well when you use the prefer_single_quotes rule as well. 609 | # 610 | # Other known linters use: 611 | # 612 | # Core disabled : https://pub.dev/packages/lints 613 | # Recommended disabled : https://pub.dev/packages/lints 614 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 615 | # Pedantic disabled : https://pub.dev/packages/pedantic 616 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 617 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 618 | # Lint disabled : https://pub.dev/packages/lint 619 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 620 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 621 | prefer_double_quotes: false 622 | 623 | # CONSIDER using => for short members whose body is a single return statement. 624 | # 625 | # https://dart-lang.github.io/linter/lints/prefer_expression_function_bodies.html 626 | # 627 | # Certainly good idea in many cases, but not always. For example not always suitable for Flutter, which may 628 | # have a `build` method with a single return, but that return is still complex enough that a "body" is worth it, 629 | # and it might not even fit on a single line. 630 | # https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods 631 | # 632 | # Other known linters use: 633 | # 634 | # Core disabled : https://pub.dev/packages/lints 635 | # Recommended disabled : https://pub.dev/packages/lints 636 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 637 | # Pedantic disabled : https://pub.dev/packages/pedantic 638 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 639 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 640 | # Lint disabled : https://pub.dev/packages/lint 641 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 642 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 643 | prefer_expression_function_bodies: false 644 | 645 | # DO prefer declaring parameters as final if they are not reassigned in the function body. 646 | # 647 | # https://dart-lang.github.io/linter/lints/prefer_final_parameters.html 648 | # 649 | # Declaring parameters as final when possible is a good practice because it helps 650 | # avoid accidental reassignments. 651 | # 652 | # Certainly good idea in many cases. There seems to be one "small" false positive issue with it. 653 | # Lint is triggered by final constructor properties, eg a in 654 | # `final int i;` the parameter `this.i` is not also final, which is not really needed 655 | # since the property is final. However, this triggers the rule, unnecessarily in our opinion. 656 | # We need to turn OFF this rule due to that. 657 | # 658 | # We turned OFF the rule. In a test project, after we cleaned up all that could be after Flutter 2.5 upgrade. 659 | # There were still 150 positives from the rule, from above issue. So after having it on and doing cleanup 660 | # where it could be used, we turned off the rule for now. Pity, it is a useful and nice rule otherwise. 661 | # 662 | # Other known linters use: 663 | # 664 | # Core disabled : https://pub.dev/packages/lints 665 | # Recommended disabled : https://pub.dev/packages/lints 666 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 667 | # Pedantic disabled : https://pub.dev/packages/pedantic 668 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 669 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 670 | # Lint disabled : https://pub.dev/packages/lint 671 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 672 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 673 | prefer_final_parameters: false 674 | 675 | # DO use int literals rather than the corresponding double literal. 676 | # 677 | # https://dart-lang.github.io/linter/lints/prefer_int_literals.html 678 | # 679 | # This rule goes against the preferred style of being explicit with 680 | # declarations and hides when a number is double, since we cannot declare it 681 | # as 0.0 or 1.0 when it is double, it has to be 0 or 1, making it look 682 | # like an integer, even if it is not. Sometimes doing that is OK, but let's 683 | # not enforce it. 684 | # 685 | # Other known linters use: 686 | # 687 | # Core disabled : https://pub.dev/packages/lints 688 | # Recommended disabled : https://pub.dev/packages/lints 689 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 690 | # Pedantic disabled : https://pub.dev/packages/pedantic 691 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 692 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 693 | # Lint disabled : https://pub.dev/packages/lint 694 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 695 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 696 | prefer_int_literals: false 697 | 698 | # DO document all public members. 699 | # 700 | # https://dart-lang.github.io/linter/lints/public_member_api_docs.html 701 | # 702 | # All non-overriding public members should be documented with /// doc-style comments. 703 | # Not necessary for an app or the examples in a pub.dev package. I always enable this for 704 | # public packages. 705 | # 706 | # NOTE: There is also the lint rule "package_api_docs", that is enabled as well via all being enabled. 707 | # https://dart-lang.github.io/linter/lints/package_api_docs.html 708 | # "DO provide doc comments for all public APIs.", is what it is supposed to do, but only for packages. 709 | # However, if we turn OFF rule "public_member_api_docs", then the "package_api_docs" offers no warnings 710 | # on missing API doc comments alone. So our conclusion for now is that this rule has to be used instead 711 | # to ensure we find all APIs that should have documentation comments in a package as well. 712 | # 713 | # Other known linters use: 714 | # 715 | # Core disabled : https://pub.dev/packages/lints 716 | # Recommended disabled : https://pub.dev/packages/lints 717 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 718 | # Pedantic disabled : https://pub.dev/packages/pedantic 719 | # Effective Dart enabled : https://pub.dev/packages/effective_dart 720 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 721 | # Lint disabled : https://pub.dev/packages/lint 722 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 723 | # RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 724 | # PACKAGE: enabled : By commenting it out. (My default, I start with this) 725 | # APPLICATION: disabled : With false value. (But usually uncomment the false value if it is an app) 726 | # public_member_api_docs: false 727 | 728 | # DO use trailing commas for all function calls and declarations unless the function call or 729 | # definition, from the start of the function name up to the closing parenthesis, 730 | # fits in a single line. 731 | # 732 | # https://dart-lang.github.io/linter/lints/require_trailing_commas.html 733 | # 734 | # This rule forces commas even in places where it just adds extra lines that 735 | # adds little value. There is also not a bulk dart fix for it: 736 | # https://github.com/dart-lang/sdk/issues/47441 737 | # 738 | # Other known linters use: 739 | # 740 | # Core disabled : https://pub.dev/packages/lints 741 | # Recommended disabled : https://pub.dev/packages/lints 742 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 743 | # Pedantic disabled : https://pub.dev/packages/pedantic 744 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 745 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 746 | # Lint enabled : https://pub.dev/packages/lint 747 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 748 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 749 | require_trailing_commas: false 750 | 751 | # DO sort constructor declarations before other members. 752 | # 753 | # We do like this lint rule, but we want to have the default constructor first, followed 754 | # by its properties, after this other named constructors and factories. This rule gets 755 | # in the way of that and forces you to put (often final) constructor properties after all 756 | # the named constructors and factories, making them tedious to find and disconnected from 757 | # where we want to see, read and handily edit them. This is especially the case if there are 758 | # many constructors and factories, and they have a lot of parameters. For now, we disable 759 | # this rule and order things as described above, which apart from the default constructor 760 | # properties coming right after the constructor, is the only part where we in practice 761 | # deviate from this rule, so other yes, we do put constructors first as well anyway. 762 | # 763 | # Other known linters use: 764 | # 765 | # Core disabled : https://pub.dev/packages/lints 766 | # Recommended disabled : https://pub.dev/packages/lints 767 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 768 | # Pedantic disabled : https://pub.dev/packages/pedantic 769 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 770 | # Flutter repo enabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 771 | # Lint disabled : https://pub.dev/packages/lint 772 | # Discussion https://github.com/passsy/dart-lint/issues/1 773 | # VG Analysis enabled : https://pub.dev/packages/very_good_analysis 774 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 775 | sort_constructors_first: false 776 | 777 | # DON'T use final for local variables. 778 | # 779 | # https://dart-lang.github.io/linter/lints/unnecessary_final.html 780 | # 781 | # Incompatible with `prefer_final_locals` that we want because having immutable local variables when 782 | # applicable makes larger functions more predictable and easier to reason about, so we 783 | # use `prefer_final_locals` instead. 784 | # 785 | # Other known linters use: 786 | # 787 | # Core disabled : https://pub.dev/packages/lints 788 | # Recommended disabled : https://pub.dev/packages/lints 789 | # Flutter Lints disabled : https://pub.dev/packages/flutter_lints 790 | # Pedantic disabled : https://pub.dev/packages/pedantic 791 | # Effective Dart disabled : https://pub.dev/packages/effective_dart 792 | # Lint disabled : https://pub.dev/packages/lint 793 | # Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml 794 | # VG Analysis disabled : https://pub.dev/packages/very_good_analysis 795 | # RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c 796 | unnecessary_final: false 797 | -------------------------------------------------------------------------------- /lib/aliyun_oss_flutter.dart: -------------------------------------------------------------------------------- 1 | library aliyun_oss_flutter; 2 | 3 | import 'dart:convert'; 4 | import 'dart:io'; 5 | import 'dart:typed_data'; 6 | 7 | import 'package:crypto/crypto.dart'; 8 | import 'package:dio/dio.dart'; 9 | import 'package:http_parser/http_parser.dart' show MediaType; 10 | import 'package:intl/date_symbol_data_local.dart'; 11 | import 'package:intl/intl.dart'; 12 | import 'package:path/path.dart' as path; 13 | import 'package:uuid/uuid.dart'; 14 | 15 | export 'package:http_parser/http_parser.dart' show MediaType; 16 | 17 | part 'src/client.dart'; 18 | part 'src/http.dart'; 19 | part 'src/model.dart'; 20 | part 'src/signer.dart'; 21 | -------------------------------------------------------------------------------- /lib/src/client.dart: -------------------------------------------------------------------------------- 1 | part of aliyun_oss_flutter; 2 | 3 | class OSSClient { 4 | factory OSSClient() { 5 | return _instance!; 6 | } 7 | 8 | OSSClient._({ 9 | required this.endpoint, 10 | required this.bucket, 11 | required this.credentials, 12 | }) { 13 | _signer = null; 14 | } 15 | 16 | /// * 初始化设置`endpoint` `bucket` `getCredentials` 17 | /// * [credentials] 获取 `Credentials` 18 | /// * 一旦初始化,则`signer`清空,上传前会重新拉取oss信息 19 | static OSSClient init({ 20 | required String endpoint, 21 | required String bucket, 22 | required Future Function() credentials, 23 | Dio? dio, 24 | }) { 25 | _instance = OSSClient._( 26 | endpoint: endpoint, 27 | bucket: bucket, 28 | credentials: credentials, 29 | ); 30 | if (dio != null) { 31 | _http = dio; 32 | } 33 | return _instance!; 34 | } 35 | 36 | static OSSClient? _instance; 37 | 38 | Signer? _signer; 39 | 40 | final String endpoint; 41 | final String bucket; 42 | final Future Function() credentials; 43 | 44 | /// * [bucket] [endpoint] 一次性生效 45 | /// * [path] 上传路径 如不写则自动以 Object[type] [time] 生成path 46 | Future putObject({ 47 | required OSSObject object, 48 | String? bucket, 49 | String? endpoint, 50 | String? path, 51 | }) async { 52 | _signer = await verify(); 53 | 54 | final String objectPath = object.resourcePath(path); 55 | 56 | final Map safeHeaders = _signer!.sign( 57 | httpMethod: 'PUT', 58 | resourcePath: '/${bucket ?? this.bucket}/$objectPath', 59 | headers: { 60 | 'content-type': object.mediaType.mimeType, 61 | }, 62 | ).toHeaders(); 63 | try { 64 | final String url = 65 | 'https://${bucket ?? this.bucket}.${endpoint ?? this.endpoint}/$objectPath'; 66 | final Uint8List bytes = object.bytes; 67 | // if (object is OSSImageObject && !object.fullImage) { 68 | // bytes = MediaAssetUtils.compressImage(file); 69 | // } 70 | await _http.put( 71 | url, 72 | data: Stream.fromIterable(bytes.map((e) => [e])), 73 | options: Options( 74 | headers: { 75 | ...safeHeaders, 76 | ...{ 77 | 'content-length': object.length, 78 | } 79 | }, 80 | contentType: object._mediaType.mimeType, 81 | ), 82 | // onSendProgress: (int count, int total) { 83 | // print(((count/total)*100).toStringAsFixed(2)); 84 | // } 85 | ); 86 | return object..uploadSuccessful(url); 87 | } catch (e) { 88 | rethrow; 89 | } 90 | } 91 | 92 | /// 验证检查 93 | Future verify() async { 94 | // 首次使用 95 | if (_signer == null) { 96 | _signer = Signer(await credentials.call()); 97 | } else { 98 | // 使用securityToken进行鉴权,则判断securityToken是否过期 99 | if (_signer!.credentials.useSecurityToken) { 100 | if (_signer!.credentials.expiration!.isBefore(DateTime.now().toUtc())) { 101 | _signer = Signer(await credentials.call()); 102 | } 103 | } else { 104 | // expiration | securityToken中途丢失,则清空 105 | _signer!.credentials.clearSecurityToken(); 106 | } 107 | } 108 | return _signer!; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /lib/src/http.dart: -------------------------------------------------------------------------------- 1 | part of aliyun_oss_flutter; 2 | 3 | var _http = _DioUtils.getInstance(); 4 | 5 | class _DioUtils { 6 | static Dio getInstance() { 7 | if (_instance == null) { 8 | _instance = Dio(BaseOptions( 9 | connectTimeout: const Duration(milliseconds: 1000 * 30), 10 | receiveTimeout: const Duration(milliseconds: 1000 * 30), 11 | )); 12 | 13 | _instance!.interceptors.add(LogInterceptor(responseBody: true)); 14 | } 15 | 16 | return _instance!; 17 | } 18 | 19 | static Dio? _instance; 20 | } 21 | // ignore: use_late_for_private_fields_and_variables 22 | -------------------------------------------------------------------------------- /lib/src/model.dart: -------------------------------------------------------------------------------- 1 | part of aliyun_oss_flutter; 2 | 3 | class Credentials { 4 | Credentials({ 5 | required this.accessKeyId, 6 | required this.accessKeySecret, 7 | this.securityToken, 8 | this.expiration, 9 | }) { 10 | if (!useSecurityToken) { 11 | clearSecurityToken(); 12 | } 13 | } 14 | 15 | factory Credentials.fromJson(String str) => 16 | Credentials.fromMap(json.decode(str) as Map); 17 | 18 | factory Credentials.fromMap(Map json) { 19 | return Credentials( 20 | accessKeyId: json['access_key_id'] as String, 21 | accessKeySecret: json['access_key_secret'] as String, 22 | securityToken: json['security_token'] as String, 23 | expiration: json['expiration'] != null 24 | ? DateTime.parse(json['expiration'] as String) 25 | : null, 26 | ); 27 | } 28 | 29 | final String accessKeyId; 30 | final String accessKeySecret; 31 | String? securityToken; 32 | DateTime? expiration; 33 | 34 | bool get useSecurityToken => securityToken != null && expiration != null; 35 | 36 | void clearSecurityToken() { 37 | securityToken = null; 38 | expiration = null; 39 | } 40 | } 41 | 42 | abstract class OSSObject { 43 | OSSObject._({ 44 | required this.bytes, 45 | MediaType? mediaType, 46 | this.uuid, 47 | }) : _mediaType = mediaType ?? MediaType('application', 'octet-stream'); 48 | 49 | final Uint8List bytes; 50 | 51 | final MediaType _mediaType; 52 | MediaType get mediaType => _mediaType; 53 | 54 | final String? uuid; 55 | 56 | String url = ''; 57 | 58 | int get length => bytes.lengthInBytes; 59 | 60 | String get type => _mediaType == MediaType('application', 'octet-stream') 61 | ? 'file' 62 | : _mediaType.type; 63 | 64 | String get name => 65 | (uuid ?? const Uuid().v1()) + 66 | (type == 'file' ? '' : '.${_mediaType.subtype}'); 67 | 68 | String get folderPath => [ 69 | type, 70 | DateFormat('y/MM/dd').format(DateTime.now()), 71 | ].join('/'); 72 | 73 | String resourcePath(String? path) => '${path ?? folderPath}/$name'; 74 | 75 | void uploadSuccessful(String url) { 76 | this.url = url; 77 | } 78 | } 79 | 80 | /// * [quality] 压缩存在问题,如果当图片没有exif将无法压缩 81 | class OSSImageObject extends OSSObject { 82 | OSSImageObject._({ 83 | required Uint8List bytes, 84 | required MediaType mediaType, 85 | String? uuid, 86 | }) : super._(bytes: bytes, mediaType: mediaType, uuid: uuid); 87 | 88 | factory OSSImageObject.fromBytes({ 89 | required Uint8List bytes, 90 | required MediaType mediaType, 91 | String? uuid, 92 | }) { 93 | return OSSImageObject._( 94 | bytes: bytes, 95 | mediaType: mediaType, 96 | uuid: uuid, 97 | ); 98 | } 99 | 100 | factory OSSImageObject.fromFile({ 101 | required File file, 102 | String? uuid, 103 | }) { 104 | String subtype = path.extension(file.path).toLowerCase(); 105 | subtype = subtype.isNotEmpty ? subtype.replaceFirst('.', '') : '*'; 106 | return OSSImageObject._( 107 | bytes: file.readAsBytesSync(), 108 | mediaType: MediaType('image', subtype), 109 | uuid: uuid, 110 | ); 111 | } 112 | 113 | // decodeImage UI 114 | // late int _width; 115 | // late int _height; 116 | // int get width => _width; 117 | // int get height => _height; 118 | 119 | // void _decodeExif() { 120 | // img.Image image; 121 | // if (mediaType.subtype == 'jpg' || mediaType.subtype == 'jpeg') { 122 | // image = img.decodeJpg(bytes); 123 | // } else if (mediaType.subtype == 'png') { 124 | // image = img.decodePng(bytes)!; 125 | // } else if (mediaType.subtype == 'gif') { 126 | // image = img.decodeGif(bytes)!; 127 | // } else { 128 | // image = img.decodeImage(bytes)!; 129 | // } 130 | // _width = image.width; 131 | // _height = image.height; 132 | // if (image.exif.hasOrientation) { 133 | // print(image.exif.orientation); 134 | // } 135 | // } 136 | } 137 | 138 | /// * [length] 秒为单位 139 | class OSSAudioObject extends OSSObject { 140 | OSSAudioObject._({ 141 | required Uint8List bytes, 142 | required MediaType mediaType, 143 | String? uuid, 144 | }) : super._(bytes: bytes, mediaType: mediaType, uuid: uuid); 145 | 146 | factory OSSAudioObject.fromBytes({ 147 | required Uint8List bytes, 148 | required MediaType mediaType, 149 | String? uuid, 150 | }) { 151 | return OSSAudioObject._( 152 | bytes: bytes, 153 | mediaType: mediaType, 154 | uuid: uuid, 155 | ); 156 | } 157 | 158 | factory OSSAudioObject.fromFile({ 159 | required File file, 160 | String? uuid, 161 | }) { 162 | String subtype = path.extension(file.path).toLowerCase(); 163 | subtype = subtype.isNotEmpty ? subtype.replaceFirst('.', '') : '*'; 164 | 165 | return OSSAudioObject._( 166 | bytes: file.readAsBytesSync(), 167 | mediaType: MediaType('audio', subtype), 168 | uuid: uuid, 169 | ); 170 | } 171 | } 172 | 173 | /// * [length] 秒为单位 174 | class OSSVideoObject extends OSSObject { 175 | OSSVideoObject._({ 176 | required Uint8List bytes, 177 | required MediaType mediaType, 178 | String? uuid, 179 | }) : super._(bytes: bytes, mediaType: mediaType, uuid: uuid); 180 | 181 | factory OSSVideoObject.fromBytes({ 182 | required Uint8List bytes, 183 | required MediaType mediaType, 184 | String? uuid, 185 | }) { 186 | return OSSVideoObject._( 187 | bytes: bytes, 188 | mediaType: mediaType, 189 | uuid: uuid, 190 | ); 191 | } 192 | 193 | factory OSSVideoObject.fromFile({ 194 | required File file, 195 | String? uuid, 196 | }) { 197 | String subtype = path.extension(file.path).toLowerCase(); 198 | subtype = subtype.isNotEmpty ? subtype.replaceFirst('.', '') : '*'; 199 | 200 | return OSSVideoObject._( 201 | bytes: file.readAsBytesSync(), 202 | mediaType: MediaType('video', subtype), 203 | uuid: uuid, 204 | ); 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /lib/src/signer.dart: -------------------------------------------------------------------------------- 1 | part of aliyun_oss_flutter; 2 | 3 | class SignedInfo { 4 | const SignedInfo({ 5 | required this.dateString, 6 | required this.accessKeyId, 7 | required this.signature, 8 | this.securityToken, 9 | }); 10 | 11 | final String dateString; 12 | final String accessKeyId; 13 | final String signature; 14 | final String? securityToken; 15 | 16 | Map toHeaders() => { 17 | 'Date': dateString, 18 | 'Authorization': 'OSS $accessKeyId:$signature', 19 | if (securityToken != null) 'x-oss-security-token': securityToken!, 20 | }; 21 | } 22 | 23 | class Signer { 24 | const Signer(this.credentials); 25 | final Credentials credentials; 26 | 27 | /// [dateString] `Date` in [HttpDate] or `Expires` in [DateTime.secondsSinceEpoch] 28 | SignedInfo sign({ 29 | required String httpMethod, 30 | required String resourcePath, 31 | Map? parameters, 32 | Map? headers, 33 | String? contentMd5, 34 | String? dateString, 35 | }) { 36 | final securityHeaders = { 37 | if (headers != null) ...headers, 38 | if (credentials.securityToken != null) ...{ 39 | 'x-oss-security-token': credentials.securityToken!, 40 | } 41 | }; 42 | final sortedHeaders = _sortByLowerKey(securityHeaders); 43 | final contentType = sortedHeaders 44 | .firstWhere( 45 | (e) => e.key == 'content-type', 46 | orElse: () => const MapEntry('', ''), 47 | ) 48 | .value; 49 | final canonicalizedOSSHeaders = sortedHeaders 50 | .where((e) => e.key.startsWith('x-oss-')) 51 | .map((e) => '${e.key}:${e.value}') 52 | .join('\n'); 53 | 54 | final securityParameters = { 55 | if (parameters != null) ...parameters, 56 | }; 57 | final canonicalizedResource = 58 | _buildCanonicalizedResource(resourcePath, securityParameters); 59 | 60 | final date = dateString ?? _requestTime(); 61 | final canonicalString = [ 62 | httpMethod, 63 | contentMd5 ?? '', 64 | contentType, 65 | date, 66 | if (canonicalizedOSSHeaders.isNotEmpty) canonicalizedOSSHeaders, 67 | canonicalizedResource, 68 | ].join('\n'); 69 | 70 | final signature = _computeHmacSha1(canonicalString); 71 | return SignedInfo( 72 | dateString: date, 73 | accessKeyId: credentials.accessKeyId, 74 | signature: signature, 75 | securityToken: credentials.securityToken); 76 | } 77 | 78 | String _buildCanonicalizedResource( 79 | String resourcePath, Map parameters) { 80 | if (parameters.isNotEmpty == true) { 81 | final queryString = _sortByLowerKey(parameters) 82 | .map((e) => '${e.key}=${e.value}') 83 | .join('&'); 84 | return '$resourcePath?$queryString'; 85 | } 86 | return resourcePath; 87 | } 88 | 89 | String _computeHmacSha1(String plaintext) { 90 | final digest = Hmac(sha1, utf8.encode(credentials.accessKeySecret)) 91 | .convert(utf8.encode(plaintext)); 92 | return base64.encode(digest.bytes); 93 | } 94 | 95 | List> _sortByLowerKey(Map map) { 96 | final lowerPairs = map.entries.map( 97 | (e) => MapEntry(e.key.toLowerCase().trim(), e.value.toString().trim())); 98 | return lowerPairs.toList()..sort((a, b) => a.key.compareTo(b.key)); 99 | } 100 | 101 | String _requestTime() { 102 | initializeDateFormatting('en', null); 103 | final DateTime now = DateTime.now(); 104 | final String string = 105 | DateFormat('EEE, dd MMM yyyy HH:mm:ss', 'en_ISO').format(now.toUtc()); 106 | return '$string GMT'; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 9 | url: "https://pub.flutter-io.cn" 10 | source: hosted 11 | version: "2.11.0" 12 | characters: 13 | dependency: transitive 14 | description: 15 | name: characters 16 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 17 | url: "https://pub.flutter-io.cn" 18 | source: hosted 19 | version: "1.3.0" 20 | clock: 21 | dependency: transitive 22 | description: 23 | name: clock 24 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 25 | url: "https://pub.flutter-io.cn" 26 | source: hosted 27 | version: "1.1.1" 28 | collection: 29 | dependency: transitive 30 | description: 31 | name: collection 32 | sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" 33 | url: "https://pub.flutter-io.cn" 34 | source: hosted 35 | version: "1.17.1" 36 | crypto: 37 | dependency: "direct main" 38 | description: 39 | name: crypto 40 | sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab 41 | url: "https://pub.flutter-io.cn" 42 | source: hosted 43 | version: "3.0.3" 44 | dio: 45 | dependency: "direct main" 46 | description: 47 | name: dio 48 | sha256: "417e2a6f9d83ab396ec38ff4ea5da6c254da71e4db765ad737a42af6930140b7" 49 | url: "https://pub.flutter-io.cn" 50 | source: hosted 51 | version: "5.3.3" 52 | flutter: 53 | dependency: "direct main" 54 | description: flutter 55 | source: sdk 56 | version: "0.0.0" 57 | flutter_lints: 58 | dependency: "direct dev" 59 | description: 60 | name: flutter_lints 61 | sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 62 | url: "https://pub.flutter-io.cn" 63 | source: hosted 64 | version: "2.0.3" 65 | http_parser: 66 | dependency: "direct main" 67 | description: 68 | name: http_parser 69 | sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" 70 | url: "https://pub.flutter-io.cn" 71 | source: hosted 72 | version: "4.0.2" 73 | intl: 74 | dependency: "direct main" 75 | description: 76 | name: intl 77 | sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" 78 | url: "https://pub.flutter-io.cn" 79 | source: hosted 80 | version: "0.18.1" 81 | js: 82 | dependency: transitive 83 | description: 84 | name: js 85 | sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 86 | url: "https://pub.flutter-io.cn" 87 | source: hosted 88 | version: "0.6.7" 89 | lints: 90 | dependency: transitive 91 | description: 92 | name: lints 93 | sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" 94 | url: "https://pub.flutter-io.cn" 95 | source: hosted 96 | version: "2.1.1" 97 | material_color_utilities: 98 | dependency: transitive 99 | description: 100 | name: material_color_utilities 101 | sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 102 | url: "https://pub.flutter-io.cn" 103 | source: hosted 104 | version: "0.2.0" 105 | meta: 106 | dependency: transitive 107 | description: 108 | name: meta 109 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" 110 | url: "https://pub.flutter-io.cn" 111 | source: hosted 112 | version: "1.9.1" 113 | path: 114 | dependency: "direct main" 115 | description: 116 | name: path 117 | sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" 118 | url: "https://pub.flutter-io.cn" 119 | source: hosted 120 | version: "1.8.3" 121 | sky_engine: 122 | dependency: transitive 123 | description: flutter 124 | source: sdk 125 | version: "0.0.99" 126 | source_span: 127 | dependency: transitive 128 | description: 129 | name: source_span 130 | sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" 131 | url: "https://pub.flutter-io.cn" 132 | source: hosted 133 | version: "1.10.0" 134 | string_scanner: 135 | dependency: transitive 136 | description: 137 | name: string_scanner 138 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 139 | url: "https://pub.flutter-io.cn" 140 | source: hosted 141 | version: "1.2.0" 142 | term_glyph: 143 | dependency: transitive 144 | description: 145 | name: term_glyph 146 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 147 | url: "https://pub.flutter-io.cn" 148 | source: hosted 149 | version: "1.2.1" 150 | typed_data: 151 | dependency: transitive 152 | description: 153 | name: typed_data 154 | sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c 155 | url: "https://pub.flutter-io.cn" 156 | source: hosted 157 | version: "1.3.2" 158 | uuid: 159 | dependency: "direct main" 160 | description: 161 | name: uuid 162 | sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" 163 | url: "https://pub.flutter-io.cn" 164 | source: hosted 165 | version: "3.0.7" 166 | vector_math: 167 | dependency: transitive 168 | description: 169 | name: vector_math 170 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 171 | url: "https://pub.flutter-io.cn" 172 | source: hosted 173 | version: "2.1.4" 174 | sdks: 175 | dart: ">=3.0.0 <4.0.0" 176 | flutter: ">=3.3.0" 177 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: aliyun_oss_flutter 2 | description: aliyun oss plugin for flutter. Use this plugin to upload files to aliyun oss. 3 | version: 1.1.1 4 | homepage: https://github.com/lucky1213/aliyun_oss 5 | 6 | environment: 7 | sdk: ">=2.17.0 <4.0.0" 8 | flutter: ">=3.3.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | path: ^1.8.2 15 | 16 | http_parser: ^4.0.2 17 | 18 | crypto: ^3.0.2 19 | 20 | intl: ^0.18.1 21 | 22 | # A powerful Http client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout etc. 23 | dio: ^5.1.1 24 | 25 | uuid: ^3.0.7 26 | 27 | dev_dependencies: 28 | 29 | # The "flutter_lints" package below contains a set of recommended lints to 30 | # encourage good coding practices. The lint set provided by the package is 31 | # activated in the `analysis_options.yaml` file located at the root of your 32 | # package. See that file for information about deactivating specific lint 33 | # rules and activating additional ones. 34 | flutter_lints: ^2.0.0 35 | 36 | # For information on the generic Dart part of this file, see the 37 | # following page: https://dart.dev/tools/pub/pubspec 38 | 39 | # The following section is specific to Flutter. 40 | flutter: 41 | 42 | # To add assets to your package, add an assets section, like this: 43 | # assets: 44 | # - images/a_dot_burr.jpeg 45 | # - images/a_dot_ham.jpeg 46 | # 47 | # For details regarding assets in packages, see 48 | # https://flutter.dev/assets-and-images/#from-packages 49 | # 50 | # An image asset can refer to one or more resolution-specific "variants", see 51 | # https://flutter.dev/assets-and-images/#resolution-aware. 52 | 53 | # To add custom fonts to your package, add a fonts section here, 54 | # in this "flutter" section. Each entry in this list should have a 55 | # "family" key with the font family name, and a "fonts" key with a 56 | # list giving the asset and other descriptors for the font. For 57 | # example: 58 | # fonts: 59 | # - family: Schyler 60 | # fonts: 61 | # - asset: fonts/Schyler-Regular.ttf 62 | # - asset: fonts/Schyler-Italic.ttf 63 | # style: italic 64 | # - family: Trajan Pro 65 | # fonts: 66 | # - asset: fonts/TrajanPro.ttf 67 | # - asset: fonts/TrajanPro_Bold.ttf 68 | # weight: 700 69 | # 70 | # For details regarding fonts in packages, see 71 | # https://flutter.dev/custom-fonts/#from-packages 72 | -------------------------------------------------------------------------------- /test/aliyun_oss_test.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | 3 | } 4 | --------------------------------------------------------------------------------