- Menu
Tools -> Build Flutter Bridge
- Or use shortcut keys
Alt + B
- 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 beR
orFuture<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');
}
}