flutter_bloc_infinite_list
一个学习Flutter Bloc正确方式的示例应用程序。本教程参考了一些我根据经验得出的注意事项。
-
您可以使用 Cubit 做很多事情,并不总是需要 Bloc。在此示例中,有使用事件、去抖动等的转换……因此,此处确实需要 Bloc。
-
使用枚举来表示加载状态比为每个状态编写特定类更好,因为它会增加样板代码。
-
我爱 Bloc!❤️
入门
此应用程序的灵感来自 Bloc 教程。
项目结构
遵循以功能驱动的目录结构。
请直接参考教程中的项目结构,网址为 此处。
├── lib | ├── posts │ │ ├── bloc │ │ │ └── post_bloc.dart | | | └── post_event.dart | | | └── post_state.dart | | └── models | | | └── models.dart* | | | └── post.dart │ │ └── view │ │ | ├── posts_page.dart │ │ | └── posts_list.dart | | | └── view.dart* | | └── widgets | | | └── bottom_loader.dart | | | └── post_list_item.dart | | | └── widgets.dart* │ │ ├── posts.dart* │ ├── app.dart │ ├── simple_bloc_observer.dart │ └── main.dart ├── pubspec.lock ├── pubspec.yaml