sm_view_state 0.0.1 copy "sm_view_state: ^0.0.1" to clipboard
sm_view_state: ^0.0.1 copied to clipboard

discontinued
outdated

ViewState

ViewState #

提供 ViewState,主要用于维护 View 所需的数据,需要配合 riverpod 进行使用。

class Book {
  String name = "";
  String author = "";
}

final bookProvider = StateNotifierProvider<BookViewModel, ViewState<Book>>((ref) {
  return BookViewModel();
});

// 继承自 ViewModel
class BookViewModel extends ViewModel<Book> {

  BookViewModel() : super(null);

  Future<void> fetch() async {
    // 修改为加载状态
    load();

    // 延迟两秒响应
    await Future.delayed(const Duration(seconds: 2));

    //  加载数据完成
    finish("new data");
  }
}
1
likes
0
points
5
downloads

Publisher

unverified uploader

Weekly Downloads

ViewState

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, state_notifier

More

Packages that depend on sm_view_state