Tag Archives: Flutter

[Solved] Flyter uses screenutil to obtain screen width and height initialization error

Errors are reported as follows

reason

We use screenutil().Screenwidth to obtain the screen width in the layout. When initializing the unloaded view, we can’t get it for the first time, and the above crash will occur.

Solution

import 'package:flutter_screenutil/screenutil_init.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@override
Widget build(BuildContext context) {
  //Wrap the entire body layout with screen initialization
  return ScreenUtilInit(
    //set initial screen size
    designSize: Size(375, 812),
    builder: () => Scaffold(
      backgroundColor: WBColors.color_f4f5f7,
      body: Container(
          height: 263.5,
          width: ScreenUtil().screenWidth,
        )
    )
  );
}

Use the screenutilinit screen initialization component to wrap the outermost layer of the entire page layout and set the initial screen size. The API for obtaining screen width and height can be used arbitrarily in the body

[Solved] Vue package error: Syntax Error: Error: Cannot find module ‘mozjpeg’

Syntax Error: Error: Cannot find module 'mozjpeg'

The main reason is that some dependencies of image webpack loader are not installed successfully, which makes the processing of pictures report errors

Attempting to install dependencies:

npm install mozjpeg

report errors:

connect ECONNREFUSED 0.0.0.0:443
mozjpeg pre-build test failed

You can solve this problem by modifying hosts.

Modify hosts for MAC system

https://github.com/googlehosts/hosts
Go to this website to download files
open the terminal, enter open/etc
and paste the hosts into the etc folder to replace the original hosts file.

The reinstallation was successful and the packaging was successful.

Failed to register observatory port with mDNS with error

An error is reported when Fletter runs IOS real machine: failed to register observation port with mDNS with error

Errors are reported as follows

[VERBOSE-2:FlutterObservatoryPublisher.mm(101)] Failed to register observatory port with mDNS with error -65555.
[VERBOSE-2:FlutterObservatoryPublisher.mm(103)] On iOS 14+, local network broadcast in apps need to be declared in the app's Info.plist. Debug and profile Flutter apps and modules host VM services on the local network to support debugging features such as hot reload and DevTools. To make your Flutter app or module attachable and debuggable, add a '_dartobservatory._tcp' value to the 'NSBonjourServices' key in your Info.plist for the Debug/Profile configurations.

Solution: (refer to the official link document above)

On iOS 14 and higher, enable the Dart multicast DNS service in the Debug version of your app to add debugging functionalities such as hot-reload and DevTools via flutter attach.

1. Rename the application’s info.plist to info-debug.plist. Make a copy called info-release.plist and add it to the Xcode project
2. In info-debug.plist, add the key nsbonjourservices and set the value to_ dartobservatory._ tcp

(optional) add the key nslocalnetworkusagedescription to the text of the desired custom permissions dialog box. (Note: ‘allow shutter tools on your computer to connect and debug your application. This prompt will not appear on release builds.’)

3. In target’s build settings, modify the info.plist file path path/to/info.plist to path/to/Info – $(configuration). Plist.
4. In target’s – & gt; Build Settings > Build Phases > Copy bundle resources build phase. If info-release.plist is deleted (I have deleted it in the figure below)

reference resources

How to Solve Tabbarview error in Column 2021

reason

The tabbarviewcomponent occupies as much space as the parent component. Generally, the outer layer of this layout is scrollable, similar to singlechildscrollview, but there is no clear height constraint in the column, that is, infinite height, so an error is reported.

Solution:

1. Fixed height

It directly solves the problem locally, but there is a big disadvantage. The components loaded by tabbarview may have different heights, so the predetermined height should be their maximum height, and the layout is not good-looking.

SingleChildScrollView(
  child: Column(
    children: [
      MyTabBar(),
     SizedBox(
     	height: 500,
    	child: TabBarView(
    		children:[
  				MyTabView1(),
  				MyTabView2(),
    		],
    	),
     ),
    ],
  ),
)

2. Do not use the tabbarview component

It is recommended to use the indexedstack component instead. The disadvantage is that it lacks the sliding animation of the original tabbarview component, but it can be customized with the animatedswitcher component. Click to learn more

SingleChildScrollView(
  child: Column(
    children: [
      MyTabBar(),
      IndexedStack(
      	index: currentIndex, //currentIndex is the value of my example, in reality it may come from TabController, or Provider, etc.
      	children:[
      		MyTabView1(),
  			MyTabView2(),
      	],
      ),
     ),
    ],
  ),
)

3. To be continued

How to Solve Macbookm1 pod error

Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "ZLPhotoBrowser":
  In snapshot (Podfile.lock):
    ZLPhotoBrowser (= 4.1.5)

  In Podfile:
    images_picker (from `.symlinks/plugins/images_picker/ios`) was resolved to 0.0.1, which depends on
      ZLPhotoBrowser (= 4.1.9)


You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `ZLPhotoBrowser` inside your development pod `images_picker`.
   You should run `pod update ZLPhotoBrowser` to apply changes you've made.

Solution:

sudo arch -x86_64 gem install ffi

arch -x86_64 pod install
//Prompt for pod update ZLPhotoBrowser uses the arch -x86_64 pod to update
arch -x86_64 pod update ZLPhotoBrowser

How to Solve Project Upgrade to flutter2.5.0 Error

Record an error report about the error report after the project is upgraded to 2.5.0

error message 1:

Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

Solution:
in your project level gradle file, just increase ext.kotlin.version from any version you have to "1.4.32" or any latest version available. Path:/Android/build. Gradle

buildscript {
    // ext.kotlin_version = '1.3.50'
    ext.kotlin_version = '1.4.32'
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google'}
        maven { url 'https://maven.aliyun.com/repository/jcenter'}
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public'}
        // google()
        // mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google'}
        maven { url 'https://maven.aliyun.com/repository/jcenter'}
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public'}
        // google()
        // mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Error Message 2:
D8: Cannot fit requested classes in a single dex file (# methods: 76688 > 65536) com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The shrinker may have failed to optimize the Java bytecode.
Solution
Path: /android/app/build.gradle,Change the minSdkVersion version to a larger one, e.g. 21

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.good_commodity"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

GeTx reports an error in the get request using getconnect

The specific error reports are as follows:

flutter/lib/ui/ui_ dart_ state.cc(209)] Unhandled Exception: type ‘int’ is not a subtype of type ‘Iterable< dynamic>’

The reason is that I use the get request and the parameters are not spliced after the URL, that is, in this form, XXX?X = 1 & amp; y=2。

But use   Map< String, dynamic>? Query a map to place parameters.

Check the source code to find the reason. If the value in query is not of string type, it will be converted to an iterator, and I put it as an int, so the conversion reports an error. The solution is to convert all the values in the query map into strings.

query?.map((key, value) => MapEntry(key, value.toString()))

Does flutter report an error after upgrading 2.5?

Q:

After the flutter executes the command to upgrade the new version, there are the following problems when checking with the flutter doctor command:

After typing the command according to the prompt, an error message appears again:

A:
after we upgrade the SDK, execute fluent doctor , which prompts us to install the command line tools developed by Android. When we install the command line tool according to the prompt, the Java error is generally because we have installed a set of java version locally, but the Java version number is higher than 1.8, resulting in compatibility problems.

There are two ways to solve the problem. The first is to uninstall our own installed Java and reinstall a lower version of Java (1.8), but it is not recommended!

Since Android development can only use java version 1.8, the Android Studio development environment will bring its own Java virtual machine, so we don’t need to install an independent Java environment ourselves. Therefore, we actually don’t need to pay attention to our locally installed java version. We can directly open the Android studio tool and automatically install CmdLine tools :

As shown in the figure above, check the tool and click OK to install it automatically. After installation, re execute the fluent doctor command to solve the problem!


Official account: programming path from 0 to 1

[Solved] Fluent filesysterexception: exists failed, path =’d: \ as’. Plugins’ (OS error: incorrect file name, directory name or volume slogan)

E:\flutter_project\first_app>flutter doctor -v
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.1052], locale zh-CN)
    • Flutter version 2.2.3 at D:\flutter
    • Framework revision f4abaa0735 (7 days ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at D:\Android
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = D:\Android
    • Java binary at: D:\Java\jdk\bin\java
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[☠] Android Studio (the doctor check crashed)
    X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know
      about this issue at https://github.com/flutter/flutter/issues.
    X FileSystemException: Exists failed, path = ''D:\AS'.plugins' (OS Error: 文件名、目录名或卷标语法不正确。
      , errno = 123)
    • #0      _Directory.existsSync (dart:io/directory_impl.dart:94:7)
      #1      ForwardingFileSystemEntity.existsSync
      (package:file/src/forwarding/forwarding_file_system_entity.dart:43:33)
      #2      ErrorHandlingDirectory.existsSync.<anonymous closure>
      (package:flutter_tools/src/base/error_handling_io.dart:479:22)
      #3      _runSync (package:flutter_tools/src/base/error_handling_io.dart:573:14)
      #4      ErrorHandlingDirectory.existsSync (package:flutter_tools/src/base/error_handling_io.dart:478:12)
      #5      AndroidStudio.pluginsPath (package:flutter_tools/src/android/android_studio.dart:186:52)
      #6      AndroidStudioValidator.validate (package:flutter_tools/src/android/android_studio_validator.dart:46:17)
      #7      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
      #8      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:109:18)
      #9      _rootRun (dart:async/zone.dart:1354:13)
      #10     _CustomZone.run (dart:async/zone.dart:1258:19)
      #11     _runZoned (dart:async/zone.dart:1789:10)
      #12     runZonedGuarded (dart:async/zone.dart:1777:12)
      #13     runZoned (dart:async/zone.dart:1708:12)
      #14     asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
      #15     Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:199:9)
      #16     Doctor.diagnose (package:flutter_tools/src/doctor.dart:303:47)
      #17     DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:50:47)
      #18     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1192:12)
      <asynchronous suspension>
      #19     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
      <asynchronous suspension>
      #20     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
      <asynchronous suspension>
      #21     CommandRunner.runCommand (package:args/command_runner.dart:196:13)
      <asynchronous suspension>
      #22     FlutterCommandRunner.runCommand.<anonymous closure>
      (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
      <asynchronous suspension>
      #23     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
      <asynchronous suspension>
      #24     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
      <asynchronous suspension>
      #25     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
      <asynchronous suspension>
      #26     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
      <asynchronous suspension>
      #27     main (package:flutter_tools/executable.dart:91:3)
      <asynchronous suspension>


[√] IntelliJ IDEA Community Edition (version 2021.1)
    • IntelliJ at D:\Intelij\IntelliJ IDEA Community Edition 2021.1.2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.57.1)
    • VS Code at C:\Users\zhongdongjing\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.124
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 91.0.864.64

! Doctor found issues in 1 category.

Run fluent config -- Android studio dir = "C:\program files\Android\Android studio" this problem occurs if the path of Android studio cannot be found. Make sure to use the correct Android studio path.

Run fluent doctor again

[Solved] Flutter SDK constraint error: pub get failed (65; See…

Download a file from git, open it, run fluent pub get, and an error occurs:
pubspec.yaml has no lower bound SDK constraint.
you should edit pubspec.yaml to contain an SDK constraint:
environment:
SDK: ‘>= 2.10.0 < 3.0.0 ‘

add to pubspec.yaml:
environment: SDK:’ >= 2.10.0 < 3.0.0 ‘
after rerunning fluent pub get, an error is still reported, indicating that the SDK constraint is not added. Later, it is found that the subfolder example of the home folder also contains a pubspec.yaml file, in which the SDK constraint is not added
after adding constraints, run fluent pub get.

Flutter upgrade upgrade SDK SSL_ERROR_Syscall error [How to Solve]

Execute the following commands when upgrading the flutter

Flutter upgrade

Unfortunately, for some reason, it cannot be accessed. The following error is reported

Standard error: fatal: unable to access
'https://github.com/flutter/flutter.git/': LibreSSL SSL_connect:
SSL_ERROR_SYSCALL in connection to github.com:443

You can set the routing agent. The command is as follows:

git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy http://127.0.0.1:1080

Note that the port can be modified according to its own configuration. Set or not set HTTPS according to your needs
if you want to cancel the proxy setting, you can use the following command:

git config --global --unset http.proxy 
git config --global --unset https.proxy

After setting, test OK

Git config — the global command will add the following configuration in the ~ /. Gitconfig file

[http]
	proxy = http://127.0.0.1:1080
[https]
	proxy = https://127.0.0.1:1080

Note:
there is another way to use this command. It has not been tested yet. Save it first

git config --global --add remote.origin.proxy

Flutter flutter doctor –android-licenses [How to Solve]

Error message

Solution:

In androidstuido, file – > Setting-> Appearance-> System Setting-> Check whether it is installed under the Android SDK (as shown in the figure)

if not, directly click Android stuido to download
and then run the shuttle doctor — Android licenses to select y in the whole process

result

Execute the flitter doctor to check all √ to prove that it has been arranged