小编Sid*_*kar的帖子

如何在颤动中设置滚动条颜色?

我有一个ListViewScrollbar类包裹的法线,以在向下滚动时产生滚动条。但是我想将Scrollbar颜色更改为白色,因为我的背景是深色的。

在探索了这个Scrollbar类之后,我可以看到它使用了highlightColor里面显示的主题scrollbar.dart

_themeColor = theme.highlightColor.withOpacity(1.0);

尝试将 包裹Scrollbar在 a 中,Theme但仍然没有运气。

下面是我的代码 -

Theme(
  data: ThemeData(
    highlightColor: Colors.white, //Does not work
  ),
  child: Scrollbar(
    child: ListView(
      //Normal ListView code
    ),
  ),
)
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏。提前致谢。

android dart flutter flutter-layout

18
推荐指数
4
解决办法
9498
查看次数

如何使用 Google Maps For Flutter 将初始相机位置设置为当前设备的纬度和经度

我正在为我的应用程序使用 google maps flutter 插件。我希望初始相机位置目标(LatLng)与当前设备的纬度和经度完全相等,以便相机在启动时显示用户当前所在的位置。但是,我在尝试执行此操作时遇到了问题。我曾尝试使用 Location 和 Geolocator 包,但没有关于如何做我想要实现的目标的明确示例。

当我尝试使用currentLocation.latitudecurrentLocation.longitude位置包作为相机目标中 Latlng 的值时,我遇到了以下错误。

“初始化器只能访问静态成员”

坦率地说,我不知道在这种情况下这意味着什么。我已经阅读了一些示例,但没有一个清楚地实现我真正想要实现的目标

import 'package:flutter/cupertino.dart';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:location/location.dart';


class Map extends StatefulWidget {
  @override
  State<Map> createState() => MapState();
}

class MapState extends State<Map> {
  Completer<GoogleMapController> _controller = Completer();
  var currentLocation = LocationData;

  var location = new Location();

 Future _getLocation() async {
    try {
      location.onLocationChanged().listen((LocationData currentLocation) {
        print('Latitude:${currentLocation.latitude}');
        print('Longitude:${currentLocation.longitude}');
        return LatLng(currentLocation.latitude, currentLocation.longitude);
      });
    } catch (e) {
     print('ERROR:$e');
      currentLocation = null; …
Run Code Online (Sandbox Code Playgroud)

google-maps flutter

15
推荐指数
2
解决办法
2万
查看次数

如何修复导致的错误:pub get failed(69)

我在运行 Flutter 应用程序时遇到问题。

酒吧失败(69)

我尝试过使用firebase_storage: anyfirebase_storage: ^1.0.4

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  firebase_auth: ^0.8.1+2
  firebase_database: ^0.4.6
  firbase_storage: any
  firebase_core: any
  intl: ^0.15.7
  image_picker:



dev_dependencies:
   flutter_test:
    sdk: flutter
Run Code Online (Sandbox Code Playgroud)

我预计输出会收到退出代码 0,但它却告诉我 pub 失败 (69)

dart dart-pub flutter flutter-test

4
推荐指数
1
解决办法
9006
查看次数

如何在 Flutter 中更改 DataColumn 的背景颜色?

我有一个DataTable小部件,用于以表格格式显示一些数据。我找不到任何方法来更改 的背景颜色DataColumn,它默认为白色。

我尝试将label内部包裹起来,Container但这无济于事,因为容器采用了孩子的尺寸。

有没有更简单的方法来设置“DataColum”的背景颜色?

以下是一些参考代码 -

DataTable(
  dataRowHeight: 70,
  headingRowHeight: 60,
  rows: List.generate(4, (index) {
    return DataRow(
      cells: <DataCell>[
        DataCell(
          Text("Number",),
        ),
        DataCell(
          Text(
          "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
          ),
        ),
      ]
    );
  }),
  columns: [
    DataColumn(
      label: Text("Name"),
    ),
    DataColumn(
      label: Text("Description"),
    ),
  ],
)
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

4
推荐指数
1
解决办法
7105
查看次数

Flutter ListView.builder 移除元素不更新列表

我有一个 ListView.builder 小部件

void delete(dynamic obj) {
  setState((){
    pc.remove(obj);
  })
}

void update(dynamic obj){}

List pc = List();

@override
void init(){
  super.initState();
  //Fetch data
  setState((){
    pc = data;
  })
}

@override
Widget build(BuildContext context) {
  return Container(
    child: ListView.builder(
      padding: EdgeInsets.only(bottom: 72.0),
      itemCount: pc.length,
      itemBuilder: (context, index) {
        return ListItemWid(
          pc.elementAt(index), delete, update);
      },
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)

这里显示的元素类型是动态的,但实际上是一个固定的对象。现在,当调用 ListItemWid 的删除按钮时,我调用有状态小部件中的删除函数,并执行该函数中的代码,因为该对象已从 db 中删除。但它没有正确反映在视图中。有时,错误的元素被删除,有时根本没有元素被删除。有时它有效。由于限制,我无法发布实际的源代码,但我确实需要帮助来修改 flutter 中列表视图中的元素。颤振库中演示的标准方法不起作用。

只是为了了解更多信息,列表视图显示在一个 PageView 页面内,所有数据都是从当前列表小部件中的 Sqflite 获取和显示的。

请帮忙。

谢谢。

listview dart flutter

1
推荐指数
1
解决办法
4652
查看次数