草庐IT

flutter-container

全部标签

flutter - 如何使用路径剪辑 GestureDetector(或 InkWell)输入区域?

我已经使用CustomPaint创建了一个自定义绘制的小部件,它以路径作为轮廓。但是将小部件包裹在GestureDetector中会使点击区域成为围绕整个Canvas的矩形,有没有办法剪辑GestureDetector以便点击仅在路径内有效? 最佳答案 您可以从CustomPainter实现hitTest方法,在其中添加您的Path并使用条件path.contains(position)确保触摸只覆盖路径部分。classMyCustomPainterextendsCustomPainter{@overridevoidpaint(Ca

flutter - 如何将数据从 ListView 传递到下一个屏幕,如 flutter 中的图像

我需要将字符串和图像从ListView传递到下一个屏幕,并且该字符串和图像在ListView中我应该如何通过它们。我在categories.dart中有项目import'package:flutter/material.dart';##标题##Listcategories=[{"name":"Indian","color1":Color.fromARGB(100,0,0,0),"color2":Color.fromARGB(100,0,0,0),"img":"assets/indian.jpg"},{"name":"Italian","color1":Color.fromARGB(10

flutter - 如何将数据从 ListView 传递到下一个屏幕,如 flutter 中的图像

我需要将字符串和图像从ListView传递到下一个屏幕,并且该字符串和图像在ListView中我应该如何通过它们。我在categories.dart中有项目import'package:flutter/material.dart';##标题##Listcategories=[{"name":"Indian","color1":Color.fromARGB(100,0,0,0),"color2":Color.fromARGB(100,0,0,0),"img":"assets/indian.jpg"},{"name":"Italian","color1":Color.fromARGB(10

Flutter for 循环生成小部件列表

我有这样的代码,但我希望它迭代一个整数数组以显示动态数量的子项:returnContainer(child:Column(children:[Center(child:Text(text[0].toString(),textAlign:TextAlign.center),),Center(child:Text(text[1].toString(),textAlign:TextAlign.center),),],),)text变量在这里是一个转换为字符串的整数列表。我尝试添加一个函数来遍历数组并显示“子项”,但出现类型错误。不知道该怎么做,因为我是Dart和Flutter的新手。

Flutter for 循环生成小部件列表

我有这样的代码,但我希望它迭代一个整数数组以显示动态数量的子项:returnContainer(child:Column(children:[Center(child:Text(text[0].toString(),textAlign:TextAlign.center),),Center(child:Text(text[1].toString(),textAlign:TextAlign.center),),],),)text变量在这里是一个转换为字符串的整数列表。我尝试添加一个函数来遍历数组并显示“子项”,但出现类型错误。不知道该怎么做,因为我是Dart和Flutter的新手。

flutter - 从外部函数更新小部件

我有一个异步函数,它在收到蓝牙信号时更新一个全局bool变量。每当我更改bool变量时,我都想更新一个小部件,但我不知道如何操作。boolpayingAttention=false;startListening()async{//codethatcheckscontinouslyif(thing){payingAttention=false;}if(otherThing){payingAttention=true;}}//...classPageTwoextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){ret

flutter - 从外部函数更新小部件

我有一个异步函数,它在收到蓝牙信号时更新一个全局bool变量。每当我更改bool变量时,我都想更新一个小部件,但我不知道如何操作。boolpayingAttention=false;startListening()async{//codethatcheckscontinouslyif(thing){payingAttention=false;}if(otherThing){payingAttention=true;}}//...classPageTwoextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){ret

flutter - 是否可以在一个应用程序中制作多个 flutter 页面?

我去把书转换成android应用程序这本书有100页,我应该为每个页面创建页面(事件)吗?或任何其他方式来做到这一点? 最佳答案 您可以为此使用PageView或其builder构造函数,这是基本示例PageView.builder(itemCount:100,itemBuilder:(_,index)=>YourPage(list[index]),)更新:像这样创建两个小部件。//ItonlyshowsTextclassTextPageextendsStatelessWidget{finalStringtext;constText

flutter - 是否可以在一个应用程序中制作多个 flutter 页面?

我去把书转换成android应用程序这本书有100页,我应该为每个页面创建页面(事件)吗?或任何其他方式来做到这一点? 最佳答案 您可以为此使用PageView或其builder构造函数,这是基本示例PageView.builder(itemCount:100,itemBuilder:(_,index)=>YourPage(list[index]),)更新:像这样创建两个小部件。//ItonlyshowsTextclassTextPageextendsStatelessWidget{finalStringtext;constText

flutter - 如何在 Flutter 中将容器 block 对齐到屏幕的末尾?

在我的Flutter项目中,我已经初始化了一个容器。在那个容器中,我有一个子“列”,在里面我初始化了3个图标作为我的小部件。所以,我想将整个容器block(下图中的白色block)垂直对齐到屏幕的末端。据我从文档中了解到,它可以通过以下命令完成-mainAxisAlignment:MainAxisAlignment.end但它在这里不起作用并显示以下输出-这是我的代码-import'package:flutter/material.dart';voidmain(){runApp(MyApp());}classMyAppextendsStatelessWidget{@overrideWi