由于客户端对应用需求的快速变化,我有近 200 个 dart 文件,其中许多没有使用。除了手动一一搜索之外,我还有什么方法可以找到未使用的类?在 Android Studio 中,我可以使用“检查代码”功能找到未使用的 java 或 kotlin 类。但是我找不到任何用于 dart / flutter 相同目的的工具。
提前谢谢你的帮助。
dart android-studio visual-studio-code flutter android-studio-3.0
我最近更新了我的应用程序以使用Glide 4,准确地说,Glide 4.2.0.gradle这个:
compile 'com.github.bumptech.glide:glide:4.2.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
compile ('com.github.bumptech.glide:okhttp3-integration:4.2.0'){
exclude group: 'glide-parent'
}
Run Code Online (Sandbox Code Playgroud)
在清单中:
<meta-data
android:name="com.xxx.MyGlideModule"
android:value="GlideModule"/>
Run Code Online (Sandbox Code Playgroud)
GlideModule类:
@GlideModule
public class MyGlideModule extends AppGlideModule {
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.connectTimeout(30, TimeUnit.SECONDS)
.build();
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client);
glide.getRegistry().replace(GlideUrl.class, InputStream.class, factory);
}
}
Run Code Online (Sandbox Code Playgroud)
我如何在适配器内使用滑动:
RequestOptions myOptions = new RequestOptions()
.placeholder(R.drawable.ic_placeholder)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.dontAnimate()
.skipMemoryCache(true)
;
Glide.with(mContext)
.load(Imageid[position])
.apply(myOptions)
.into(imageView);
Run Code Online (Sandbox Code Playgroud)
使用这些代码,当我运行它时,我收到错误:
java.lang.RuntimeException: Expected instanceof GlideModule, but found: [my …
Run Code Online (Sandbox Code Playgroud) 我在Kotlin项目中使用MVP模式.我有一个Presenter类:
import com.google.gson.Gson
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.async
import org.jetbrains.anko.coroutines.experimental.bg
class TeamsPresenter(private val view: TeamsView,
private val apiRepository: ApiRepository,
private val gson: Gson
) {
fun getTeamList(league: String?) {
view.showLoading()
async(UI){
val data = bg {
gson.fromJson(apiRepository
.doRequest(TheSportDBApi.getTeams(league)),
TeamResponse::class.java
)
}
view.showTeamList(data.await().teams)
view.hideLoading()
}
}
}
Run Code Online (Sandbox Code Playgroud)
这个演示者课程在Kotlin 1.2.71上正常工作,但我无法在Kotlin 1.3.0上工作.
我在项目的build.gradle中更新了Kotlin版本,删除了"实验协同程序"并添加了kotlin coroutine core依赖:
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0'
Run Code Online (Sandbox Code Playgroud)
这是我目前的代码:
import com.google.gson.Gson
class TeamsPresenter(private val view: TeamsView,
private val apiRepository: ApiRepository,
private val gson: Gson
) {
fun getTeamList(league: String?) {
view.showLoading()
async(UI){
val data = …
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序上实现了用于解析推送通知的 android 通知。但最近我发现kitkat上没有显示通知内容。它仅显示在 OS Lollipop 上。
这是 Kitkat 4.4.4 上的图像
:
在棒棒糖 5.0 上:
两个图像的代码相同:
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
Notification notification = mBuilder.setSmallIcon(smallIcon).setTicker(title) //title
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle(title)
.setStyle(inboxStyle)
.setContentIntent(resultPendingIntent)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
.setContentText(notifMessage)
.build();
NotificationManager notificationManager = (NotificationManager) mContext
.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(mNotificationId, notification);
Run Code Online (Sandbox Code Playgroud)
有关信息,我使用构建工具 23.0.2(编写此问题时最新的)。这是我的应用程序 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
...
Run Code Online (Sandbox Code Playgroud)
有什么区别吗?任何帮助将不胜感激。提前致谢
android android-notifications android-4.4-kitkat android-5.0-lollipop
请帮忙..正如我在问题标题中所写,我无法在一个条形图中绘制负 y 值和正 y 值。我使用你的代码,只更改了其中的几行。
原始来源是:https : //raw.githubusercontent.com/PhilJay/MPAndroidChart/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java。
编辑后的来源是:https : //db.tt/FWGvAZOZ
我只编辑了第 266-273 行。
片段(原始):
for (int i = 0; i < count; i++) {
float mult = (range + 1);
float val = (float) (Math.random() * mult);
yVals1.add(new BarEntry(val, i));
}
Run Code Online (Sandbox Code Playgroud)
片段(已编辑):
for (int i = 0; i < count; i++) {
float val = (float) ((double)1.0 * (float)i) -5;
yVals1.add(new BarEntry(val, i));
}
Run Code Online (Sandbox Code Playgroud)
我已经在作者 github 中打开了一个问题(issue #183),我在 stackoverflow 中发帖,希望在这里我可以有更快的响应。
谢谢各位
请帮我。我做错了什么?我收到错误:
[Get] the improper use of a GetX has been detected.
这是代码:
class MealRecipesItem extends StatefulWidget {
const MealRecipesItem({
Key? key,
@required this.gender,
this.item,
}) : super(key: key);
final int? gender;
final Data? item;
@override
_MealRecipesItemState createState() => _MealRecipesItemState(item?.id);
}
class _MealRecipesItemState extends State<MealRecipesItem> {
final itemId;
_MealRecipesItemState(this.itemId) {
Get.put(RecipeDetailController(), tag: itemId);
}
@override
Widget build(BuildContext context) {
var controller = Get.find<RecipeDetailController>(tag: itemId);
_toggleFavorite() {
controller.toggleFavorite(widget.item?.databaseId);
}
return Material(
child: InkWell(
onTap: _toggleFavorite,
child: Container(
child: Obx(() { // ====**** …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的 Flutter 应用程序中实现 ReorderableListView。代码很简单:
\nimport 'package:flutter/material.dart';\n\nvoid main() => runApp(const MaterialApp(home: MyHomePage()));\n\nclass MyHomePage extends StatefulWidget {\n const MyHomePage({super.key});\n\n @override\n State<MyHomePage> createState() => _MyHomePageState();\n}\n\nclass _MyHomePageState extends State<MyHomePage> {\n void _onReorder(int oldIndex, int newIndex) => setState(\n () => items.insert(\n newIndex > oldIndex ? newIndex -= 1 : newIndex,\n items.removeAt(oldIndex),\n ),\n );\n\n var items = ['Item A', 'Item B', 'Item C'];\n\n @override\n Widget build(context) => Scaffold(\n body: ReorderableListView(\n onReorder: _onReorder,\n children: items.map((item) {\n var index = items.indexOf(item);\n return ListTile(\n key: Key('$index'),\n tileColor: Colors.white,\n …
Run Code Online (Sandbox Code Playgroud) 我的main.dart中有以下代码:
main() {
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(builder: (context) => Auth()), // /**problem here. builder displayed with strikethrough line**/
],
child: App(),
),
);
}
Run Code Online (Sandbox Code Playgroud)
从大约2天前开始,我的visual studio代码显示以下警告:
所以我不建议使用ChangeNotifierProvider上的builder参数。我到处搜索,但找不到该Builder参数的替代方法。那么如何消除这些警告呢?以下是我flutter --version
在Windows 10上使用命令的Flutter版本
> flutter --version
Flutter 1.9.1+hotfix.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 68587a0916 (3 months ago) • 2019-09-13 19:46:58 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0
Run Code Online (Sandbox Code Playgroud)
对于任何帮助,在此先感谢