草庐IT

Flutter-FlutterBloc

全部标签

flutter - 当键盘弹出或关闭时,streambuilder 一次又一次地重建

这里我遇到了一个问题。我有一列带有流生成器和文本字段的小部件。当我尝试输入一些文本时,键盘弹出,然后流生成器再次重建,或者当键盘关闭时,流生成器再次重建。当我构建聊天屏幕时,我不想再次重建流构建器,因为它会增加读取次数。任何有帮助的建议。 最佳答案 Fluttercallsthebuild()methodeverytimeitwantstochangeanythingintheview,andthishappenssurprisinglyoften.您可以将流传递给无状态小部件MyApp({Keykey,this.stream}):

flutter - 当键盘弹出或关闭时,streambuilder 一次又一次地重建

这里我遇到了一个问题。我有一列带有流生成器和文本字段的小部件。当我尝试输入一些文本时,键盘弹出,然后流生成器再次重建,或者当键盘关闭时,流生成器再次重建。当我构建聊天屏幕时,我不想再次重建流构建器,因为它会增加读取次数。任何有帮助的建议。 最佳答案 Fluttercallsthebuild()methodeverytimeitwantstochangeanythingintheview,andthishappenssurprisinglyoften.您可以将流传递给无状态小部件MyApp({Keykey,this.stream}):

Flutter - 将起始高度设置为 MediaQuery 高度时,AnimatedSize 不设置动画

我不知道怎么回事...当我使用0.0的静态高度时,AnimatedSize小部件将进行动画处理。但是当我设置topLayoutHeight=MediaQuery.of(context).size.height没有任何反应。这是我的代码:doubletopLayoutHeight=0.0;setHeight(){topLayoutHeight=MediaQuery.of(context).size.height-200;}我的小部件:@overrideWidgetbuild(BuildContextcontext){setHeight();......newAnimatedSize(cu

Flutter - 将起始高度设置为 MediaQuery 高度时,AnimatedSize 不设置动画

我不知道怎么回事...当我使用0.0的静态高度时,AnimatedSize小部件将进行动画处理。但是当我设置topLayoutHeight=MediaQuery.of(context).size.height没有任何反应。这是我的代码:doubletopLayoutHeight=0.0;setHeight(){topLayoutHeight=MediaQuery.of(context).size.height-200;}我的小部件:@overrideWidgetbuild(BuildContextcontext){setHeight();......newAnimatedSize(cu

dart - 卡片宽度与父级匹配 : flutter

我是Flutter的新手,所以我想知道如何设置宽度以匹配父布局宽度newScaffold(body:newContainer(decoration:newBoxDecoration(color:AppColors.hoBlue),child:Padding(padding:EdgeInsets.all(20.0),child:newCenter(child:Column(mainAxisAlignment:MainAxisAlignment.center,children:[Stack(children:[Row(children:[Expanded(child:Padding(pad

dart - 卡片宽度与父级匹配 : flutter

我是Flutter的新手,所以我想知道如何设置宽度以匹配父布局宽度newScaffold(body:newContainer(decoration:newBoxDecoration(color:AppColors.hoBlue),child:Padding(padding:EdgeInsets.all(20.0),child:newCenter(child:Column(mainAxisAlignment:MainAxisAlignment.center,children:[Stack(children:[Row(children:[Expanded(child:Padding(pad

mobile - Flutter 无法更改路由,因为 undefined name context with PopupMenuButton 如何解决?

我想单击一个项目菜单(PopupMenuItem)并使用Navigator.push转到另一条路线,但方法内未定义上下文。import'package:flutter/material.dart';voidmain()=>runApp(newMyApp());classMyAppextendsStatelessWidget{finalListchoices=const[constChoice(title:'Settings',icon:Icons.settings),constChoice(title:'Logout',icon:Icons.exit_to_app),];@overri

mobile - Flutter 无法更改路由,因为 undefined name context with PopupMenuButton 如何解决?

我想单击一个项目菜单(PopupMenuItem)并使用Navigator.push转到另一条路线,但方法内未定义上下文。import'package:flutter/material.dart';voidmain()=>runApp(newMyApp());classMyAppextendsStatelessWidget{finalListchoices=const[constChoice(title:'Settings',icon:Icons.settings),constChoice(title:'Logout',icon:Icons.exit_to_app),];@overri

scroll - FLUTTER 滚动多个小部件

如果我有两个(或更多)可滚动小部件(例如,SingleChildScrollView),如何让它们同时滚动?因为我会将它们堆叠在彼此之上,所以一个被另一个的Container覆盖。我是新手,所以我现在没有太多选择。我尝试了ScrollController但它不起作用。我不知道如何在我的代码中正确实现它。另外,如果可能的话,请附上一个简单的代码示例。这是我尝试过的:class_MyHomePageStateextendsState{finalScrollController_mycontroller=newScrollController();@overrideWidgetbuild(B

scroll - FLUTTER 滚动多个小部件

如果我有两个(或更多)可滚动小部件(例如,SingleChildScrollView),如何让它们同时滚动?因为我会将它们堆叠在彼此之上,所以一个被另一个的Container覆盖。我是新手,所以我现在没有太多选择。我尝试了ScrollController但它不起作用。我不知道如何在我的代码中正确实现它。另外,如果可能的话,请附上一个简单的代码示例。这是我尝试过的:class_MyHomePageStateextendsState{finalScrollController_mycontroller=newScrollController();@overrideWidgetbuild(B