A command-lint tool for help develop flutter application.
fluct
is not meant to be used as a dependency,Instead,it should be "activated".
$ pub global activate fluct
# or
$ flutter pub global activate fluct
or you can get it form github.
$ pub global activate -sgit https://github.com/rhymelph/fluct
# or
$ flutter pub global activate -sgit https://github.com/rhymelph/fluct
Learn more about activating and using packages (here)[https://dart.dev/tools/pub/cmd/pub-global]
fluct
provides two commands:create
,assets-gen
,strings-gen
,strings-replace
.
create
create a new file about widget.assets-gen
autogenerated assets file toa.dart
strings-gen
autogenerated chinese strings to json file.strings-replace
auto replace json file find the value to key.
Help Flutter application create a new file
Usage: fluct create [arguments] <path>
-h, --help Print this usage information.
-t, --type
[custom] Create a new file about custom widget in 'fluct.yaml'
[stful] Create a new file about StatefulWidget
[stless] Create a new file about StatelessWidget
-a, --arg create a new file about your custom widget use arg in 'fluct.yaml'
Run "fluct help" to see global options.
create a new file about StateFulWidget.
$ fluct create -t stful home_page
Create a new file about StatefulWidget
create class HomePage
create success
exit 0
End,you can find ./home_page.dart
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Container();
}
}
Create a new file about custom widget in 'fluct.yaml'
inh: |
import 'package:flutter/material.dart';
class $NAME$ extends InheritedWidget {
const $NAME$({
Key key,
@required Widget child,
}) : assert(child != null),
super(key: key, child: child);
static $NAME$ of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType(aspect: $NAME$) as $NAME$;
}
@override
bool updateShouldNotify($NAME$ old) {
return false;
}
}
inh: is your arg.
import..: is your custom widget,use $NAME$
will replace your name by file name,and the first word will uppercase,such as: home_page will become HomePage
as last, you can use this command-line.
fluct create -t custom -a inh home_page_inherited
Auto generate assets to dart file
Usage: fluct assets-gen [arguments] <path>
-h, --help Print this usage information.
-a, --assets your asset directory path -- default ./assets
-i, --ignore ignore your start path
// such as file path is assets/images/... you want to ignore assets/ will become images/....
-o, --output your output directory path -- default ./lib/generated
-r, --[no-]rename Include chinese filename will be rename.
-c, --[no-]collect Collect filename include @2x/@3x/@4x strings file to /2.0x,/3.0x,/4.0x directory
Run "fluct help" to see global options.
Running it.
╰─$ fluct assets-gen
tip: assets directory path in `./assets`
tip: output directory path in `./lib/generated`
waiting: generate running... 0.0s
success: generate complete,new file in `./lib/generated/a.dart`
You can add it in your `pubspec.yaml` file
...............................
flutter:
assets:
- assets/village/
- assets/pay/
- assets/message/
- assets/mine/
- assets/login/
...............................
All done exit 0
In your path:./lib/generated/a.dart
,you can find...
// fluct assets-gen command generated.
// author: rhyme_lph
// github: https://github.com/rhymelph
// version: 1.0.3
class A {
static final String assetsVillageMyMsg = 'assets/village/my_msg.png';
static final String assetsVillageVRepair = 'assets/village/v_repair.png';
static final String assetsVillageVPropertyFee = 'assets/village/v_property_fee.png';
static final String assetsVillageVVoting = 'assets/village/v_voting.png';
static final String assetsVillageIcCompany = 'assets/village/ic_company.png';
static final String assetsVillageIcRightArrow = 'assets/village/ic_right_arrow.png';
static final String assetsVillageVComplain = 'assets/village/v_complain.png';
static final String assetsVillageIcLaw = 'assets/village/ic_law.png';
static final String assetsVillageIcSearch = 'assets/village/ic_search.png';
static final String assetsVillageIvFamilyNorepair = 'assets/village/iv_family_norepair.png';
static final String assetsVillageIcUploadPic = 'assets/village/ic_upload_pic.png';
static final String assetsVillageIvFamilyNocomplaint = 'assets/village/iv_family_nocomplaint.png';
static final String assetsVillageIvFamilyNoad = 'assets/village/iv_family_noad.png';
static final String assetsVillageIcGovernment = 'assets/village/ic_government.png';
static final String assetsVillageVHouse = 'assets/village/v_house.png';
static final String assetsPayPayTypeWx = 'assets/pay/pay_type_wx.png';
static final String assetsPayPayTypeAbc = 'assets/pay/pay_type_abc.jpg';
static final String assetsPayPayTypeAli = 'assets/pay/pay_type_ali.png';
static final String assetsMessageArticle4 = 'assets/message/article_4.jpg';
static final String assetsMessageArticle1 = 'assets/message/article_1.jpg';
static final String assetsMessageArticle3 = 'assets/message/article_3.jpg';
static final String assetsMessageArticle2 = 'assets/message/article_2.jpg';
static final String assetsMessageMReturn = 'assets/message/m_return.png';
static final String assetsMineDefaultAvatar = 'assets/mine/default_avatar.png';
static final String assetsMineMyMsg = 'assets/mine/my_msg.png';
static final String assetsMineHwpushIcToolbarRefresh = 'assets/mine/hwpush_ic_toolbar_refresh.png';
static final String assetsMineArrowRight = 'assets/mine/arrow_right.png';
static final String assetsMineWhiteRight = 'assets/mine/white_right.png';
static final String assetsMineIvCardEmblem = 'assets/mine/iv_card_emblem.png';
static final String assetsMineHomeCenterNormal = 'assets/mine/home_center_normal.png';
static final String assetsMineUserCenterNormal = 'assets/mine/user_center_normal.png';
static final String assetsMineVideoCamera = 'assets/mine/video_camera.png';
static final String assetsMineShare = 'assets/mine/share.png';
static final String assetsMineIconCamera = 'assets/mine/icon_camera.png';
static final String assetsMineIvCardFace = 'assets/mine/iv_card_face.png';
static final String assetsMineMySetting = 'assets/mine/my_setting.png';
static final String assetsMineUmiIdentity = 'assets/mine/umi_identity.png';
static final String assetsMineUmiModfiyPwd = 'assets/mine/umi_modfiy_pwd.png';
static final String assetsMineMyBill = 'assets/mine/my_bill.png';
static final String assetsLoginIcClose = 'assets/login/ic_close.png';
static final String assetsLoginIcLauncher = 'assets/login/ic_launcher.png';
static final String assetsLoginIcLoginBg = 'assets/login/ic_login_bg.png';
static final String assetsLoginIcEyesClose = 'assets/login/ic_eyes_close.png';
static final String assetsLoginIcEyesOpen = 'assets/login/ic_eyes_open.png';
}
Auto generate chinese strings to json file
Usage: fluct string-gen [arguments]
-h, --help Print this usage information.
-o, --output your output directory path -- default ./lib/generated.
-a, --assets your asset directory path -- default ./lib
Run "fluct help" to see global options.
Running it.
╰─$ fluct string-gen
tip: assets directory path in `./lib`
tip: output directory path in `./lib/generated`
waiting: seek chinese strings form your ./lib... 0.2s
success: generate complete,new file in `./lib/generated/strings.json`
All done exit 0
In your path:./lib/generated/string.json
,you can find...
{
"0": "单引号",
"1": "双引号",
"2": "单引sdfsdf\nsdfsf号多",
"3": "双引sdfsdf\nsdfdsf号多",
"4": "r单引号",
"5": "r双引号",
"6": "r单引dsfsdf\nsfdsf号多",
"7": "r双引sdfsdfs\nsdfsdf号多",
}
Auto replace string to your value
Usage: fluct strings-replace [arguments]
-h, --help Print this usage information.
-i, --import the code of you want to import package --default `import 'package:../generated/i18n.dart'`;
-v, --var your i18n variable --default `S.of(context)`
-s, --source your source json file --default `./res/values/a.json`
Run "fluct help" to see global options.
Running it.
╰─$ fluct string-gen
tip: assets directory path in `./lib`
tip: output directory path in `./lib/generated`
waiting: seek chinese strings form your ./lib... 0.2s
success: generate complete,new file in `./lib/generated/strings.json`
All done exit 0
In your path:./lib/generated/string.json
,you can find...
{
"0": "单引号",
"1": "双引号",
"2": "单引sdfsdf\nsdfsf号多",
"3": "双引sdfsdf\nsdfdsf号多",
"4": "r单引号",
"5": "r双引号",
"6": "r单引dsfsdf\nsfdsf号多",
"7": "r双引sdfsdfs\nsdfsdf号多",
}
Have a nice day 。