我的 Flutter 应用程序中有一个 CupertinoAlertDialog 和 AlertDialog。每次弹出对话框时,它后面的一切都会变暗。我想删除背景。我怎么做?
CupertinoDialogAction(
child: Text('Delete',
style: TextStyle(color: Colors.red),
),
onPressed: () async {
await CommentActivity.delete(postData[index]['id'])
.then((response) {
if (response) {
setState(() {
postData.removeAt(index);
createPageActivity();
renderPageActivity();
});
Navigator.of(context).pop();
}
});
}
)
],
)
Run Code Online (Sandbox Code Playgroud) I'm using the sample below (taken from the CupertinoTabScaffold documentation page).
There is a "slide" transition when pushing a new route inside the tab, but when I click on a tabbar item, the content is brutally replaced. How can I have a transition when switching between tabs?
I would like implement something like that: https://github.com/Interactive-Studio/TransitionableTab
CupertinoTabScaffold(
tabBar: CupertinoTabBar(
items: [
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.home),
title: Text("Tab 0"),
),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.news),
title: Text("Tab 1"),
),
],
),
tabBuilder: (BuildContext context, …
Run Code Online (Sandbox Code Playgroud) 我们是否有一种简单的方法可以CupertinoApp
只使用下面的那种菜单?
我知道要使用它们,就必须import 'package:flutter/cupertino.dart';
像这样使用它,Icon(CupertinoIcons.info);
但是很难选择所需的图标。
亲爱的Flutter小组,请在某处提供完整的Cupertino图标参考。一个地方的名称没有图标,其他地方的图标没有名字。
更新:
正如Mariano所指出的那样,并且如本答案所示,名称映射尚未完成,我们可以如下使用图标:
const IconData baseball = const IconData(0xf3dd,
fontFamily: CupertinoIcons.iconFont,
fontPackage: CupertinoIcons.iconFontPackage);
Icon(baseball);
Run Code Online (Sandbox Code Playgroud)
其中0xf3dd是图标(f3dd)的代码,您可以在此处找到。
我试过这样的事情:
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text(widget.title),
),
child: Center(
child: Container(
child: CupertinoButton.filled(
child: const Text('Push screen'),
onPressed: () {
CupertinoNavigationBar navBar = CupertinoNavigationBar(
leading: Row(children: <Widget>[
const CupertinoNavigationBarBackButton(),
CupertinoButton(
child: const Text('Button 2'),
padding: EdgeInsets.zero,
onPressed: () {},
),
]),
);
Navigator.push(context, CupertinoPageRoute<CupertinoPageScaffold>(
builder: (_) => CupertinoPageScaffold(
navigationBar: navBar,
child: Center(child: const Text('Content')),
)
));
},
),
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
当点击按钮时,它失败了
I/flutter (30855): ??? EXCEPTION CAUGHT BY WIDGETS LIBRARY ????????????????????????????????????????????????????????????
I/flutter (30855): …
Run Code Online (Sandbox Code Playgroud) 我在我的颤振应用程序中使用 CupertinoTabBar。问题是当键盘出现时,bottomBar 会显示,而它不应该。它是一个底部栏,它应该始终位于底部。
我还没有找到一些方法或技巧来做到这一点。也许有人可以指导我获得正确的行为。
这是我的颤振医生输出
医生摘要(要查看所有详细信息,请运行 flutter doctor -v):
[?] Flutter (Channel master, v1.6.1-pre.50, on Linux, locale en_US.UTF-8)
[?] Android 工具链 - 为 Android 设备开发(Android SDK 版本 28.0.3)
[?] Android Studio(3.3 版)
[?] VS Code(版本 1.33.1)
[?] 连接的设备(1 个可用)
这是 cupertinoTabBar 允许的唯一选项:
const CupertinoTabBar({
Key key,
@required this.items,
this.onTap,
this.currentIndex = 0,
this.backgroundColor,
this.activeColor,
this.inactiveColor = CupertinoColors.inactiveGray,
this.iconSize = 30.0,
this.border = const Border(
top: BorderSide(
color: _kDefaultTabBarBorderColor,
width: 0.0, // One physical pixel.
style: BorderStyle.solid,
),
),
})
Run Code Online (Sandbox Code Playgroud)
这是出现键盘时我的 …
我想知道是否有办法在 CupertinoTabBar 中停靠浮动操作按钮。我想得到如下图所示的结果
我的屏幕组织如下
我尝试将以下代码添加到我的Scaffold 中,但结果不是我想要的。我理解问题是 TabBar 不在脚手架内,因此它没有停靠但是我想知道是否有办法将浮动按钮放在其他地方以获得我想要的结果
这是代码
child: Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton.extended(
backgroundColor: kColorAccent,
onPressed: () {},
label: Text('To my Favorites!'),
icon: Icon(Icons.favorite),
),
Run Code Online (Sandbox Code Playgroud)
这是我得到的结果......
我需要更改 CupertinoDatePicker 的字体大小,使其看起来更像原生字体。与 ios datepicker 相比,字体较小。对于高度包装在高度为 Container 中的高度,MediaQuery.of(context).copyWith().size.height / 3
使得高度与原生高度相似。
我的问题是,如何在 Flutter 中更改 CupertinoSwitch 的非活动颜色,使用普通 Switch 相当容易,因为我们有相应的属性,但在 CupertinoSwitch (iOS) 上我们没有这些属性。
编辑:
现在这是实现这一目标的自定义类。
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
class MyCupertinoSwitch extends StatefulWidget {
/// Creates an iOS-style switch.
///
/// The [value] parameter must not be null.
/// The [dragStartBehavior] parameter defaults to [DragStartBehavior.start] and must not be null.
const MyCupertinoSwitch({
Key key,
@required this.value,
@required this.onChanged,
this.activeColor,
this.trackColor,
this.dragStartBehavior = DragStartBehavior.start,
}) : assert(value != null),
assert(dragStartBehavior != null),
super(key: key);
/// Whether …
Run Code Online (Sandbox Code Playgroud)