草庐IT

share-button

全部标签

button - 连续的自定义 Flutter 按钮

我想用Flutter制作一个看起来像上图的Button。但我不知道该怎么做...请帮助我! 最佳答案 Widget_startButton(BuildContextcontext){returnContainer(margin:constEdgeInsets.only(top:250.0),child:Stack(children:[Center(child:Row(mainAxisAlignment:MainAxisAlignment.spaceEvenly,children:[_buildSideButtons(context,

sharedpreferences - Flutter Shared Preferences 保存值,不显示

我有一个类(class)列表。用户使用ListTile上的复选框将每门类(class)标记为已完成。我实现了共享首选项,因此当用户关闭应用程序时,已完成类(class)的列表仍然存在。这些值正在保存,但是当应用程序关闭(在模拟器中或通过IDE)并重新打开时,UI将值显示为false(即使终端显示该值为True)。当我热重启时,UI将值显示为True(从一开始就是预期的)。我无法使用模拟器按钮或在设备上正确显示UI。如何让UI立即正确显示值?SharedPreferencesprefs;voidgetResult(Coursecourse)async{prefs=awaitSharedP

android - 如何在android端访问flutter Shared preferences(使用java)

我在dart中有以下函数来设置特定的bool首选项值。_switchPersistentNotifications(){setState((){isPersistentNotificationEnabled=!isPersistentNotificationEnabled;});widget.preferences.setBool("isPersistentNotificationEnabled",isPersistentNotificationEnabled);}此函数设置isPersistentNotificationEnabled首选项的值。现在在nativeandroid端,我

flutter 自动测试: Tap on a button don't work in drawer

我正在尝试使用flutter进行一些TDD,当测试运行时,如果按钮在抽屉中,则点击它不起作用。该按钮对普通用户来说工作得很好。在下面的示例中,我们按下两个按钮,它们会在控制台中打印一条消息。以下是操作:找到并点击脚手架中的按钮:OK打开抽屉:OK在抽屉中找到按钮:确定点击抽屉按钮:没有任何反应import'package:flutter/material.dart';import'package:flutter_test/flutter_test.dart';voidmain(){testWidgets('Testthatdrawerisapparingandwecanclickonb

flutter :How to print shared preferences all content

我要打印所有sharedpreferences内容(key,value)键和值由用户提供我尝试使用getKeys()方法将所有键放入一个集合中,然后循环该集合并检索我的元素,如下所示:_favoritePlaces()async{SharedPreferencesprefs=awaitSharedPreferences.getInstance();//prefKeysdeclaredasstaticSetprefKeys=prefs.getKeys();if(prefKeys.isNotEmpty){for(inti=0;i预期输出:键0=>值0 最佳答案

dart - flutter : Refresh same screen with different data and back button

几天前,我最近开始探索Flutter。我创建了一个包含一些行的列表。有些行有子数据。现在屏幕顶部有自定义按钮。finaltopAppBar=AppBar(elevation:0.1,backgroundColor:Color.fromRGBO(0,113,188,1.0),title:Text("RESOURCES",style:TextStyle(color:Colors.white,fontFamily:'Raleway-ExtraBold',fontWeight:FontWeight.w900,fontSize:20.0,),),leading:IconButton(icon:n

dart - Flutter根据Shared Preference设置启动页

我一直在尝试根据我的共享首选项设置加载不同的页面,但没有成功。根据在stackoverflow中找到的几篇文章,我最终得到以下解决方案:import'dart:async';import'package:flutter/material.dart';import'package:testing/screens/login.dart';import'package:testing/screens/home.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatefulWidget{@override_MyAppStatecreate

button - 如何识别在flutter中点击了哪个按钮

每次单击按钮时,我有4个按钮显示不同的列表。如何使用flutter识别点击了哪个按钮? 最佳答案 您可以分配一个回调,为每个按钮调用不同的方法newFlatButton(child:newText(confirmText),onPressed:()=>onOkPressed(),),或者你可以传递一个参数newFlatButton(child:newText(confirmText),onPressed:()=>onButtonPressed('okButton'),), 关于butto

button - Flutter 更改 AppBar 内 OutlineButton 的高度?

只是想知道如何更改OutlineButton的高度?我想这也可能适用于其他按钮类型。returnScaffold(appBar:AppBar(title:Text('Test'),actions:[SizedBox(width:100.0,height:8.0,child:OutlineButton(borderSide:BorderSide(width:4.0)child:Text('Hi'),onPressed:(){},),),],),body:Container(),);我发现这个按钮对于我的情况来说太高了大约8像素,我想把它压扁一点。 最佳答案

flutter - Flutter 中可以有不同的 Button 样式吗?

我有几个OutlineButton,我希望能够有多种样式(深色、浅色、小型等)。我可以创建一个ButtonTheme,但是我如何为按钮指定Theme或Style,因为它们不接受任何一个参数?即:我希望以下两个按钮具有不同的背景颜色:children:{OutlineButton(color:Colors.black,child:Text("Hello")),OutlineButton(child:Text("GoodBye"))}(颜色字段被忽略,因为它使用应用程序主题按钮的背景)编辑:示例代码:Widgetbutton(BuildContextcontext,Stringicon,S