小编Kod*_*ata的帖子

列表视图内的Flutter GridView

我想构建像Ios应用商店这样的设计,如下图所示。我想要实现的是有5个顶级类别,每个类别都有显示图像的网格。我尝试过这样。

像这样

return new Scaffold(
  backgroundColor: Colors.white,
  appBar: buildBar(context),
  // wrap in gesture to dismiss keyboard
  body: new GestureDetector(
    behavior: HitTestBehavior.opaque,
    onPanDown: (detail) {
      FocusScope.of(context).requestFocus(new FocusNode());
    },
    child: new ListView(
      shrinkWrap: true,
      children: <Widget>[
        new Container(
          decoration: new BoxDecoration(color: Colors.grey[400]),
          child: new Column(
            children: <Widget>[
              new SizedBox(height: 15.0),
              new Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  new Icon(Icons.invert_colors,
                      color: Colors.red, size: 45.0),
                  new Text('Top 5',
                      style: new TextStyle(
                          color: Colors.white,
                          fontSize: 25.0,
                          fontWeight: FontWeight.bold)),
                ],
              ),
              new SizedBox(height: 15.0),
            ],
          ),
        ),
        new …
Run Code Online (Sandbox Code Playgroud)

flutter

5
推荐指数
4
解决办法
8510
查看次数

Flutter Firestore 日期

我知道这是重复的,但由于我无法找到正确的方法,所以请不要将其标记为重复。我想Firestore在颤振中正确设置日期类型。我尝试过DateTime.now(),但是当我检索它时,错误提示

不支持的值:FIRTimestamp:FIRTimestamp 类型的秒=1533950401 纳秒=81000000>

并且应用程序将崩溃。我也尝试过millisecondsSinceEpoch, microsecondsSinceEpochtoUtc但 Firestore 将它们识别为数字而不是时间戳。我使用了intl包并格式化yyyy-MM-dd hh:mm,但它被识别为字符串。有谁知道如何正确设置时间戳?

flutter google-cloud-firestore

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

Flutter 按时间戳排序 Firebase 快照

我正在尝试按时间戳对快照进行排序,但返回原始顺序。
数据结构看起来像这样 在此处输入图片说明

我有两个快照,时间戳是-1536025466539-1536025893015
所以,我希望-1536025893015在排序后排在第一位。有谁知道如何正确排序?

代码:

Map<dynamic, dynamic> map = snapshot.data?.snapshot?.value;
    map.values.toList().sort((a, b) {
      return a['timestamp'].compareTo(b['timestamp']);
    // also not work return b['timestamp'].compareTo(a['timestamp']);
  });
Run Code Online (Sandbox Code Playgroud)

firebase-realtime-database flutter

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

颤振笔记本电脑最低要求

macbook pro Late2011(ram16GB) 处理 flutter 没有任何问题吗?\n我\xe2\x80\x99m 想买一台笔记本电脑,我想知道这台 mac 是否可以用于 flutter、Xcode 和 android studio。我\xe2\x80\x99m对mac不熟悉。那么有人可以告诉我是否适合去。有最低要求吗?任何帮助表示赞赏!

\n

flutter

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

Firestore 空结果算作已读?

我想知道您是否获取了文件但没有要返回的文件,这算作至少读过一次还是不计入任何不会增加价格的内容?
我一直在寻找,但我找不到答案。
任何帮助表示赞赏。

firebase google-cloud-firestore

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

我需要 Flutter Firebase AdMob 包的哪些 MobileAdTargetingInfo 属性才能发布?

我想知道什么时候使用firebase_admob,我需要这个代码吗?如果是这样,在发布应用程序时,我应该为keywordscontentUrl、 和写什么testDevices?我的意思是,在发布应用程序时,testDevices甚至有必要吗?

  MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
      keywords: <String>['flutterio', 'beautiful apps'],
      contentUrl: 'https://flutter.io',
      birthday: DateTime.now(),
      childDirected: false,
      designedForFamilies: false,
      gender: MobileAdGender.male, // or MobileAdGender.female, MobileAdGender.unknown
      testDevices: <String>[], // Android emulators are considered test devices
    );
Run Code Online (Sandbox Code Playgroud)

flutter firebase-admob

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

列表视图中的颤振包装小部件

我想将列包裹起来,listview以便向下滚动时,搜索栏将消失。我试过这样

new ListView(
   shrinkWrap: true,
    children: <Widget>[
       new Column(
         mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            new GestureDetector(
              child: new Container(
                color: Colors.grey[300],
                child: new Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: new Card(
                    margin: const EdgeInsets.fromLTRB(4.0, 0.0, 4.0, 0.0),
                    child: new ListTile(
                      leading: new Icon(Icons.search),
                      title: new Text('Search',
                          style: new TextStyle(color: Colors.grey[600])),
                    ),
                  ),
                ),
              ),
              onTap: () {
                print(
                    'tapped');
              },
            ),
            new GridView.builder(
              itemCount: items.length,
              gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2),
              itemBuilder: (BuildContext context, int index) {
                return new GestureDetector(
                  child: …
Run Code Online (Sandbox Code Playgroud)

flutter

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

颤动如何生成不重复的随机数

有没有办法生成不重复的随机数?例如,我想生成从 1 到 100 不重复的 50 个随机数,有什么方法可以做到这一点,或者我是否必须在每次输入数字已经创建时进行检查?

dart flutter

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

颤振计算方法

我正在尝试执行重方法compute()
我这样尝试过。后loop执行,Text窗口更新而result返回0按下按钮后,差不多吧。
有人知道我在想什么吗?

 int _counter;

  static int loop(int val) {
    int count = 0;
    for (int i = 1; i <= val; i++) {
      count += i;
    }
    return count;
  }

  Future<void> _onPressed() async {
    int result = await compute(loop, 1000000000000000000);
    setState(() {
      _counter = result;
    });
  }
Run Code Online (Sandbox Code Playgroud)

dart flutter

3
推荐指数
2
解决办法
3098
查看次数

颤动如何填充凸起按钮的渐变颜色?

我正在尝试渲染渐变按钮,但在某些设备上,渐变颜色不会像下图那样展开。

我怎样才能解决这个问题?
谢谢!

代码

class GradientButton extends StatelessWidget {
  final Widget child;
  final VoidCallback onPressed;
  const GradientButton({@required this.child, @required this.onPressed});
  @override
  Widget build(BuildContext context) {
    return RaisedButton(
      textColor: Colors.white,
      shape: StadiumBorder(),
      padding: const EdgeInsets.all(0.0),
      child: Container(
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: <Color>[Color(0xff00F260), Color(0xff0575E6)],
          ),
        ),
        padding: EdgeInsets.all(8.0),
        child: child
        onPressed: onPressed,
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

flutter flutter-web

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