flutter 相关问题

Flutter是一款开源的移动应用SDK,可帮助开发人员和设计人员构建适用于iOS和Android的现代移动应用。

如何在 DART 中获取两个字符串之间的子字符串?

我如何实现类似的解决方案:如何在 PHP 中获取两个字符串之间的子字符串?但在 DART 中 例如我有一个字符串: 字符串数据=“敏捷的棕色狐狸跳过了懒狗” 我有...

回答 7 投票 0

自定义 Flutter 导航栏

我怎样才能制作这样的自定义导航栏? 在此输入图像描述 我已经尝试过这个 在主页上 类 CustomNavigationBar 扩展 StatelessWidget { 最终名单 我怎样才能制作这样的自定义导航栏? 在此输入图片描述 我已经尝试过这个 在主页上 class CustomNavigationBar extends StatelessWidget { final List<NavigationDestination> destinations; final int selectedIndex; final Function(int index) onDestinationSelected; const CustomNavigationBar({ Key? key, required this.destinations, required this.selectedIndex, required this.onDestinationSelected, }) : super(key: key); @override Widget build(BuildContext context) { return Container( color: Colors.green, // You can customize the background color height: 60, // Adjust the height as needed child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: List.generate( destinations.length, (index) => GestureDetector( onTap: () => onDestinationSelected(index), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( destinations[index].icon, color: index == selectedIndex ? Colors.white : Colors.black, ), if (destinations[index].label != null) Text( destinations[index].label!, style: TextStyle( color: index == selectedIndex ? Colors.white : Colors.black, ), ), ], ), ), ), ), ); } } 在主页上 final List<NavigationDestination> destinations = [ NavigationDestination(icon: Icons.home, label: 'Home'), NavigationDestination(icon: Icons.search, label: 'Search'), NavigationDestination(icon: Icons.shopping_cart, label: 'Cart'), ]; 我已经尝试过这个 蛇形导航栏 至少我需要任何帮助来了解我该如何做这个蛇形导航栏 我已经尝试了很多,我读过它,但我绝对做不到 尝试下面的代码: import 'package:flutter/material.dart'; class CustomNavigationBar extends StatelessWidget { final List<NavigationDestination> destinations; final int selectedIndex; final Function(int index) onDestinationSelected; const CustomNavigationBar({ super.key, required this.destinations, required this.selectedIndex, required this.onDestinationSelected, }); @override Widget build(BuildContext context) { return Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.symmetric(horizontal: 16.0), decoration: BoxDecoration( color: const Color(0xFF017620), borderRadius: BorderRadius.circular(30.0), ), height: 60.0, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: List.generate( destinations.length, (index) { bool isSelected = index == selectedIndex; return GestureDetector( onTap: () => onDestinationSelected(index), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( decoration: isSelected ? const BoxDecoration( color: Colors.white, shape: BoxShape.circle, ) : null, padding: EdgeInsets.all(isSelected ? 8.0 : 0.0), child: Icon( destinations[index].icon, color: isSelected ? Colors.green : Colors.white, ), ), ], ), ); }, ), ), ); } } class NavigationDestination { final IconData icon; final String? label; NavigationDestination({required this.icon, this.label}); } void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( bottomNavigationBar: CustomNavigationBar( destinations: [ NavigationDestination(icon: Icons.home, label: 'Home'), NavigationDestination(icon: Icons.note, label: 'Notes'), NavigationDestination( icon: Icons.calendar_today, label: 'Calendar'), NavigationDestination(icon: Icons.person, label: 'Profile'), ], selectedIndex: 0, onDestinationSelected: (index) { // todo: handle destination selection... }, ), body: const Center(child: Text('Content goes here')), ), ); } } 它会给你一个像附件一样的底部导航栏。

回答 1 投票 0

Flutter Listview 在使用 FutureBuilder 加载缩略图时冻结

我正在flutter中创建一个文件管理器用于学习目的。我刚刚开始学习flutter,所以对此了解不多。 我的问题是我想显示图像的缩略图...

回答 2 投票 0

Flutter:线程“主”java.net.SocketException 中出现异常:来自服务器的文件意外结束

当尝试运行我的 flutter 项目时,我收到此错误: 在调试模式下在 sdk gphone x86 上启动 lib\main.dart... 运行 Gradle 任务“assembleDebug”... 线程“main”java.net 中出现异常。

回答 1 投票 0

如何在 Flutter 中检查 Apple Pay 和 Google Pay 可用性

我需要在我的应用程序中列出所有可用的付款方式,因此如果配置了 Apple Pay,我需要在我的付款方式列表中显示它,对于 Google Pay 也是如此。 有没有办法检查是否...

回答 2 投票 0

如何确保服务器仅接受来自移动应用程序的请求

我有一个 Node.js 服务器,它将处理来自我的 flutter 移动应用程序的请求。 flutter 应用程序使用 http 模块将请求发送到服务器。 Node.js 服务器使用 CORS。怎么...

回答 1 投票 0

如何更改 Flutter web 中的 url?

我需要更改此网页的内容 对于此内容 并且还将 url 从“localhost:49318/#/home/inicio”更改为“localhost:49318/#/home/other”。 所有这一切都无需使用导航...

回答 5 投票 0

如何在 Flutter 中正确处理嵌套 WillPopScope 小部件中的后退按钮

我正在开发一个带有 NavigationPage 的 Flutter 应用程序,该应用程序使用 IndexedStack 通过 BottomNavigationBar 管理不同的屏幕。每个屏幕都包裹在一个导航器中,有自己的 Globa...

回答 1 投票 0

如何使用source_gen和build_runner以字符串形式获取函数体?

我的目标是让我的单元测试易于理解。目前,它们很难理解,因为它们有很多嵌套函数。 我想使用build_runner生成单元的代码...

回答 2 投票 0

Flutter FCM iOS 问题 - 在检索 FCM 令牌之前未设置 APNS 设备令牌

我在 Flutter 应用程序中使用 firebase_messaging v9.0.1。在基于 https://pub.dev/packages/firebase_messaging/example 配置此库时,我能够收到

回答 4 投票 0

_从 API 映射数据时出现类型错误

我正在尝试使用这个API。我正在发送 GET 请求,我得到的数据如下所示; { “信息”:{ “计数”:826, “页数”:42, “下一步&qu...

回答 1 投票 0

使用颤动相机插件设置自动白平衡(AWB)和其他低级别相机设置的选项

我正在构建一个 flutter 应用程序,它可以录制视频并将其保存到本地文件。录制视频时,我需要设置值/启用/禁用自动白平衡 (AWB)、曝光、ISO 和其他低值

回答 1 投票 0

如何修复找不到“Flutter/Flutter.h”文件

上周,当我最后一次处理这个问题时,它构建得很好。 在向其他应用程序添加新功能时停止了这方面的工作,周末休息我回来,两个应用程序都不再编译。一个是

回答 1 投票 0

Flutter、TextFormField 中的超链接

我想知道是否有人知道如何使超链接在 TextFormField 内可点击。 该场景是一个笔记应用程序,其中每个笔记的文本始终位于 TextFormFiel 内...

回答 1 投票 0

Flutter:当 _formKey.currentState.validate() 为 false 时自动滚动到复选框(或任何表单小部件)

我有一份较长的表格,表格底部有保存按钮。当用户点击“保存”按钮时,表单字段验证器会根据 validator() 函数突出显示错误文本。我的问题是当有任何呃...

回答 3 投票 0

如何在调整窗口大小时自动调整控件的大小和位置?

我正在尝试使用Python Flet 开发一个临时应用程序。我的目标是找到一种方法来定位,或者指定相对于其父控件尺寸的控件尺寸。例如...

回答 1 投票 0

在 Pluto Grid Flutter 中添加自定义下拉菜单时遇到问题

我使用相同的下拉菜单,除了冥王星网格之外,它在任何地方都可以工作,问题是我无法在定制的文本字段或下拉字段中输入内容。 冥王星柱...

回答 1 投票 0

部署后无法将图像上传到 Firebase 存储

我有 flutter web 应用程序,上传图像在调试模式下工作得很好,但在我将其部署到 firebase 上后,它无法正常工作,给了我这个错误 上传错误:PlatformException(通道-

回答 1 投票 0

在 Dart 中,是否可以在单例中传递参数?

人民阶级{ 迟到的 int id; 迟到的字符串名称; 静态最终 Peoples _inst = Peoples._internal(); Peoples._internal(); 工厂人民() { 返回_inst; } } 我有这个单身...

回答 6 投票 0

页面转换期间脚手架主体周围有黑色边框

当我在我的(网络)应用程序中导航时,我得到了这个奇怪的黑色边框。 “缩放”动画本身是可取的,但我想摆脱黑色边框。有任何想法吗? 请注意,没有

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.