我需要获取我当前的路线名称。我习惯于在每个页面中GlobalKey创建。所以我创建:navigatorSeviceNavigator.of(context)navKey
class Keys {
static final GlobalKey<NavigatorState> navKey = GlobalKey<NavigatorState>();
}
Run Code Online (Sandbox Code Playgroud)
当我想重定向到另一个页面时,我会编写Keys.navKey.currentState.pushNamed()或pushReplacementNamed其他一些方法。
我想知道我在 Interceptor 中的当前路线,在那里我没有上下文。
我需要有这样的结构
我LayoutBuilder用来获取内容的高度(在App Bar和之间TabsBottomNavigation)。在这里,我构建 Profile Info Container 并希望使用一些 List Tiles 构建 ListView,但是当我尝试在 Layout Builder 中构建它时,我在控制台中出现错误。
如果我创造ListView出来LayoutBuilder它的作品!
请帮我解决它。我的代码如下:
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return SingleChildScrollView(
child: Container(
child: Column(
children: <Widget>[
Container(
height: viewportConstraints.maxHeight * .44,
color: Theme.of(context).primaryColor,
padding: EdgeInsets.only(bottom: 2),
child: Align(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildProfileImage(context),
SizedBox(height: 17),
Text(userName)
],
),
),
),
Expanded(
child: ListView(
children: <Widget>[
ListTile(
leading: Icon(Icons.print), …Run Code Online (Sandbox Code Playgroud) 我需要框对齐,如下图所示。我使用Wrap Widget将我的物品按两个元素连续包装。但是,正如我所见,Wrap小部件没有crossAxisAlignment的Stretch属性。
我使用另一种方法来构建cardItem,以简化代码,然后将其用于我的四张卡。也许您知道其他一些Widget可以帮助您做到这一点。
有人可以帮我吗。请在下面查看我的代码:
class Transfers extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Transfers'),
),
body: Center(
child: Wrap(
spacing: 10,
runSpacing: 10,
children: <Widget>[
_buildTransferItem(
"assets/images/icon.png",
"Some Text of this box",
context,
),
_buildTransferItem(
"assets/images/icon.png",
"Text",
context,
),
_buildTransferItem(
"assets/images/icon.png",
"Some Text of this box",
context,
),
_buildTransferItem(
"assets/images/icon.png",
"Some Text of this box",
context,
),
],
),
),
);
}
Widget _buildTransferItem(
String transferIcon, String transferTitle, BuildContext context) {
return Container(
width: …Run Code Online (Sandbox Code Playgroud) Android 设备在菜单工具栏上有后退按钮。当我登录到我的应用程序并单击该后退按钮以在登录页面上路由时,我想禁用这种可能性。
我想如果用户在登录后点击后退按钮然后我关闭应用程序。这是我用于路由的初始代码。
if (token) {
this.router.navigate(['/main-tabs/tabs/dashboard'])
} else {
this.router.navigate(['/login']).then();
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 HTML、CSS 和 Jquery 构建音频播放器。我在使用 Jquery 的“悬停”方法时遇到了问题。当“背景图像”被删除时,它似乎将 div 向下移动 - 为什么会这样?我知道这与页面的流程有关。想我应该从头开始重新启动音频播放器,因为它有太多问题。我应该只使用 CSS 悬停吗?
这是直播网站的链接
$('.music-box').hover(function() {
$('.music-box').css("border", "1px solid black");
$('.music-box').css("background", "none");
$('.player').css('display', 'block');
$('.music-details').css('display', 'block');
$('.buyDiv').css('display', 'block');
});
$('.music-box').mouseleave(function() {
$('.music-box').css("border", "none");
$('.music-box').css("background", "url('junction.jpg')");
$('.music-box').css("background-size", "contain");
$('.music-box').css("background-repeat", "no-repeat");
$('.player').css('display', 'none');
$('.music-details').css('display', 'none');
$('.buyDiv').css('display', 'none');
}); Run Code Online (Sandbox Code Playgroud)
.junction {
display: inline;
padding: 2vw;
}
.music-box {
background: url(junction.jpg);
background-size: contain;
background-repeat: no-repeat;
position: relative;
width: 16vw;
cursor: pointer;
height: 30vh;
display: inline-block;
}
.music-details {
display: none;
position: relative; …Run Code Online (Sandbox Code Playgroud)