我开始使用BLoC模式,但我有一个问题:
1)您是否应该使用BloC模式来确定路由是否应该更改?示例:身份验证对象更改为,unauthenticated因此侦听器应处理路由更改.
2)BLoC模式是否应仅用于UI状态并处理UI更改中的路由更改?示例:用户单击login并导航到home屏幕.
我问这个问题是因为我遇到了一个我没有中央导航管理解决方案的问题.
这段代码现在在我的BLoC中:
loggedIn.listen((AuthResponse user) {
currentUserSubject.add(user);
Navigator.pushReplacement(
_context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) {
return HomePage();
},
transitionsBuilder: (context, animation, _, child) {
return new SlideTransition(
child: child,
position: new Tween<Offset>(
begin: const Offset(0.0, 1.0),
end: Offset.zero,
).animate(animation),
);
},
transitionDuration: Duration(milliseconds: 400),
),
);
}, onError: (error) {
Scaffold.of(_context).showSnackBar(new SnackBar(
content: new Text(error.message),
));
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的扑腾应用添加多个屏幕,但无法让它工作.并没有教程/指南来做到这一点.
有没有人有一个如何实现这一目标的例子.
提前致谢.
我有一个关于ListView元素上的ItemSelected()事件的问题.
我的ListView基于DataTemplate,如下所示:
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Label Text="{Binding Name}" FontAttributes="Bold" />
<Button Text="More" Clicked="MoreInfo" c="{Binding Name}"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
它获取了一个PlaceItems数组,其结构如下.
private PlaceItem[] places = {
new PlaceItem("Theo's huis"),
new PlaceItem("Kerk op de berg"),
new PlaceItem("Hostel Stay Okay")
};
public class PlaceItem
{
public PlaceItem(string Name, double Lat = 0.0, double Lng = 0.0)
{
this.Name = Name;
this.Lat = Lat;
this.Lng = Lng;
}
public string Name { get; set; }
public string …Run Code Online (Sandbox Code Playgroud) 我只想在Widget中创建一个包含多个PageViewWidgets的ColumnWidget,供用户滚动浏览.
文件说:
页面视图的每个子项都被强制与视口大小相同.
为什么是这样?在Android中我只会wrap_content用来调整孩子的身高.
创建一个"屏幕"并将其作为主屏幕启动:
class HomeScreen extends StatefulWidget {
@override
State createState() => new HomeScreenState();
}
class HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Flexible(
child: new PageView.builder(
itemBuilder: (BuildContext context, int index) {
return new RaisedButton(
color: Colors.green,
child: new Text(index.toString()),
onPressed: () {});
},
itemCount: 6))
]);
}
Run Code Online (Sandbox Code Playgroud)
当我删除FlexibleWidget它给我这个错误:
I/flutter (19887): ??? EXCEPTION CAUGHT BY RENDERING …Run Code Online (Sandbox Code Playgroud) 我在ListView中有一个ListView,内部ListView不知道它应该是多高,所以我必须给它一个特定的高度,比如一个SizedBox.然而问题是我实际上希望内部ListView缩小换行,以便它不会在父ListView中滚动/占用不必要的空间.
提前致谢
我正在使用蓝图来分隔我的api,admin和authentication,但在我的 API 中我想分隔users,groups和files以获得更好的结构而不是仅仅一个routes文件。
所以我的问题是:是否可以在蓝图内创建蓝图?
或者有更好的解决方案来满足我的结构需求吗?
提前致谢。
我Form用Flutter 创建了一个但是当我专注于一个字段并且键盘弹出时,内容消失了.
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
import 'package:greencat/greencat.dart';
import 'package:woody_app/Application.dart';
import 'package:woody_app/actions/AuthAction.dart';
import 'package:woody_app/states/AuthState.dart';
class ProfileScreen extends StatefulWidget {
@override
State createState() => new ProfileScreenState();
}
class PersonData {
String name = '';
String phoneNumber = '';
String password = '';
}
class ProfileScreenState extends State<ProfileScreen> {
final Store<AuthState, AuthAction<dynamic>> _store = Application.get().store;
StreamSubscription<AuthState> _subscriber;
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
PersonData person = new PersonData();
void showInSnackBar(String value) {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new …Run Code Online (Sandbox Code Playgroud) 的code_build(https://pub.dartlang.org/packages/code_builde)封装提供了一种解决方案,以产生那个类的类和构造函数,字段和方法。
我的最终目标是根据给定的 json 结构生成 Flutter ( https://flutter.io ) Widgets,但我不知道如何使用code_build或其他包来做到这一点。
所以帮助将不胜感激!