flutter-layout 相关问题

如何在flutter gridview中添加原生广告?

有人可以帮我在 staggedgridview 之间添加原生广告。广告必须显示在 12 个图像网格之间......任何人都可以帮助我...... 我的代码: 容器(

回答 1 投票 0

需要在flutter中实现Native splash screen 2秒

我用过 flutter 插件 flutter_native_splash: ^2.2.2 我需要使用自定义图像准确实现启动画面 2 秒。我尝试了插件描述中的所有示例,但效果并不完美......

回答 5 投票 0

我想要一个 cupertino 风格的 Listtile/Card 或者我可以在我的 flutter 应用程序中使用的东西

我正在写一个 flutter 应用程序并做一个日历视图应用程序。在首页上应显示所有日历项目。包括日期、标题、地点和时间。问题是我找不到好的 listtile...

回答 1 投票 0

如何去除 ListTile 颤振顶部和底部的空间?

如何去掉ListTile顶部和底部的空格? 我的代码是: 孩子:专栏( 孩子们:[ 列表块( contentPadding: EdgeInsets.only(左: 0.0, 右: 0.0),

回答 12 投票 0

管理showMenu在flutter中的位置

我有一个 GestureDetector,在 onPressed 有一个 showMenu,但我无法使菜单靠近我创建的按钮。 这是我的代码: 请注意,我已经将 RelativeRect.fill 用于...

回答 2 投票 0

如何在键盘下隐藏 FloatingActionButton 而不是 flutter 中的 textformfield?

所以我试图使用 resizeToAvoidBottomInsert: false 隐藏 FloatingActionButton,但它也隐藏了 textformfield。有什么办法可以单独隐藏 FloatingActionButton 而不是 textformfield ...

回答 2 投票 0

错误:(参数类型“String?”不能分配给参数类型“String”,因为“String?”是可以为空的,而“String”不是。)在 Flutter 中

我是 flutter 的新手,在传递 String 时遇到错误并到处查看,最后将其添加到 StackOverflow 错误是 错误:参数类型“字符串?”不能分配给

回答 6 投票 0

如何使按钮宽度匹配父级?

我想知道如何设置宽度以匹配父布局宽度 新容器( 宽度:200.0, 填充:const EdgeInsets.only(顶部:16.0), 孩子:新的RaisedButton( 孩子:新文本( ...

回答 25 投票 0

在 Flutter 中请求通知权限

我想使用这个包 https://pub.dev/packages/notification_permissions 做一个权限检查,我看到了里面的例子,但是我不能使用它并正确地把它放在我的项目中。 我需要的一切...

回答 2 投票 0

如何在 Flutter 中更改 PopupMenuItem 的背景颜色

flutter如何改变PopupMenuItem的背景色? 现在我只是改变了 PopupMenuItem 子项的颜色,结果是这样的: 这是代码: 弹出菜单按钮 如何在flutter中改变PopupMenuItem的背景颜色? 现在我只是改变了 PopupMenuItem 的孩子的颜色,结果是这样的: 代码如下: PopupMenuButton<int>( onSelected: (value) { // TODO: Implement onSelect }, offset: Offset(50, 50), itemBuilder: (context) => [ PopupMenuItem( value: 1, child: Container( height: double.infinity, width: double.infinity, color: Colors.greenAccent, // i use this to change the bgColor color right now child: Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Icon(Icons.check), SizedBox(width: 10.0), Text("Konfirmasi Update"), SizedBox(width: 10.0), ], ), ), ), 我想要的是更改“Konfirmasi Update”选项的背景颜色,正如您在上图中看到的那样,颜色在选项外留下了白色区域。 如何完全改变 PopupMenuItem 的背景颜色,而不留下 PopupMenuItem 外部的白色区域? 另一种选择是继承自 PopupMenuItem。 仅使用更改 CustomPopupMenuItem 的 PopupMenuButton 并设置颜色。 import 'package:flutter/material.dart'; class CustomPopupMenuItem<T> extends PopupMenuItem<T> { final Color color; const CustomPopupMenuItem({ Key key, T value, bool enabled = true, Widget child, this.color, }) : super(key: key, value: value, enabled: enabled, child: child); @override _CustomPopupMenuItemState<T> createState() => _CustomPopupMenuItemState<T>(); } class _CustomPopupMenuItemState<T> extends PopupMenuItemState<T, CustomPopupMenuItem<T>> { @override Widget build(BuildContext context) { return Container( child: super.build(context), color: widget.color, ); } } 没有办法使用开箱即用的PopupMenuButton和PopupMenuItem小部件,因为如果你检查源代码,垂直和水平填充有硬编码值。 我修改了popup_menu.dart文件的代码,具体是这些值: const double _kMenuVerticalPadding = 0.0;//8.0; const double _kMenuHorizontalPadding = 0.0;//16.0; 如果你想让它工作,下载这个文件到你的项目:https://gist.github.com/diegoveloper/995f1e03ef225edc64e06525dc024b01 在您的项目中导入该文件并添加别名: import 'your_project/my_popup_menu.dart' as mypopup; 用法: @override Widget build(BuildContext context) { return Scaffold( body: Center( child: mypopup.PopupMenuButton<int>( elevation: 20, onSelected: (value) { // TODO: Implement onSelect }, offset: Offset(50, 50), itemBuilder: (context) => [ mypopup.PopupMenuItem( value: 1, child: Container( height: double.infinity, width: double.infinity, color: Colors .greenAccent, // i use this to change the bgColor color right now child: Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Icon(Icons.check), SizedBox(width: 10.0), Text("Konfirmasi Update"), SizedBox(width: 10.0), ], ), ), ), mypopup.PopupMenuItem( value: 1, child: Container( height: double.infinity, width: double.infinity, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Icon(Icons.check), SizedBox(width: 10.0), Text("Revisi Update"), SizedBox(width: 10.0), ], ), ), ), ], ), ), ); } 结果 您可以将 PopupMenuButton 放在主题中,在您的主题中,您必须为您想要的背景颜色更新 cardColor,如下所示: Center( child: Theme( data: Theme.of(context).copyWith( cardColor: Colors.greenAccent, ), child: PopupMenuButton<int>( onSelected: (value) { }, offset: Offset(50, 50), itemBuilder: (context) => [ PopupMenuItem( value: 1, child: Container( height: double.infinity, width: double.infinity, color: Colors.greenAccent, // i use this to change the bgColor color right now child: Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Icon(Icons.check), SizedBox(width: 10.0), Text("Konfirmasi Update"), SizedBox(width: 10.0), ], ), ), ) ] ) ) ) 对于 Flutter 3.7 我修改了@erli proposition 到这样的版本: class CustomPopupMenuItem<T> extends PopupMenuItem<T> { const CustomPopupMenuItem({ super.key, super.value, super.onTap, super.height, super.enabled, super.child, this.color, }); final Color? color; @override CustomPopupMenuItemState<T> createState() => CustomPopupMenuItemState<T>(); } class CustomPopupMenuItemState<T> extends PopupMenuItemState<T, CustomPopupMenuItem<T>> { @override Widget build(BuildContext context) { return Material( color: widget.color, child: super.build(context), ); } } 更改整个菜单或仅更改其子项的颜色非常容易。 使用正则颜色表达式。 颜色:Colors.red 或任何你喜欢的颜色。 您可以在PopupMenuButton()或PopupMenuItem()中使用它。

回答 5 投票 0

允许溢出容器超过屏幕

我在 Stack 小部件中有 AnimatedContainer。我想更改 MyAnimatedContainer 的比例并使其大于屏幕,如下图所示: 我怎样才能做到这一点 ? 代码: @覆盖 小工具

回答 2 投票 0

Flutter中Radio button如何只选择一组值?

我正在使用 Flutter-Dart-SQLite 开发一个测验应用程序。在这里,我使用 RadioListTile 来实现单选按钮功能。我将文本值从一个数组传递给这个 StatefulWidget。 这是……

回答 3 投票 0

如何在 Flutter 中自动滚动到 SingleChildScrollView 中的一行位置

我正在使用 SingleChildScrollView。它的 scrollDirection 设置为 Horizontal,在一个 Row Widget 中放置了 20 个以上的子 widget。我想以编程方式滚动到位置小部件(即第 5 或...

回答 4 投票 0

在flutter中无法在单个滚动视图中添加不同的widget

所以,我有一个高度为屏幕高度的容器,singlechildscrollview 作为它的孩子。 代码:- 堆( 孩子们: [ 容器( 对齐方式:Alignment.center, ...

回答 2 投票 0

是否可以在不渲染的情况下获取子部件的大小?

我正在尝试创建一个需要大小参数的可调整大小的小部件。我想根据它的子尺寸使高度和宽度字段动态,这样我们就不必给出静态尺寸......

回答 2 投票 0

在 flutter 中更改分页数据表的颜色?

我希望使用 flutter 更改分页数据表的颜色, 我使用深色主题和分页数据表采用该颜色,我还从 flutter 网站上阅读,在此处输入链接描述 使用

回答 2 投票 0

如何在 flutter tablecalendar 中隐藏过去和下个月的日期

我使用了 flutter TableCalendar 插件,我想隐藏过去和下个月的日期选项。我的代码是。 孩子:表日历( headerVisible: false,

回答 2 投票 0

TFLITE 插件不适用于 flutter 中的情绪检测应用程序

我正在尝试使用 tflite 插件将模型用于情绪检测应用程序。但是显示错误。任何帮助将不胜感激。 失败:构建失败,出现异常。 * 在哪里: 构建...

回答 1 投票 0

如何在 flutter 中设置 showModalBottomSheet 宽度

我有设计(如图所示)并且我正在使用 showModalBottomSheet 但是当我设置宽度时,它不会改变并保持屏幕宽度,所以我有几个问题: 1-如何设置宽度为

回答 3 投票 0

flutter 错误:此小部件已被卸载,因此状态不再具有上下文(应被视为已失效)

当我的手机号码错误时单击登录按钮然后打开一个错误对话框然后当我在对话框上单击确定时我收到此错误。 我收到这条消息 这个小部件有...

回答 5 投票 0

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