Flutter学习笔记
问题
**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`
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` 验证,安卓真机和仿真器同时只能有一个启动
-
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
2environment:
sdk: '>=2.11.0 <3.0.0' -
chrome://inspect
-
比特流转换
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
9final 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 thedart:typed_data
library gives you different views on byte data. What you want is the Float32 view, which will give you adouble
in Dart.1
2
3
4final bytes = Uint8List.fromList(data);
final byteData = ByteData.sublistView(bytes);
double value = byteData.getFloat32(0);
print(value); // 8.433111377393183e+35The
0
ingetFloat32(0)
means that you want to get the 32-bit float value starting at index0
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
3for (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
78.433111377393183e+35
7.3795778785962275e+28
2.9925614505443553e+21
1.0139077133430874e-8
2.308231080230816e-12
7.366162972792583e+31
2.522593777484324e-181
2
3
4
5
6
7Uint8List 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);
Flutter学习笔记