我一直在尝试在我的应用程序中实现一个搜索栏,以将选定的listView项目带到列表的顶部。该列表包含许多项,大约1700左右,因此添加搜索栏是必不可少的。我希望listView搜索框从search顶部右侧的图标出现appBar。下面是当前视图的图片,以供参考。
单击搜索时iconButton,搜索字段应替换中的标题appBar。对于用户来说,这显然是加密的,listView因为我将在搜索视图中添加一个标识此内容的提示。
我不包括我的所有代码,因为这对于堆栈问题会很麻烦,但是下面是我的home_page.dart文件,在这里,我的底层密码的其他类listView都可以在此GitHub存储库中找到。
这就是我的“ home_page.dart”样子。
import 'package:cryptick/cryptoData/crypto_data.dart';
import 'package:cryptick/cryptoData/trending_data.dart';
import 'package:cryptick/modules/crypto_presenter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'background.dart';
//FOLLOWING DART CODE COPYRIGHT OF 2017 - 2018 SQUARED SOFTWARE LONDON
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => new _HomePageState();
}
class ServerStatusScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
iconTheme: new IconThemeData(color: Colors.white), …Run Code Online (Sandbox Code Playgroud) 自 诞生以来发生了很大的变化google_maps_flutter,这意味着删除单个标记的过程也发生了变化。
我在这个问题的旧查询中发现的内容是,删除版本 ~ 0.0.1 上的标记是这样的:
mapController.markers.forEach((marker){
mapController.removeMarker(marker);
});
Run Code Online (Sandbox Code Playgroud)
这对我不起作用,因为我收到错误:
The getter 'markers' isn't defined for the class 'GoogleMapController'.
和
The method 'removeMarker' isn't defined for the class 'GoogleMapController'.
这就是我用来添加标记的内容:
void _addMarker(LatLng latlang, String title) {
var _width = MediaQuery.of(context).size.width;
var _height = MediaQuery.of(context).size.height;
double _topHeight = 55;
if (_height == 896.0 && _width == 414.0) {
_topHeight = 83;
} else if (_height == 812.0 && _width == 375.0) {
_topHeight = 78;
}
double …Run Code Online (Sandbox Code Playgroud) 我目前正在创建一个跟踪一般加密数据的应用程序,除了这些数据,我们还发布了为加密爱好者量身定制的新闻文章。此新闻文章数据的每个方面都以字符串形式存储,从图像 url 到发布日期 -完整列表如下。
我正在寻找一种将这些数据保存到用户设备的方法。在完美的情况下,我只是将这些数据保存在 JSON 数组中,但除了不知道如何执行此操作之外,我不确定这是否是保存这些数据以供以后显示的最有效方法。
如果您认为 JSON 将是保存这些数据的最佳方式,那么我需要知道的是如何将这些数据正确管理到一系列不同的已保存文章中,以及如何将其正确导入我的 Dart 代码中。
这段代码的一个例子会很棒,我希望在新的一年之前发布这个应用程序,所以我需要我能得到的所有帮助。非常感谢。
这是我希望从此来源保存/显示的上述数据:
sourceauthordescriptionpublishedAttitleurlurlToImage编辑:尝试修改 shadowsheep 的答案以适应索引模型
每个新闻小部件都是一个新小部件inkwell,允许scaffold构建新小部件。从此,scaffold您将看到保存文章的选项。在储蓄,代码目前只是改变与下列字符串值title,description,URL和Image URL。
_sTitle_sDescription_sURL_sURLtoImage我真的很想要一种将数据库保存到用户设备的方法,如 shadowsheep 所述。这意味着尽管用户关闭和打开应用程序,已保存的文章仍将在设备上持久存在。
以下代码是我显示新闻数据的确切用例。
CarouselSlider(
items: [1,2,3,4,5,6,7,8,9,10].map((index) {
return Builder(
builder: (BuildContext context) {
return Padding(
padding: …Run Code Online (Sandbox Code Playgroud) 我是Flutter/Dart的新手,所以可能没有使用所有正确的关键词,但我遇到了一个问题,我在类'FirstPageState'扩展State 下获得了一条红线.这使我无法调试应用程序,所以我来到这里希望得到一个解决方案!
这是我的'FirstPage.dart'代码
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
String _FirstPageText = 'Exchange Rates';
class First extends StatefulWidget {
// This widget is the root of your application.
@override
FirstPageState createState() => new FirstPageState();
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text(_FirstPageText),
centerTitle: true,
backgroundColor: Colors.black,
),
body: new FeedWidget(),
),
);
}
}
class FirstPageState extends State<First> {
Future<String> getData() async {
var response = await http.get( …Run Code Online (Sandbox Code Playgroud) 添加 path_provider 依赖项后,我遇到了一些未定义类的问题。“目录”和“文件”未定义,问题发生在我尝试在 pubspec.yaml 中为我的项目实现 path_provider 之后。这是在图标按钮按下时将字符串添加到文本文件所需要的。
进口:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:cryptick/data/crypto_data.dart';
import 'package:cryptick/modules/crypto_presenter.dart';
import 'package:shimmer/shimmer.dart';
import 'dart:async';
import 'package:path_provider/path_provider.dart';
Run Code Online (Sandbox Code Playgroud)
有问题的代码:
ListTile _getListItemUi(Crypto currency, MaterialColor color) {
return new ListTile(
leading: new Image.network("http://cryptoicons.co/32@2x/color/"+currency.symbol.toLowerCase()+"@2x.png"),
title: new Text(currency.name,
style: new TextStyle(fontWeight: FontWeight.bold)),
subtitle:
_getSubtitleText(currency.price_usd, currency.percent_change_1h),
isThreeLine: true,
trailing: new IconButton(
icon: new Icon(Icons.add),
onPressed: () async { Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;
new File('$appDocPath/my_file.txt').writeAsStringSync('myVar: $_currencies');
}
),
);
}
Run Code Online (Sandbox Code Playgroud)
这些是显示错误的两行:
onPressed: () async { Directory appDocDir …Run Code Online (Sandbox Code Playgroud)