03 2025 档案

摘要:一,安装第三方库 库地址: https://pub.dev/packages/fluttertoast 编辑pubspec.yaml dependencies: flutter: sdk: flutter path_provider: ^2.1.5 audioplayers: ^6.4.0 flut 阅读全文
posted @ 2025-03-29 09:05 刘宏缔的架构森林 阅读(355) 评论(0) 推荐(0)
摘要:一,代码: 1,通用方法 import 'package:flutter/material.dart'; class DialogHelper { // 显示通用弹窗 static Future<void> showCustomDialog({ required BuildContext conte 阅读全文
posted @ 2025-03-29 09:04 刘宏缔的架构森林 阅读(122) 评论(0) 推荐(0)
摘要:一,代码: dart代码:model class GoodsListItem { String name; String desc; int id; GoodsListItem(this.name,this.desc, this.id) {} GoodsListItem.fromJson(Map<S 阅读全文
posted @ 2025-03-29 09:04 刘宏缔的架构森林 阅读(53) 评论(0) 推荐(0)
摘要:一,代码: import 'package:flutter/material.dart'; import 'dart:convert'; //定义解析后的类 class User { final String name; final int age; User({required this.name 阅读全文
posted @ 2025-03-29 09:04 刘宏缔的架构森林 阅读(12) 评论(0) 推荐(0)
摘要:一,安装第三方库 地址: https://pub.dev/packages/http 编辑pubspec.yaml: dependencies: flutter: sdk: flutter path_provider: ^2.1.5 http: ^1.3.0 然后点击 pub get 二,代码: i 阅读全文
posted @ 2025-03-29 09:03 刘宏缔的架构森林 阅读(71) 评论(0) 推荐(0)
摘要:一,安装 包地址: https://pub.dev/packages/file_picker 编辑pubspec.yaml dependencies: flutter: sdk: flutter file_picker: ^9.2.1 然后点击 pub get 各功能的兼容性如下: 二,代码 imp 阅读全文
posted @ 2025-03-29 09:03 刘宏缔的架构森林 阅读(280) 评论(0) 推荐(0)
摘要:一,安装第三方库: 地址: https://pub.dev/packages/dio 编辑pubspec.yaml dependencies: flutter: sdk: flutter path_provider: ^2.1.5 audioplayers: ^6.4.0 flutter_sound 阅读全文
posted @ 2025-03-29 09:02 刘宏缔的架构森林 阅读(215) 评论(0) 推荐(0)
摘要:一,下载 库地址 https://pub.dev/packages/permission_handler 下载:编辑pubspec.yaml,增加一行: dependencies: flutter: sdk: flutter permission_handler: ^11.4.0 然后点 pub g 阅读全文
posted @ 2025-03-29 09:02 刘宏缔的架构森林 阅读(260) 评论(0) 推荐(0)
摘要:一,报错信息 Your project is configured with Android NDK 26.3.11579264, but the following plugin(s) depend on a different Android NDK version: - audioplayer 阅读全文
posted @ 2025-03-29 09:01 刘宏缔的架构森林 阅读(1075) 评论(0) 推荐(0)
摘要:一,下载第三方库: 地址: https://pub.dev/packages/path_provider 编辑pubspec.yaml,添加path_provider dependencies: flutter: sdk: flutter path_provider: ^2.1.5 点击pub ge 阅读全文
posted @ 2025-03-29 09:00 刘宏缔的架构森林 阅读(187) 评论(0) 推荐(0)
摘要:一,安装第三方库 第三方库地址 https://pub.dev/packages/audioplayers 修改pubspec.yaml dependencies: flutter: sdk: flutter audioplayers: ^6.4.0 然后点击 pub get 二,代码: impor 阅读全文
posted @ 2025-03-22 10:32 刘宏缔的架构森林 阅读(277) 评论(0) 推荐(0)
摘要:一,代码: import 'package:flutter/material.dart'; class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override State<MyHomePage> cre 阅读全文
posted @ 2025-03-22 10:32 刘宏缔的架构森林 阅读(18) 评论(0) 推荐(0)
摘要:一,报错信息 Running Gradle task 'assembleDebug'... Exception in thread "main" java.net.ConnectException: Operation timed out at java.base/sun.nio.ch.Net.co 阅读全文
posted @ 2025-03-22 10:32 刘宏缔的架构森林 阅读(874) 评论(0) 推荐(0)
摘要:一,安装 官方库地址: https://pub.dev/packages/webview_flutter 编辑pubspec.yaml,在dependencies下增加一行:webview_flutter,如下: dependencies: flutter: sdk: flutter webview 阅读全文
posted @ 2025-03-22 10:31 刘宏缔的架构森林 阅读(101) 评论(0) 推荐(0)
摘要:一,代码: tabbar: import 'package:flutter/material.dart'; import '../tabpages/MyHomePage.dart'; import '../tabpages/ProfilePage.dart'; class MyTabBar exte 阅读全文
posted @ 2025-03-22 10:31 刘宏缔的架构森林 阅读(109) 评论(0) 推荐(0)
摘要:一,代码: tabbar页面: import 'package:flutter/material.dart'; import '../tabpages/MyHomePage.dart'; import '../tabpages/ProfilePage.dart'; class MyTabBar ex 阅读全文
posted @ 2025-03-22 10:31 刘宏缔的架构森林 阅读(55) 评论(0) 推荐(0)
摘要:一,代码: import 'package:flutter/material.dart'; class HomePage extends StatefulWidget { @override State<HomePage> createState() => _HomePageState(); } c 阅读全文
posted @ 2025-03-22 10:31 刘宏缔的架构森林 阅读(63) 评论(0) 推荐(0)
摘要:一,代码: main.dart import 'package:flutter/material.dart'; import 'pages/HomePage.dart'; import 'pages/DetailPage.dart'; void main() { //const runApp(MyA 阅读全文
posted @ 2025-03-22 10:31 刘宏缔的架构森林 阅读(12) 评论(0) 推荐(0)
摘要:一,下载: 官网: https://flutter.dev/ 下载页面: https://docs.flutter.dev/get-started/install/macos/mobile-android 如图: 选择对应自己电脑cpu的版本下载 二,下载完成后安装 1,解压后移动到相应的目录下 2 阅读全文
posted @ 2025-03-22 10:31 刘宏缔的架构森林 阅读(155) 评论(0) 推荐(0)
摘要:一,执行顺序: 先进后出,类似于栈的特性 1,代码: func deferAndPanic() { defer func() { fmt.Println("defer1") }() defer func() { fmt.Println("defer2") }() defer func() { fmt 阅读全文
posted @ 2025-03-15 15:15 刘宏缔的架构森林 阅读(6) 评论(0) 推荐(0)
摘要:一,如果直接用header("Location")会无效 代码: header('Location: https://baidu.com'); return false; 无效: 页面不会跳转 二,解决方法: 代码:在controller中 return redirect('https://baid 阅读全文
posted @ 2025-03-15 15:14 刘宏缔的架构森林 阅读(42) 评论(0) 推荐(0)
摘要:一,代码: // 入口函数 func main() { lock:=sync.Mutex{} go func() { lock.Lock() defer lock.Unlock() for i:=1; i<=5; i++ { time.Sleep(time.Millisecond) fmt.Prin 阅读全文
posted @ 2025-03-09 15:10 刘宏缔的架构森林 阅读(16) 评论(0) 推荐(0)
摘要:一,代码: //实现单例的数据结构 type SingleObject struct { } //最终获得的单例对象 var instance *SingleObject //变量one是一个sync.Once的实例 var one sync.Once //方法:得到单例对象 func getIns 阅读全文
posted @ 2025-03-09 13:46 刘宏缔的架构森林 阅读(18) 评论(0) 推荐(0)
摘要:一,代码: // 入口函数 func main() { //无缓冲的channel ch:=make(chan int) go func() { //<-ch for i:=1; i<=5; i++ { time.Sleep(time.Millisecond) fmt.Println(i) } ch 阅读全文
posted @ 2025-03-09 13:21 刘宏缔的架构森林 阅读(16) 评论(0) 推荐(0)
摘要:一,代码: // 入口函数 func main() { ch:=make(chan int,1) go func() { <-ch for i:=1; i<=5; i++ { time.Sleep(time.Millisecond) fmt.Println(i) } }() go func() { 阅读全文
posted @ 2025-03-09 13:06 刘宏缔的架构森林 阅读(41) 评论(0) 推荐(0)
摘要:一,怎么用channel实现锁定? 只有1个缓冲区的channel, 写入数据类似于加锁, 读出数据类似于释放锁 二,代码例子: // 入口函数 func main() { //创建channel对象 ch:=make(chan int,1) //协程1 go func() { ch <- 0 fo 阅读全文
posted @ 2025-03-09 12:54 刘宏缔的架构森林 阅读(23) 评论(0) 推荐(0)
摘要:一,空select语句:会报死锁 代码: // 入口函数 func main() { select{} } 运行结果: $ go run main.go fatal error: all goroutines are asleep - deadlock! goroutine 1 [select (n 阅读全文
posted @ 2025-03-01 20:55 刘宏缔的架构森林 阅读(45) 评论(0) 推荐(0)
摘要:一,并发时不使用channel,直接访问变量(共享内存) 代码: // 入口函数 func main() { //共享访问的切片 var ints []int var wg sync.WaitGroup //定义协程的数量 n:=10000 //定义wg的数量 wg.Add(n) //创建指定数量的 阅读全文
posted @ 2025-03-01 20:54 刘宏缔的架构森林 阅读(11) 评论(0) 推荐(0)