Core: over the wall, terminal agent, remove mirror system variables
A pub:
Pub is the package Manager for Dart
Official website: pub.dartlang.org
This domain name has been pinged by several partners at the same time, and the corresponding IP address is different. Therefore, we can know that this website has load balancing, but the pit comes, part of it is outside the wall, so this is the reason why this website is not smooth in China occasionally.
Ping pub.dartlang.org is ping ghs.googlehosted.com [216.58.200.243] with 32 bytes of data: Bytes =32 time =58ms TTL=40 Reply from 216.58.200.243: bytes =32 time =58ms TTL=40 Reply from 216.58.200.243: bytes =32 time =58ms TTL=40 Reply from 216.58.200.243: Bytes =32 time =58ms TTL=40 Reply from 216.58.200.243: bytes =32 time =58ms TTL=40 Ping statistics: Packets: Sent = 4, Received = 4, Lost = 0 (0% lost), estimated round trip time in milliseconds: Minimum = 58ms, Maximum = 58ms, average = 58msCopy the code
Domestic mirror site eg: pub.flutter- IO. Cn /
Set access to the mirror: in the environment variable, this depends on the system Settings:
- MAC:
1.1 can be added temporarily using the export command or in this file in vi ~/.bash_profile
- Win is in the system variable
PUB_HOSTED_URL=https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Copy the code
Second, the Package:
Using package, you can create modular code that can be easily shared. A minimum package includes:
- A pubspec.yaml file: a metadata file that declares the name, version, author, and so on of the package.
- A lib folder: include the public code in the package, and at least one.dart file
Iii. Package type:
- Dart packages: Some of these may contain the specific functionality of a Flutter and therefore have a dependency on the Flutter framework for use only with a Flutter, such as the Fluro package.
- Plug-in package: A dedicated Dart package that contains apis written in Dart code and specific implementations for Android (using Java or Kotlin) and/or iOS (using ObjC or Swift) platforms. A concrete example is the Battery plug-in package.
Iv. Relevant Documents:
- Readme. md: The file that introduces the package
- Changelog. md: Records the changes in each version
- LICENSE: a file containing the LICENSE terms of a software package
Release packages:
Sometimes we write our own open source libraries and want to publish them to pub.
Dart/Flutter has no concept of approval for plug-ins, and publishing is simple. You can publish any plugin to the PUB as long as it is not duplicated, so that other developers can easily use it.
Before publishing, check pubspec.yaml, readme. md, and Changelog.md files for completeness and correctness of their content.
Premise:
Code 1.
2. Command line flip wall tool The command line flip wall tool is used because domestic images cannot be published and must be connected to the official source of pub
Google accounts are used to confirm permissions, bind libraries to your authorship, and prevent others from overwriting your plugin
The terminal over the wall
This involves connecting to Google, so you have to make sure your terminal is over the wall
** MAC: ** Enter curl google.com. If you have a successful palindrome (an HTML text message), you have successfully connected to google.com. If you do not have a successful palindrome, your terminal is still inside the wall
SS(small aircraft) terminal HTTP protocol over the wall can be simple in the terminal input:
Export http_proxy = http://127.0.0.1:1081; Export https_proxy = http://127.0.0.1:1081;Copy the code
** win: ** I use the free gate: after the connection is successful, the port number will be displayed. Git bash does not support the following command: curl
Release steps:
1. Run the dry-run command to check whether everything is ready. If there is any problem, modify the information as prompted. flutter packages pub publish --dry-run | |-- search_input | | '-- search_input.dart | '-- sliver | |-- pinned_appbar.dart | '-- safearea_header.dart |-- pubspec.yaml '-- test '-- flutterlib_test.dart Looks great! Are you ready to upload your package (y/n)? Terminate the batch operation (Y/N)? Y oR: Missing requirements: * Your pubspec.yaml is Missing a "homepage" field. Run the publish command: Flutter packages pub publish 2.1 More detailed information can be viewed by wearing -v. 2.2 If VPN still does not work, Try using --server flutter packages pub publish --server=https://pub.dartlang.org to point the address to the official, not the domestic mirror. | |-- search_input | | '-- search_input.dart | '-- sliver | |-- pinned_appbar.dart | '-- safearea_header.dart |-- pubspec.yaml '-- test '-- flutterlib_test.dart Looks great! Are you ready to upload your package (y/n)? y Pub needs your authorization to upload packages on your behalf. In a web browser, go to https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&response_type=code&client_id=818368 855108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A49996&scope=ope nid+https%3A%2F%2Fwww.g oogleapis.com%2Fauth%2Fuserinfo.email Then click "Allow access". Waiting for your authorization... Authorization received, processing... Successfully authorized. Uploading... Failed to upload the package. pub finished with exit code 1 If the package is released for the first time, Google account authentication and authorization are required. After the authentication is successful, subsequent authentication operations are not required. 2. If you do not appear Google account authorized that URL only two cases, one is you have authorized before, two is you failed to connect. 3. Authentication effect: https://upload-images.jianshu.io/upload_images/2097746-6d17aacb2fff4ed7.png? imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp | '-- sliver | |-- pinned_appbar.dart | '-- safearea_header.dart |-- pubspec.yaml '-- test '-- flutterlib_test.dart Looks great! Are you ready to upload your package (y/n)? y Uploading... Failed to upload the package. pub finished with exit code 1 2. Using the -v effect, you can see specific error messages: MSG: Uploading... IO : HTTP GET https://pub.dartlang.org/api/packages/versions/new | Accept: application/vnd.pub.v2+json | authorization: < censored > | the user-agent: Dart pub 2.7.2 FINE: Uploading finished (21.090 s). The FINE: Saving OAuth2 credentials. IO: Writing 466 characters to text file D:\Program Files\flutter\.pub-cache\credentials.json. ERR : Proxy failed to establish tunnel (400 Bad Request) FINE: Exception type: ClientException FINE: package:http/src/io_client.dart 65:7 IOClient.send | ===== asynchronous gap =========================== | dart:async Future.catchError | package:pub/src/utils.dart 109:52 captureErrors.<fn> | package:stack_trace Chain.capture | package:pub/src/utils.dart 122:11 captureErrors | package:pub/src/command_runner.dart 171:13 PubCommandRunner.runCommand | dart:async _completeOnAsyncReturn | package:pub/src/command_runner.dart PubCommandRunner._validatePlatform | dart:async _completeOnAsyncReturn | package:pub/src/io.dart runProcess.<fn> pub finished with exit code 69 #0 throwToolExit (package:flutter_tools/src/base/common.dart:28:3) #1 _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:323:7) <asynchronous suspension> #2 PackagesPassthroughCommand.runCommand (package:flutter_tools/src/commands/packages.dart:269:15) #3 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:615:18) #4 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64) #5 _rootRunUnary (dart:async/zone.dart:1134:38) #6 _CustomZone.runUnary (dart:async/zone.dart:1031:19) #7 _FutureListener.handleValue (dart:async/future_impl.dart:139:18) 3. View environmental issues with Flutter Doctor: D:\workspace1\flutterlib>flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel Stable, V1.12.13 +hotfix.9, on Microsoft Windows [Version 10.0.14393], Locale zh-CN) [√] Android Toolchain - Develop for Android Devices (Android SDK Version 29.0.2) [√] Android Studio (version 3.6) [!] Proxy Configuration ! NO_PROXY is not set [√] Connected device (1 available)! Doctor found issues in 1 category. 4. If the terminal does not successfully set up the proxy, Unable to access Google account | '- silver | | -- pinned_appbar. Dart |' -- safearea_header. Dart | -- pubspec. Yaml '- test - flutterlib_test.dart Looks great! Are you ready to upload your package (y/n)? y Uploading... It looks like accounts.google.com is having some trouble. Pub will wait for a while before trying to connect again. 5. Uploading successful results: | '-- sliver | |-- pinned_appbar.dart | '-- safearea_header.dart |-- pubspec.yaml '-- test '-- flutterlib_test.dart Looks great! Are you ready to upload your package (y/n)? y Uploading... Successfully uploaded package. Upload library on the pub you can see: https://pub.flutter-io.cn/packages/flutterlibCopy the code
Failure to release packages
- Gmail authentication succeeded, but an error was reported indicating that accounts.google.com could not be accessed.
It looks like accounts.google.com is having some trouble. Pub will wait for a while before trying to connect again. Solution: Set the terminal proxy (the port number is the connected port in the wall scaling tool), set the proxy, upload again. Do not use THE SOck5 protocol to set the proxy. Otherwise, Invalid Request method export http_proxy=http://127.0.0.1:1080 export https_proxy=http://127.0.0.1:1080 set may be displayed Http_proxy =http://127.0.0.1:8580 set https_proxy=https://127.0.0.1:8580 (you may need to restart the terminal) making solution: https://github.com/flutter/flutter/issues/17070Copy the code
- Failed to upload the package
Uploading... Failed to upload the package. Pub finished with exit code 1. The HTTP Proxy configured by the system setting in Android Studio may be valid, but the above problems still occur. You need to enter the following command in Terminal to perform this step again. Set http_proxy=http://127.0.0.1:8580 set https_proxy=https://127.0.0.1:8580 2. If the image is set as recommended by the official website: export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn Be sure to comment it out before uploading, and remove the corresponding system variables in THE WIN environment. 3. Making solutions: https://github.com/flutter/flutter/issues/16658 have said enough permissions: Sudo packages pub publish -v sudo packages pub publish -v Post online discussion: Sharpron commented on 22 Jul 2019 commented. yuxuelian commented. yuxuelian commented. 21 Aug 2019 COMMented. yuxuelian commented on 21 Aug 2019 I can curl www.google.com, but still failed there are many netizens, many developers have encountered such a problem, have not solved. Also from the side shows that the WIN environment is not very friendly to this compatibility.Copy the code
- Successful experience of WIN environment:
1. First of all, after a series of crazy operations according to the steps described on the Internet, it was found that the long transmission failed anyway, authentication was successful, and finally there was no hint that the Google account could not be accessed, that is, the upload failed. 2. Try this for MAC SOdu: On the cli, enter taskkill /f /im Explorer. Exe and press Enter. On the CLI, enter at Time/Interactive % Systemroot % Explorer. Directly blocked the black screen. 3. Then restart the machine and open Studio, set HTTP Proxy (HTTP, HTTPS), open the wall turning software, and then set it in the terminal: Set http_proxy=http://127.0.0.1:8580 set https_proxy=https://127.0.0.1:8580 Summary thinking: 1. The core problem is still the wall problem. Set up the agent for the terminal, so that the terminal can also climb the wall, and ensure the success of setting the agent. The Win environment is not as command-line friendly as the MAC environment, so if setting up agents still doesn't work, consider restarting your computer and trying again.Copy the code
Reference: flutterchina club/developing -…