sm_view_model

Creator: coderz1093

Last updated:

0 purchases

sm_view_model Image
sm_view_model Images

Languages

Categories

Add to Cart

Description:

sm view model

ViewModel #
用于配合 riverpod 维护 View 所需的数据及状态。
class Book {
String name = "";
String author = "";
}

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

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

BookViewModel() : super(null);

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

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

// 加载数据完成
finish("new data");
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.