小编Har*_*n R的帖子

如何使用 bloc flutter 更改单个列表项的状态?

如何使用 bloc pacakage 在 flutter 中更改列表项中的小部件。我应该在整个 ListView.builder 上使用 BlockBuilder 还是监听器,还是只在单个项目上使用。如果您分享示例或教程,那就太好了。例如,如果我有一个复选框,我需要在单击它时更改其状态。这些是我的 Bloc 课程 Bloc

const String SERVER_FAILURE_MESSAGE = 'Server Failure';
const String CACHE_FAILURE_MESSAGE = 'Cache Failure';
class MarkAttendanceBloc extends Bloc<MarkAttendanceEvent, MarkAttendanceState> {

  final MarkStudentPresent markStudentPresent;
  final MarkStudentAbsent markStudentAbsent;

  MarkAttendanceBloc({@required this.markStudentPresent,@required this.markStudentAbsent});

  @override
  MarkAttendanceState get initialState => MarkedInitial();

  @override
  Stream<MarkAttendanceState> mapEventToState(MarkAttendanceEvent event) async* {
    yield MarkedLoading();
    if(event is MarkAbsentEvent){
      final remotelyReceived = await markStudentAbsent(MarkStudentParams(classId: event.classId, courseId: event.courseId,studentId: event.studentId));
      yield* _eitherLoadedOrErrorState(remotelyReceived);
    }
    else if(event is MarkPresentEvent){
      final remotelyReceived = await markStudentPresent(MarkStudentParams(classId: event.classId, courseId: …
Run Code Online (Sandbox Code Playgroud)

flutter bloc flutter-bloc

6
推荐指数
1
解决办法
1121
查看次数

如何在flutter webview中收听事件?

当用户单击 webview 中存在的按钮时,我想关闭我的 flutter 应用程序中的 webview

这是显示webview的代码

class WebViewApp extends StatefulWidget {
  @override
  _WebViewAppState createState() => _WebViewAppState();
}

class _WebViewAppState extends State<WebViewApp> {
  @override
  Widget build(BuildContext context) {
    return  WebviewScaffold(url: 'https://google.com',
        appBar: AppBar(
          title: Text('Test'),
          centerTitle: true,
          backgroundColor: kBlue,
          leading: BackButton(
            onPressed: (){
              Router.navigator.pop();
            },
          )
        ),
      );
  }
}

Run Code Online (Sandbox Code Playgroud)

示例图像,我想检测运动是否

flutter flutterwebviewplugin

5
推荐指数
2
解决办法
4825
查看次数