1. If the next page is displayed, the black screen is displayed
When navigator. push opens the next page, this page navigator. pop(context) returns to the previous page and a black screen appears. Remove the MaterialApp of the current page
2. Soft keyboard, layout with the top of the keyboard problem
In the Scaffold add attribute resizeToAvoidBottomPadding: false
3. When you press the soft keyboard, iOS cannot disable the soft keyboard
Click on the event in the layout layer
InkWell(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: child
)
Copy the code
4. ScrollView nested ListView scrolling problem
ListView. Builder (shrinkWrap: true, physics: NeverScrollableScrollPhysics (), / / the padding: EdgeInsets.fromLTRB(15, 0, 15, 15), itemCount: subjects.length, itemBuilder: (BuildContext context, int position) { return getItem(context, subjects[position]); });Copy the code
5. Android nested Flutter back key returns to previous page processing
override fun onBackPressed() { if (flutterView ! = null) { flutterView? .popRoute() } else { super.onBackPressed() } }Copy the code
Internationalization is needed when using controls that default to English (e.g., select the date component)
Dependencies :flutter_localizations: SDK :flutter import 'package:flutter_localizations/flutter_localizations. Dart '; return MaterialApp( home: child, localizationsDelegates: [ GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], supportedLocales: [ const Locale('zh', 'CH'), // const Locale('en', 'US'), ], );Copy the code
7. Rxdart makes network requests for example:
ProgressDialog _progressDialog = ProgressDialog(context); ApiRepository.resetPassword(_phoneController.text, _codeController.text, _newPasswordContrpller.text) .doOnDone(() => _progressDialog.hide()) .doOnListen(() => _progressDialog.show()) .doonError ((error, StackTrace) {if (error is DioError) {showToast(" load failed, please check network connection "); } }).listen((baseResp) { if (baseResp ! = null && baserESP. isSuccess()) {showToast(" reset successful "); Navigator.pop(context); } else { showToast(baseResp.msg); }});Copy the code
8. Integrate image_pick without callbacks (Android with Flutter)
Add callback code on Android
override fun onActivityResult(requestCode: Int, resultCode:Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) flutterView? .pluginRegistry? .onActivityResult(requestCode, resultCode, data) } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) flutterView? .pluginRegistry? .onRequestPermissionsResult(requestCode, permissions, grantResults) }Copy the code
9. Error with Flutter in iPhone input box when long pressing copy and paste popup
There is a way to display Android style in iOS
Theme(
data: ThemeData(platform: TargetPlatform.android),
child: TextField(
*****)
)
Copy the code
See this article for another way to implement iOS as it is
Cupertino copy and paste pop-up error with flutter