我正在使用draggableScrollableSheet. 我给这些参数
DraggableScrollableSheet(initialChildSize: 0.4,maxChildSize: 1,minChildSize: 0.4,builder: (BuildContext context, ScrollController scrollController) {
return SingleChildScrollView(controller: scrollController,
child: Theme(
data: Theme.of(context).copyWith(canvasColor: Colors.transparent),
child: Opacity(
opacity: 1,
child: IntrinsicHeight(
child: Column(mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(height: 10,),
Container(
margin: EdgeInsets.only(right: 300),
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: Colors.blue,
width: 3,
style: BorderStyle.solid),
),
),
),
Card(
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
S
.of(context)
.we_have_found_you_a_driver,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold), …Run Code Online (Sandbox Code Playgroud) 我一直在研究一些列表排序库,例如flutter_list_drag_and_drop,reorderable_list,flutter_reorderable_list,dragable_flutter_list,和其他人,但只有一个列表中的所有工作。
我想要做的事情可以在下图中理解,这正是 Trello 应用程序所拥有的。
任何图书馆建议或如何做到这一点?

我使用 flutter Bloc 将用户导航到登录页面或主屏幕,具体取决于用户是否经过身份验证。但是,在初始状态更改后,当我更改身份验证状态时,侦听器不会触发。
听众:
Widget build(BuildContext context) {
return BlocListener<AuthenticationBloc, AuthenticationState>(
listener: (context, state) {
// Listener never gets called on statechange after the initial app startup
// navigation based on authentication
}
},
child: SplashPage(),
);
}
Run Code Online (Sandbox Code Playgroud)
提供者在父小部件中初始化:
AuthenticationRepository authRepo = AuthenticationRepository();
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider<AuthenticationBloc>(
create: (BuildContext context) =>
AuthenticationBloc(authenticationRepository: authRepo),
),
/*
Other Providers
*/
],
child: MaterialApp(
title: 'myApp',
home: StartUpPage(),
),
);
Run Code Online (Sandbox Code Playgroud)
当用户登录时,mapEventState 在 AuthenticationBloc 中被调用:
class AuthenticationBloc
extends …Run Code Online (Sandbox Code Playgroud) 我是 Flutter 开发的新手。谁能分享我如何禁用后按flutter?
在Android中,我们可以使用onbackpressed方法。
@Override
public void onBackPressed() {
// super.onBackPressed(); commented this line in order to disable back press
//Write your code here
Toast.makeText(getApplicationContext(), "Back press disabled!", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
在flutter如何可能呢?
由于CachedNetworkImage不在 flutter web 上工作,在移植时,我尝试使用它,但我的问题是我们真的需要它吗?或者我们只使用 Image。网络和浏览器和服务工作者将处理缓存部分(然后由服务器的响应头设置,例如 cache-control="max-age=43200, public"
这用于我正在从事的食品配送项目,https://www.santaiyamcha.com
下面是我用来替换 CachedNetworkImage 的类,它似乎不能很好地工作。
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:http_extensions_cache/http_extensions_cache.dart';
import 'package:http_extensions/http_extensions.dart';
/// Builds a widget when the connectionState is none and waiting
typedef LoadingBuilder = Widget Function(BuildContext context);
/// Builds a if some error occurs
typedef ErrorBuilder = Widget Function(BuildContext context, Object error);
class MeetNetworkImage extends StatelessWidget {
/// Image url that you want to show in your app.
final String imageUrl;
/// When image data loading from the …Run Code Online (Sandbox Code Playgroud) 我的主页上有一个列表视图,如果单击它将移动到新页面,第一个页面的主题应为蓝色,下一个页面的主题数据应为红色。就像 Facebook Messenger 中聊天自定义的工作原理一样。
我有一个小部件,它呈现 TextFormFields 的 ListView 以输入数据。但是,我想动态更改其中一个文本字段的键盘类型。以下是小部件的概述:
class CreateTodo extends StatefulWidget {
@override
_CreateTodoState createState() => _CreateTodoState();
}
class _CreateTodoState extends State<CreateTodo> {
final _formKey = GlobalKey<FormState>();
final double formWidth = 175.0;
final Map<String, Icon> itemsMap = {
'Heading': Icon(Icons.title),
'Description': Icon(Icons.edit),
'Date': Icon(Icons.calendar_today)
};
final items = ['Heading', 'Description', 'Date'];
_changeKeyboardType(entry) {
if (entry == "Description") {
return TextInputType.multiline;
}
return TextInputType.text;
}
ListView createListItems() {
return ListView.builder(
padding: EdgeInsets.only(
left: 50.0,
right: 50.0,
top: 20.0
),
scrollDirection: Axis.vertical,
itemCount: 3, …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的小部件测试,我可以使用 找到小部件actionKey,但是点击测试失败并且tapped在 后值为 false tester.tap(...),我的测试有什么问题?
testWidgets('some test', (WidgetTester tester) async {
final UniqueKey actionKey = UniqueKey();
bool tapped = false;
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: SlidableListItem(
child: const ListTile(title: Text('item')),
actions: <Widget>[
InkWell(
key: actionKey,
child: const Text('action'),
onTap: () => tapped = true,
),
],
),
),
));
await tester.tap(find.byKey(actionKey));
await tester.pump();
expect(find.byKey(actionKey), findsOneWidget);
expect(tapped, isTrue); <- failes
});
Run Code Online (Sandbox Code Playgroud)
The following TestFailure object was thrown running a test:
Expected: true
Actual: <false>
Run Code Online (Sandbox Code Playgroud) 我有一个听另一个集团的集团。将flutter_bloc包更新为 后version 6.0.2,侦听器在初始状态下将不再调用。
class BlocA extends Bloc {
final BlocB blocB = ...;
...
blocA.blocB.listen((state) {
DO SOMTTHING...
});
...
}
Run Code Online (Sandbox Code Playgroud)
我找到了这个解决方案:
class BlocB extends Bloc<..., ...> with BehaviorSubjectBloc {
...
}
mixin BehaviorSubjectBloc<TEvent, TState> on Bloc<TEvent, TState> {
@override
StreamSubscription<TState> listen(
void Function(TState state) onData, {
Function onError,
void Function() onDone,
bool cancelOnError,
}) {
onData(this.state);
return super.listen(
onData,
onError: onError,
onDone: onDone,
cancelOnError: cancelOnError,
);
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道有没有更好的解决方案?