The generate_api_path can be generated different api path file for encode api request.
debug mode:
class UrlGenerator {
static const String userInfo = '/user/info';
static const String systemHiNotice = '/system/hi/notice';
static const String flowerHiGood = '/flower/hi/good';
}release mode:
class UrlGenerator {
static const String userInfo = '00000000-00000000-00000-000000000000';
static const String systemHiNotice = '00000000-00000000-00000-000000000001';
static const String flowerHiGood = '00000000-00000000-00000-000000000002';
}import the generate_api_path and analyzer plugin in pubspec.yaml file.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.6
# This one.
generate_api_path: ^0.0.1
dev_dependencies:
flutter_test:
sdk: flutter
# This one.
analyzer: ^6.2.0make a file origin.txt on material directory, and write the api path in it.
the key is code and the value is the path.
00000000-00000000-00000-000000000000 -> /user/info
00000000-00000000-00000-000000000001 -> /system/hi/notice
00000000-00000000-00000-000000000002 -> /flower/hi/goodthen run the command:
dart run generate_api_path:create --origin_file_path material/origin.txt --target_file_path lib/gen/http/api_mapping_generate.dart --mode debugor
dart run generate_api_path:create --origin_file_path material/origin.txt --target_file_path lib/gen/http/api_mapping_generate.dart --mode releaseit will generate a file api_mapping_generate.dart in lib/gen directory and the content is:
class UrlGenerator {
static const String userInfo = '/user/info';
static const String systemHiNotice = '/system/hi/notice';
static const String flowerHiGood = '/flower/hi/good';
}or
class UrlGenerator {
static const String userInfo = '00000000-00000000-00000-000000000000';
static const String systemHiNotice = '00000000-00000000-00000-000000000001';
static const String flowerHiGood = '00000000-00000000-00000-000000000002';
}more detail see the example directory.