Dart modular development, event communication template generation plugin (AS, IDEA)

- Menu
Tools -> Build Flutter Bridge
- Or use shortcut keys
Alt + B
There are several requirements for the Bridge template
- A dart file can only have one class, stored in the
lib/ directory
- The class must be
with Bridge
- The method must be annotated with
@Url
- The method parameter must be
Map<String, String>, and the return value must be R or Future<R> type
import 'package:module_bridge/module_bridge.dart';
class UserBridge with Bridge {
@Url(url: '/user/getUserId', desc: 'Get UserId')
R getUserId(Map<String, String> params) {
return R.ok(data: 1234);
}
@Url(url: '/user/getUserName', desc: 'Get user name')
Future<R> getUserName(Map<String, String> params) async {
return R.ok(data: 'azhon');
}
}