yanshouwang / bluetooth_low_energy

A Flutter plugin for controlling the bluetooth low energy.
https://pub.dev/packages/bluetooth_low_energy
MIT License
49 stars 16 forks source link

為何要用ViewModel?這樣改跟5.x差異太大 #76

Closed spiderman16888 closed 4 months ago

spiderman16888 commented 4 months ago

比如說下面的程式碼.整個改變太大. 本來很簡單的程式,都要改變成要用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), ); },

yanshouwang commented 4 months ago

只是在 example 代码里使用了 MVVM 架构,目的是为了分离视图层和业务层代码,方便大家理解插件的用法,实际使用中并不需要使用 MVVM,只需要根据迁移文档修改代码即可

spiderman16888 commented 4 months ago

好的,我試試. 但我找遷移文件. https://pub.dev/documentation/bluetooth_low_energy/latest/doc/migrations/migration-v6.md 他顯示404 Not Found.

spiderman16888 commented 4 months ago

我找到了.我試試看遷移.謝謝. https://github.com/yanshouwang/bluetooth_low_energy/blob/master/bluetooth_low_energy/doc/migrations/migration-v6.md