Time plugins and formatting
flutter_cupertino_date_picker
+date_format
Reference:
Github.com/dylanwuzh/f…
www.cnblogs.com/yiweiyihang…
Calendar formatting plug-in date_format
Cloud.tencent.com/developer/a…
import 'package:date_format/date_format.dart';
import 'package:flutter_cupertino_date_picker/flutter_cupertino_date_picker.dart';
void _showDatePicker() {
DatePicker.showDatePicker(
context,
pickerTheme: DateTimePickerTheme(
showTitle: true,
confirm: Text('sure', style: TextStyle(color: Colors.red)),
cancel: Text('cancel', style: TextStyle(color: Colors.cyan)),
),
minDateTime: DateTime.parse("2019-05-21"),
// maxDateTime: DateTime.parse(MAX_DATETIME),
initialDateTime: DateTime.now(),
dateFormat: "yyyy-MM-dd",
locale: DateTimePickerLocale.zh_cn,
onConfirm: (dateTime, List<int> index) {
setState(() { _date = dateTime; }); }); }Copy the code
Image select multi_image_picker
Reference:
Pub. Dev/packages/mu…
Sh1d0w. Making. IO/multi_image…
Android/app/SRC/main/AndroidMainFest. Added to XML
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
Copy the code
The android/app/build. Gradle
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.paoding.jihong_horticulture_warehouse"
minSdkVersion 19 / / 16 to 19
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Copy the code
android/build.gradle
dependencies {
classpath 'com. Android. Tools. Build: gradle: 3.5.0'}}Copy the code
android/gradle/wrapper/gradle-wrapper.properties
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\:/ / services.gradle.org/distributions/gradle-5.4.1-all.zip
Copy the code
The last one
Then delete the original gradle package
Usage Reference:
void _uploadPictures() async {
var list =
await MultiImagePicker.pickImages(maxImages: 9, enableCamera: true);
setState(() {
images = images+list;
});
for (var r in list) {
var t = await r.filePath;
await _upLoadImage(File(t));
}
}
_upLoadImage( File croppedFile) async {
String _path = croppedFile.path;
var _name = _path.substring(_path.lastIndexOf("/") + 1, _path.length);
String _suffix = _name.split(".").last.toLowerCase();
ContentType _contentType;
if (_suffix == "jpg") {
_contentType =ContentType("image"."jpeg");
} else if (_suffix == "png") {
_contentType =ContentType("image".'png');
}
FormData _formData = new FormData.from({
"file": new UploadFileInfo(croppedFile, _name,contentType: _contentType)
});
String host = 'https://app.ji-hong.com.cn/api';
String url='/attachment/upload';
Dio dio = new Dio();
Response response =await dio.post("$host$url", data: _formData);
if (response.statusCode == 200) {
var resCode = response.data['code'];
if (resCode == 200) {
uploadimageList.add(response.data['data']);
print(response.data['data']);
} else if (resCode == 400) {
showToast(response.data['message']);
}
}
}
Widget buildGridView() {
return GridView.builder(
itemCount: images.length + 1,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, crossAxisSpacing: 4, mainAxisSpacing: 3),
itemBuilder: (BuildContext context, int index) {
returnindex ! = images.length ? Stack(children: <Widget>[ GestureDetector( onTap: () { showDialog( context: context, builder: (_) => Center( child: AssetThumb( asset: images[index], width: 300, height: 300, ), )); }, child: AssetThumb( asset: images[index], width: 105, height: 105,),), new toy (right: 10, top: 0.05, Child: New GestureDetector(onTap: () {setState(() {
if(uploadimageList.length == images.length){ images.remove(images[index]); uploadimageList.removeAt(index); }else{
toast("Wait until the pictures are uploaded and delete them."); }}); }, child: new Container( decoration: new BoxDecoration( color: Colors.black45, shape: BoxShape.circle, ), child: New Icon(Icons. Close, color: Colors. White, size: 20.0,)))]) : GestureDetector(onTap: _uploadPictures, child: Container( alignment: Alignment.topLeft, child: LocalImageSelecter.getImage('d_icon_sczp_n', imageWidth: Adapt.dp(105), imageHeight: Adapt.dp(105)))); }); } _getDataList2() async {if(uploadimageList.length! =images.length){toast("Pictures have not been uploaded, wait...");return; }Copy the code
Lateral spreads
Flutter_slidable: 0.5.3
Juejin. Cn/post / 684490…
toast
Toast pub. Flutter – IO. Cn/packages/ok…
OKToast(
/// set toast style, optional
child:MaterialApp()
);
Copy the code
Custom encapsulation:
Get a DART file for this
import 'package:jihong_horticulture_warehouse/common/CommonInsert.dart';
ToastFuture toast(String text){
return showToast(text,
textPadding:EdgeInsets.fromLTRB(Adapt.dp(14), Adapt.dp(9), Adapt.dp(13), Adapt.dp(9)),
position: ToastPosition(align: Alignment.center,),
backgroundColor: Colors.black,
radius: Adapt.dp(4),
textStyle:
TextStyle(color: MyColors.white, fontSize: MyFonts.mediumminus));
}
Copy the code
Where adapt.dp is the adaptive width, refer to the file when you want to use it, toast(‘ text ‘); Can be
showToastWidget(Center( child: Container( decoration: BoxDecoration( color: Color.black. WithOpacity (0.7), borderRadius: borderRadius. Circular (10)), padding: const EdgeInsets. Symmetric (vertical: 12, horizontal: 28), child: Column( children: <Widget>[ LocalImageSelecter.getImage('icon_common_ok',
imageWidth: 44, imageHeight: 44),
SizedBox(
height: 10,
),
Text(
'success',
style: TextStyle(fontSize: 12),
)
],
mainAxisSize: MainAxisSize.min,
),
),
));
Copy the code
Scan the QR code
Pub. Dev/packages/ba…
Blog.csdn.net/qq_35905501…
There is an error, because the latest version is referenced in pub.dev, resulting in a port to androidX
Juejin. Cn/post / 684490…
Switching to a lower version results in duplicate packages.
High end: no longer humble – the JDK is written as jre ext.kotlin_version = ‘1.2.31’
www.cnblogs.com/gxsyj/p/114…
Android Dependency 'Androidx. core:core' has different versionfor the compile (1.0. 0) and runtime (1.01.) classpath. You should manually set the same version via DependencyResolution
Copy the code
www.codercto.com/a/80137.htm…
Flash lamp
C:\flutter.pub-cache\hosted\pub.dartlang.org \ barcode_scan – 0.0.6 \ android \ SRC \ main \ kotlin \ com \ apptreesoftware \ barcodescan first Change into Chinese in a KT file
Generate qr code
Qr code generation plugin qr_FLUTTER 3.1.0
Pub. Dev/packages/qr…
The lower version will report an error, remember that.
Flutter picker plug-in
Pop-up list slide selection
https://github.com/yangyxd/flutter_picker/blob/master/example/lib/main.dart
Copy the code
Localization, long press the character out of copy to copy
In the main file add:
Widget build(BuildContext context) {
return OKToast(
position: ToastPosition.bottom,
backgroundColor: MyColors.button_bg_grey_deep,
child: MaterialApp(
onGenerateRoute: prefix0.onGenerateRoute,
initialRoute: '/',
title: 'JIHong', localizationsDelegates: [PickerLocalizationsDelegate. Delegate, / / if you want to use the localization, please add this trip, You can show Chinese button GlobalMaterialLocalizations. Delegate, GlobalWidgetsLocalizations. Delegate,], supportedLocales: [ const Locale('en'.'US'),
const Locale('zh'.'CH')],Copy the code
Reference: blog.csdn.net/u010126792/…
www.jianshu.com/p/ac1615db8…
Wifi plug-in
Later changed to wiFI-iot, but with the two-dimensional code plug-in conflict, the current mobile phone if only need to switch on and off wifi is very easy to solve, but to connect to the specified wifi should be only Android can do
Pub. Dev/packages/wi…
Run a deemo
Error:
gradlew.bat” exited abnormally:
versionCode not found. Define flutter.versionCode in the local.properties file.
Solution:
Blog.csdn.net/qq_24550911…
Add it to android/local.properties
Sdk. dir=C:\ Users\ EDZ\ AppData\ Local\ Android\ SDK flutter. SDK =C:\\flutter. BuildMode =debug flutter.versionName=1.0. 0
flutter.versionCode=1
Copy the code
Flutter makes phone calls and jumps to web pages
url_launcher
Pub. Flutter – IO. Cn/packages/ur…
The latest version requires a higher version of dart.SDK
For url_launcher: 5.2.1
Blog.csdn.net/qq_33210042…
flutter_html
Pub. Flutter – IO. Cn/packages/fl…
import 'package:flutter_html/flutter_html.dart'; SingleChildScrollView(child: Html(data:Copy the code
Wechat login fluwX
Get the code, using sendAuth
There has been an error without this signature
Deemo sendAuth I ran
And then the project went bad
I rebooted my phone. It’s done
main.js
await fluwx.register(
appId: "wx747bca6f419ed7a3".doOnAndroid: true.doOnIOS: true,);var result = await fluwx.isWeChatInstalled();
print("is installed $result");
Copy the code
Landing page
void initState(){
super.initState();
fluwx.responseFromAuth.listen((response) {
// Listen for the authorization login callback
print("code: "+ response.code); }); } in component ontap:(){fluwx.sendauth (scope:"snsapi_userinfo".state: "wechat_sdk_demo_test"); }Copy the code
Related websites:
Github.com/OpenFlutter…
Address the plugin
import 'package:city_pickers/city_pickers.dart'; String provinceS; String cityS; String districtS; void _selectCity() async { Result tempResult = await CityPickers.showCityPicker( context: context, locationCode: resultAttr ! = null ? resultAttr.areaId ?? resultAttr.cityId ?? resultAttr.provinceId : null, showType: ShowType.pca, height: 350, isSort: isSort, barrierOpacity: barrierOpacityAttr, itemExtent: customerItemExtent, cancelWidget: Text('cancel',style: TextStyle(color: MyColors.blue_4f,fontSize: MyFonts.f14),),
confirmWidget: Text('sure',style: TextStyle(color: MyColors.blue_4f,fontSize: MyFonts.f14),),
itemBuilder: this.getItemBuilder());
print("locationCode $tempResult");
if (tempResult == null) {
return;
}
this.setState(() {
result = tempResult;
provinceS = result.provinceName;
cityS = result.cityName;
districtS = result.areaName;
pccAddress = "${result.provinceName}${result.cityName}${result? .areaName}";
});
}
Copy the code
Pull-up refresh pull-down load
import 'package:pull_to_refresh/pull_to_refresh.dart'; int biu = 0; // Drop down state RefreshController _refreshController = RefreshController(initialRefresh:false); Void _onRefresh() async {// monitor network fetch await future.delayed (Duration(milliseconds: 1000)); //if failed,use refreshFailed()
_refreshController.refreshCompleted();
_pageNo = _pageNo2=1;
_list=[];
if(! isPage2) { _getDataList(); }else{ _getDataList2(); } _refreshController.loadComplete(); } // pull down void _onLoading() async {// monitor network fetch await future.delayed (Duration(milliseconds: 1000));if(! isPage2) { _pageNo++; _getDataList(); }else{
_pageNo2++;
_getDataList2();
}
if(biu == 2) { _refreshController.loadNoData(); / / found countless according to appear as long as the state can no longer under tensile load, can lead to enter the page of screening can't drop down / / need _refreshController loadComplete (); Reset state}else if (biu == 0) {
_refreshController.loadFailed();
} else {
_refreshController.loadComplete();
}
}
bool flag = true;
bool isPage2 = false; Int _pageNo = 1; Int _pageNo2 = 1; List _list = []; voidinitState() {
super.initState();
_getDataList();
}
void disposeDispose () {// Dispose textEditingController controller1.dispose(); controller2.dispose(); controller3.dispose(); super.dispose(); } / / normal request _getDataList () is async {var res = await the Fetch HttpManager.net (context, address findAllWarehouseComplaint (), {"pageable": {"page": _pageNo, "size": 5}}, null, null, noTip: true);
isPage2 = false;
if(res ! = null) {if (res.result) {
if (mounted) {
setState(() {
if(res.data.length ! = 0) { _list.addAll(res.data); biu = 3; }else{ biu = 2; }}); }}}else{ biu = 0; toast(BaseCommon.SERVER_ERROR); }} // Filter page request + drop down _getDataList2() async{isPage2 =true;
Map<String,dynamic> map = new Map();
map = {"providerName":controller3.text,"plantName":controller1.text,"status":status,"complaintName":controller2.text,"pageable": {"page": _pageNo2, "size": 5}};
var res = await HttpManager.netFetch(
context, address.filterWarehouseComplaint(), map, null, null, noTip: true);
if(res ! = null) {if (res.result) {
if (mounted) {
if(_pageNo2==1&&res.data.length == 0){
if (mounted) {
setState(() {
flag = false; }); }}else if(res.data.length ! = 0) {setState(() {
_list.addAll(res.data);
});
biu = 3;
} else{ biu = 2; }}}}else {
biu = 0;
toast(BaseCommon.SERVER_ERROR);
}
}
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomPadding: false// Enable the keyboard to override the layout key: key7, backgroundColor: MyColors. Grey_f5, appBar: MyAppBar(title: MyAppBar)"After-sales Complaints",
isBack: true,
rightEvent: InkWell(
child: Text("Screening"), onTap: _handlerDrawerButton, // Scaffold.of(context).openEndDrawer(); // CommonUtil.openPage(context, forgetPassword2()); ) , ), body: SmartRefresher(enablePullDown: true.enablePullUp: true,
header: WaterDropHeader(),
footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode) {
Widget body;
if (mode == LoadStatus.idle) {
body = Text("Pull up load");
} else if (mode == LoadStatus.loading) {
body = CupertinoActivityIndicator();
} else if (mode == LoadStatus.failed) {
body = Text("Load failed! Click Retry!");
} else if (mode == LoadStatus.canLoading) {
body = Text("Let go! Load more!");
} else {
body = Text("No more data!");
}
returnContainer(height: 55.0, child: Center(child: body),); }, ), controller: _refreshController, onRefresh: _onRefresh, onLoading: _onLoading, child: flag ? ListView.builder( itemBuilder: (context, index) {return _buildList(_list[index]);
},
itemCount: _list.length,
)
: new SearchError(callback: (val) => onDataChange(val)),
),
endDrawer: Container(
Copy the code