我一直试图在Widget启动时读取首选项,但一直无法找到解决方案.我希望在TextField中显示用户名(他们可以更改)并将其存储在首选项中,以便在它们返回页面时立即显示.
class _MyHomePageState extends State<MyHomePage> {
TextEditingController _controller;
:
:
Future<Null> storeName(String name) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString("name", name);
}
@override
initState() async {
super.initState();
SharedPreferences prefs = await SharedPreferences.getInstance();
_controller = new TextEditingController(text: prefs.getString("name"));
}
@override
Widget build(BuildContext context) {
:
:
return new TextField(
decoration: new InputDecoration(
hintText: "Name (optional)",
),
onChanged: (String str) {
setState(() {
_name = str;
storeName(str);
});
},
controller: _controller,
)
}
}
Run Code Online (Sandbox Code Playgroud)
我在initState()上使用async的想法来自:
API调用后有状态小部件上的颤动定时问题
但async似乎在启动时导致此错误:
'package:flutter/src/widgets/framework.dart': Failed assertion: line …Run Code Online (Sandbox Code Playgroud) 在Android Pie中,默认情况下启用了sqlite预写日志记录(WAL)。这仅在Pie设备中导致我现有代码的错误。由于无法访问WAL,SQLiteDatabase.disableWriteAheadLogging()或者PRAGMA journal_mode由于我访问数据库的方式,我无法成功关闭WAL 。我想使用名为db_compatibility_wal_supported的Android设置完全禁用WAL :
有人知道如何配置吗?我不知道该文件是否可以在启动时以编程方式更改,或者是否可以手动更改。
我的应用程序中有一个sqlite数据库(20mb + / 250k记录)。该数据库是使用我的服务器上的纯Java生成的。它包含一个食物数据库,该应用程序的用户可以添加到数据库中(并且服务器已更新)。这存储在android的assets文件夹中。在首次安装期间,数据库从资产复制到app文件夹,以便可以使用以下有效方法将其写入:
不幸的是,一旦我开始使用SqlDroid写入数据库,就会启用wal,原始数据库中的表将消失,仅保留任何新创建的表。但是,数据库的大小仍为20mb +。所有数据库错误均归因于缺少表。表格复制和写入方法可以在Pie之前的Android版本中完美运行。
我正在尝试访问我的自定义可扩展列表中的孩子。该列表如下所示:
我可以通过以下方式成功访问组:
Espresso.onView(allOf(withId(R.id.groupRowTextView1), withText(startsWith("Candida")))).perform(click());
Run Code Online (Sandbox Code Playgroud)
当我尝试访问子 EditText 时:
Espresso.onData(is(instanceOf(CustomExpandableListAdapter.class)))
.inAdapterView(withId(R.id.aversionsListView))
.onChildView(allOf(withId(R.id.childEditText), isDisplayed()))
.atPosition(1)
.perform(click());
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
11-30 16:47:45.733 2479-2492/com.foodaversions.people I/TestRunner? ----- begin exception -----
11-30 16:47:45.733 2479-2492/com.foodaversions.people I/TestRunner? com.google.android.apps.common.testing.ui.espresso.PerformException: Error performing 'load adapter data' on view 'with id: is <2131099682>'.
at com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.build(PerformException.java:67)
at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:57)
at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:40)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:159)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(ViewInteraction.java:90)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewInteraction.java:73)
at com.google.android.apps.common.testing.ui.espresso.DataInteraction.load(DataInteraction.java:135)
at com.google.android.apps.common.testing.ui.espresso.DataInteraction.perform(DataInteraction.java:112)
at com.foodaversions.people.ModifyAversionsTest.selectGlutenIntolerance(ModifyAversionsTest.java:49)
at com.foodaversions.people.ModifyAversionsTest.test(ModifyAversionsTest.java:20)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:115)
at junit.framework.TestResult.runProtected(TestResult.java:133)
at junit.framework.TestResult.run(TestResult.java:118)
at junit.framework.TestCase.run(TestCase.java:124) …Run Code Online (Sandbox Code Playgroud) 当我将我的 Apple 帐户连接到 App Annie 时,我创建了一个新的电子邮件地址(实际上只是来自我域的简单转发电子邮件)附加到一个只能访问销售数据的 Apple 帐户 - 并将该帐户登录到 App Annie。当我将我的 Amazon 帐户连接到 App Annie 时,Amazon 可以为我提供给 App Annie 的我的应用程序数据创建一个特殊的访问密钥。这两种解决方案都是合理且直接的。
当我尝试将我的帐户连接到 Google Play 时,App Annie 需要我的 google 帐户密码!在我看来,这似乎完全不合理。我想让 App Annie 只访问销售数据,而不是我的整个 Google 帐户。App Annie 是否值得信赖甚至不是重点——这些天公司一直被黑客攻击(例如 InstaAgent)。