Generate api path.
The generate_api_path can be generated different api path file for encode api request.
Generate result.
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';
}
Usage
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.0
make 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/good
then 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 debug
or
dart run generate_api_path:create --origin_file_path material/origin.txt --target_file_path lib/gen/http/api_mapping_generate.dart --mode release
it 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.