在我的代码中,我调用底部工作表来显示瓷砖列表。这些磁贴包含显示快餐栏的按钮。该功能工作正常,唯一的问题是小吃栏显示在底部工作表的后面,因此只有关闭底部工作表才能看到它。它们中的每一个都使用以下代码调用:
1. 底片:
void _settingModalBottomSheet(context, stream, scaffoldKey ) {
if (_availableRides.length == 0) {
return null;
} else {
return scaffoldKey.currentState.showBottomSheet((context) {
return Column(
children: Widgets;
});
}
}
Run Code Online (Sandbox Code Playgroud)
2. 小吃店
widget.scaffoldKey.currentState.showSnackBar(SnackBar(
content: Text("Created", textAlign:
TextAlign.center,),),
Run Code Online (Sandbox Code Playgroud)
有谁知道我如何将小吃店放在底纸前面
对此答案的一些评论表明,可以捕获小部件的每个像素,即使它部分位于屏幕外。这个答案中的评论表明相反的观点。我一直无法弄清楚,我今天才开始搞乱它。这是我到目前为止的代码:
RenderRepaintBoundary boundary = globalKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage();
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
Run Code Online (Sandbox Code Playgroud)
有人知道如何修改它以便捕获完整的小部件吗?或者这仅适用于屏幕上的小部件部分?
FWIW,在将这个问题标记为重复的类似问题中提供的答案被自我描述为故意破坏颤动为优化所做的事情,并且仅在最坏的情况下。我正在寻找一个不需要做两年内就会崩溃的疯狂事情的答案。
我已经在我的颤振项目中实现了signature_pad并且它工作正常。
不幸的是,当我把它放在里面时SingleChildScrollView,签名没有画出来。它滚动而不是签名。
似乎是,GestureDetector但我不知道如何解决它。
有人可以给我一些线索吗?
谢谢。
我正在与此DropDownItem框错误作斗争,似乎一切正常,但在加载时弹出黄色越界。尝试了几件事,但无法解决。我的Widget.
@override
Widget build(BuildContext context) {
var _children = <Widget>[
!_createNew ? _referrerPractice() : _referrerCreate(),
];
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Column(
mainAxisSize: MainAxisSize.max,
children: _children,
));
}
Run Code Online (Sandbox Code Playgroud)
然后我将其用作功能之一。
Widget _referrerPractice() {
assert(!_createNew);
return new Form(
key: _formKey2,
child: new Expanded(
child: new ListView(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
children: <Widget>[
new InputDecorator(
decoration: const InputDecoration(
labelText: 'Referrer Practice',
hintText: 'Choose Referrer Practice or choose new',
),
isEmpty: _referPractice == …Run Code Online (Sandbox Code Playgroud) 我有一个自定义的无状态小部件,它有一个ValueNotifier参数作为构造函数参数。
请参阅下面的片段。
\n\nclass MyWidget extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return FlatChoiceChipList(\n choiceList: ["first item","second item","third item"],\n selectedIndex: ValueNotifier<int>(0),\n onSelected: (index) {},\n );\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n\xe2\x80\x8b
\n\n好吧,正如您在上面的代码片段中看到的,在构建方法中我创建了一个 ValueNotifier 对象,并且稍后不会将其释放。
\n\n我想知道是否有办法检测小部件中发生的溢出并返回一个布尔值以根据trueorfalse值进行一些更改。
例如,我有一个里面有文字的容器。我想检测文本何时溢出容器,之后我将在某些条件下使容器变大。我知道有一些方法,auto_size_text但这里的重点是检测溢出。
我是颤振的新手,并根据要求执行一项任务。
我正在创建一个可以在所有平台上运行的应用程序,如 iOS、Android、桌面(MacOS、Linux、Windows)和网络。
现在客户端想要自定义 MenuBar 并添加一些额外的操作并设置 MenuItem 的分组。
菜单栏如下所示:
有没有可能通过flutter来完成这个任务?
我收到通知警告(不是错误),假设Use key in widget constructors.我有这样的无状态类:
class TeaTile extends StatelessWidget {
final TheTea? tea;
const TeaTile({this.tea}); //the warning in hire!
@override
Widget build(BuildContext context) {
return Container();
}
}
Run Code Online (Sandbox Code Playgroud)
基本的无状态格式有一个像这样的键:
class TeaTile extends StatelessWidget {
const TeaTile({ Key? key }) : super(key: key); //this one
@override
Widget build(BuildContext context) {
return Container();
}
}
Run Code Online (Sandbox Code Playgroud)
我知道如何禁用关键规则use_key_in_widget_constructors: false。但我不想这样做。那么,我如何key添加
final TheTea? tea;
const TeaTile({this.tea});
Run Code Online (Sandbox Code Playgroud)
解决警告通知?
这是代码,任何人都可以帮助我:
Theme(
data: theme,
child: ListTileTheme(
contentPadding: EdgeInsets.all(0),
dense: true,
child: ExpansionTile(
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GFCheckbox(
inactiveBgColor: kColorPrimaryDark,
inactiveBorderColor: Colors.white,
customBgColor: kColorPrimaryDark,
size: 15,
activeIcon: const Icon(
Icons.check,
size: 15,
color: Colors.white,
),
activeBgColor: kColorPrimaryDark,
onChanged: (value) {
setState(() {
isChecked = value;
});
},
value: isChecked,
inactiveIcon: null,
),
SizedBox(
width: 5,
),
textWidget(color: Colors.white, size: 12, text: root.title),
],
),
key: PageStorageKey<DataList>(root),
children: root.children.map(_buildTiles).toList(),
),
),
);
Run Code Online (Sandbox Code Playgroud) 当我尝试使用 flutter DropdownButton Widget 时,我在控制台中收到此错误。
package:flutter/src/material/dropdown.dart': 断言失败: 第 1252 行 pos 12: 'widget.items!.where((DropdownMenuItem item) => item.value == widget.value).length == 1' : 不是真的。
有一个很长的回溯...这里我添加了小代码示例,它将重现此错误...任何人都可以简单地复制粘贴到main.dart文件中
// flutter import
import 'package:flutter/material.dart';
void main() {
runApp(const BugReportApp());
}
class BugReportApp extends StatefulWidget {
const BugReportApp({Key? key}) : super(key: key);
@override
State<BugReportApp> createState() => _BugReportAppState();
}
class _BugReportAppState extends State<BugReportApp> {
final TextEditingController _dropdownController = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Bug Report',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Flex(direction: …Run Code Online (Sandbox Code Playgroud)