Flutter学习笔记

问题

  1. Exception in thread “main” java.util.zip.ZipException: zip END header not found
 **For mac user:** open terminal and execute

 >   cd ~

 >   rm -rf .gradle

 **For windows user:**

 Go to the root directory C:\Users\YourUser and locate the hidden .gradle folder and delete it. and then run your app connected to an Android emulator or device, don't cancel and make have a stable internet connection, this will download fresh Gradle

 [Flutter: Exception in thread "main" java.util.zip.ZipException: error in opening zip file](https://stackoverflow.com/questions/60899075/flutter-exception-in-thread-main-java-util-zip-zipexception-error-in-opening)

 我的解决方案:手动下载https\://services.gradle.org/distributions/gradle-7.5-all.zip到`C:\Users\xxx\.gradle\wrapper\dists\gradle-7.5-all\xxx`
  1. adb: failed to install
 In your manifest, add `android:exported="true"`.

 example:

 
1
2
3
4
5
6
7
8
<activity
android:name="com.example.packssas.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
用`adb shell` 验证,安卓真机和仿真器同时只能有一个启动
  1. Flutter(Dart)udp组播,本地调试可以成功抓到数据包,但在apk中使用未抓到数据包

  2. The lower bound of “sdk: ‘>=2.2.0 ❤️.0.0’” must be 2.12.0 or higher to enable null safety.

    https://blog.csdn.net/wuqingsen1/article/details/121519297

    1
    2
    environment:
    sdk: '>=2.11.0 <3.0.0'
  3. chrome://inspect

  4. 比特流转换

    Your data contains 28 bytes, and since it represents 32-bit float values (each of which are 4 bytes), that’s equivalent to seven 32-bit values.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    final data = [
    123, 34, 106, 115, // 1
    111, 110, 114, 112, // 2
    99, 34, 58, 34, // 3
    50, 46, 48, 34, // 4
    44, 34, 109, 101, // 5
    116, 104, 111, 100, // 6
    34, 58, 34, 115, // 7
    ];

    The ByteData class from the dart:typed_data library gives you different views on byte data. What you want is the Float32 view, which will give you a double in Dart.

    1
    2
    3
    4
    final bytes = Uint8List.fromList(data);
    final byteData = ByteData.sublistView(bytes);
    double value = byteData.getFloat32(0);
    print(value); // 8.433111377393183e+35

    The 0 in getFloat32(0) means that you want to get the 32-bit float value starting at index 0 in the byte array. That only gives you the first value of the seven, though, so if you want the rest you need to loop though the entire byte list:

    1
    2
    3
    for (var i = 0; i < data.length; i += 4) {
    print(byteData.getFloat32(i));
    }

    On every loop you increase the index by 4 to get the beginning of the next 32-bit float value. Run that loop and you’ll see the results for all seven values:

    1
    2
    3
    4
    5
    6
    7
    8.433111377393183e+35
    7.3795778785962275e+28
    2.9925614505443553e+21
    1.0139077133430874e-8
    2.308231080230816e-12
    7.366162972792583e+31
    2.522593777484324e-18
    1
    2
    3
    4
    5
    6
    7
    Uint8List intBytes = Uint8List.fromList([63, 158, 184, 82]);
    ByteData byteData = intBytes.buffer.asByteData();
    List<double> floatList = [
    for (var offset = 0; offset < intBytes.length; offset += 4)
    byteData.getFloat32(offset, Endian.big),
    ];
    print(floatList);
作者

GWJ

发布于

2023-04-26

更新于

2023-04-28

许可协议

评论