Closed spiderman16888 closed 4 months ago
只是在 example 代码里使用了 MVVM 架构,目的是为了分离视图层和业务层代码,方便大家理解插件的用法,实际使用中并不需要使用 MVVM,只需要根据迁移文档修改代码即可
好的,我試試. 但我找遷移文件. https://pub.dev/documentation/bluetooth_low_energy/latest/doc/migrations/migration-v6.md 他顯示404 Not Found.
比如說下面的程式碼.整個改變太大. 本來很簡單的程式,都要改變成要用viewModel, 可以不用 ViewModel 嗎? 很多人看不懂. 因為我覺得flutter 還有bloc, provider, 不應該強迫user使用MVVM. GoRoute( path: ':uuid', builder: (context, state) { final uuidValue = state.pathParameters['uuid']!; final uuid = UUID.fromString(uuidValue); final viewModel = ViewModel.of(context);
final eventArgs = viewModel.discoveries.firstWhere(
(discovery) => discovery.peripheral.uuid == uuid);
return ViewModelBinding(
viewBuilder: (context) => PeripheralView(),
viewModelBuilder: (context) =>
PeripheralViewModel(eventArgs),
);
},