我的 sqflite 数据库中有一个表,其中包含各个用户的通话历史记录。现在,在 flutter 中的“通话历史记录”页面上,我显示了从 sqflite 获取的完整历史数据,到目前为止它工作正常。但现在我想检查这些号码是否在我的历史记录列表中存在。如果是,那么我想在列表中显示他们的联系人姓名和头像。否则我只想显示数字。这是我的代码:
List<Map<String, dynamic>> ok =
await DatabaseHelper.instance.getAllLogs(argv);
setState(() {
queryRows = ok;
});
var historyRecords = List<HistoryRecord>.from(queryRows.map((row) => HistoryRecord.fromJson(row)));
FutureBuilder<List<HistoryRecord>>(
future: _checkContact(historyRecords),
builder: (context, snapshot) {
return ListView.builder(
itemCount: historyRecords.length,
itemBuilder: (context, index) {
print(historyRecords[index]);
},
);
},
)
Future<List<HistoryRecord>> _checkContact(List<HistoryRecord> rec)async
{
for(int i=0;i<rec.length;i++) {
var conhere=await
ContactsService.getContactsForPhone(rec[i].callHistoryNumber);
//how should i map iterable contact list to Historyrecord
}
}
Run Code Online (Sandbox Code Playgroud) 我已经为我的 flutter 开发安装了 get_cli 。正如文档所说,我使用该命令get create page:home创建一个带有绑定、视图和控制器的主模块。默认情况下,它创建在 lib/app/modules/home文件夹中。如何在不同的文件夹下创建它,例如lib/app2/modules/home或lib/modules/home。
ListView当您根据默认行为插入/删除/重新排序(或执行任何其他操作)项目时ListView.builder,ListView.separated它总是会重建整个小部件。
我怎样才能避免这种情况?它会带来不良结果,例如数据丢失。
Flutter Dart 移动应用程序开发 我正在寻找一种从移动设备的传感器获取指纹图像并使用 dart 将其发送到服务器的方法。我陷入了内部身份验证,似乎无法找到任何方法从设备获取生物指纹数据。阅读许多有关受信任方和其他内容的文档,但无法获得可以远程满足上述要求的具体描述。期待收到你们的来信。
问候。
作为 flutter 中的第一个应用程序,我想构建一个节拍器应用程序。UI 已经构建完成,但实际节拍器功能我仍然遇到以下问题:
\n有时,节拍器会稍微滞后一点,只是足够,所以你会注意到它。flutter中有没有办法实现节拍器100%的精度?
\n演奏时不改变细分(您必须停止并启动节拍器)。如果值“节奏”和“细分”发生变化,如何自动应用于节拍器订阅?我知道 Flutter 提供了 Listenable、Stream、InheritedWidget 等工具,但我还没有找到在现有代码中实现这些工具的方法。
\n用户界面截图:
\n\n这是代码(它不完全是我写的 -> 学分):
\nimport \'dart:io\' show File;\nimport \'dart:async\';\nimport \'package:flutter/cupertino.dart\';\nimport \'package:quiver/async.dart\';\nimport \'package:audioplayers/audioplayers.dart\' show AudioPlayer;\nimport \'package:flutter/services.dart\' show ByteData, rootBundle;\nimport \'package:path_provider/path_provider.dart\' show getTemporaryDirectory;\n\n//credits: "Andi Qu", /sf/ask/3573388171/\n\nValueNotifier<int> tempo = ValueNotifier(100);\nint subdivision = 1;\nbool isPlaying = false;\n\nint soundIndex = 1;\nFile _soundFile;\n\nStreamSubscription<DateTime> _subscription;\n\nFuture<ByteData> _loadSound() async {\n return await rootBundle.load(\'assets/sounds/sound_$soundIndex.wav\');\n}\n\nvoid _writeSound() async {\n _soundFile = File(\n \'${(await getTemporaryDirectory()).path}/sounds/sound_$soundIndex.wav\');\n await _soundFile.writeAsBytes((await _loadSound()).buffer.asUint8List());\n print("_writeSound executed");\n}\n\nvoid _playLocal() async {\n …Run Code Online (Sandbox Code Playgroud) 我需要打开并保存设备上可能存在的简单文本文件。例如在文档、下载等中。只要文件可用于其他程序,在 Android 术语中,它就是“外部存储”
\npath_provider提供了几种方法。其中之一getExternalStorageDirectory()。安卓文档说:
\n\n此方法已在 API 级别 29 中弃用。为了提高用户隐私,\n不推荐直接访问共享/外部存储设备。当\n应用程序定位 Build.VERSION_CODES.Q链接时
\n
如果我使用方法path_provider
getExternalStorageDirectory()\xe2\x86\x92 /storage/emulated/0/Android/data/myapp.name/files \n getApplicationDocumentsDirectory()\xe2\x86\x92 /data/user/0/myapp.name/app_flutter
getExternalStorageDirectories(type: StorageDirectory.documents)返回列表,其中包含
/storage/emulated/0/Android/data/myapp.name/files/Documents
\n/storage/1CEE-4019/Android/data/myapp.name/files/Documents
\n在我的 Android 模拟器(Api 30)上,真实的外部文档位于
\n/存储/模拟/0/文档
\n/存储/模拟/0/下载
\n我怎样才能访问它们?据我了解,没有其他选择path_provider
如何使用GetX在 Flutter 中实现图像(侧边栏和导航菜单)中的设计?类似于网络上的选项卡。
在我的第一个Flutter 项目中,我试图从Alert Dialog内的TextFormField获取值。我正在尝试验证输入,并根据该验证我想启用/禁用AlertDialog按钮。
_displayDialog(BuildContext context) async {
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('TextField AlertDemo'),
content: _container(),
actions: <Widget>[
RaisedButton(
onPressed: isValid
? () {
print("ISVALID:");
}
: null,
child: Text("Click Me"),
)
],
);
});
}
Run Code Online (Sandbox Code Playgroud)
Widget _container() {
return Container(
margin: EdgeInsets.all(25),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextFormField(
onChanged: (text) {
setState(() {
if (text.length > 5) {
isValid = true; …Run Code Online (Sandbox Code Playgroud) 我想用冻结的包创建一个简单的块。这是我的集团:
import 'package:bloc/bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:presentation/presentation_index.dart';
part 'auth_bloc_event.dart';
part 'auth_bloc_state.dart';
class AuthBlocBloc extends Bloc<AuthEvent, AuthState> {
final SignUpBuyerUseCase signUpBuyerUseCase;
AuthBlocBloc(this.signUpBuyerUseCase) : super(AuthState.initial());
@override
Stream<AuthState> mapEventToState(
AuthEvent event,
) async* {
yield* event.map();
}
}
Run Code Online (Sandbox Code Playgroud)
和我的活动课程:
part of 'auth_bloc.dart';
@freezed
abstract class AuthEvent with _$AuthEvent {
const factory AuthEvent.login(String username, String password) = Login;
const factory AuthEvent.signUpBuyer(BuyerEntity entity) = SignUpBuyer;
}
Run Code Online (Sandbox Code Playgroud)
和状态类:
part of 'auth_bloc.dart';
@freezed
abstract class AuthState with _$AuthState {
const factory AuthState.initial() = InitialAuthState;
const factory AuthState.signUpBuyerFail(String …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用graphql-flutter库创建来自 GraphQL API 的元素的 ListView 。
第一页的构建正常。然后当我开始滚动时,结果会很好,我的 ListView 显示第二页,然后第三页等......正确。
问题是,从第二个页面加载开始,就出现了问题。FetchMore 函数似乎在每个页面加载时构建多个请求。就像之前加载的所有页面都再次加载一样,越来越多。
奇怪的是,正如我所说,显示列表的结果在几个页面中都是正确的,然后突然列表从上一页循环回来,然后继续继续......
这是我的查询小部件:
Query(
options: QueryOptions(
document: gql(getHistory),
variables: <String, dynamic>{
'pubkey': this.pubkey,
'number': nRepositories,
'cursor': null
},
),
builder: (QueryResult result, {refetch, FetchMore fetchMore}) {
if (result.isLoading && result.data == null) {
return const Center(
child: CircularProgressIndicator(),
);
}
if (result.hasException) {
return Text('\nErrors: \n ' + result.exception.toString());
}
if (result.data == null && result.exception.toString() == null) {
return const Text('Both data and errors are null');
}
final …Run Code Online (Sandbox Code Playgroud)