Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
135 views
in Technique[技术] by (71.8m points)

android - Using a Text Widget on the "trailing" property is not shown in the GridTileBar Widget but the Icon Widget is does

Hello Everyone!

Here I am working on a small project which is a gallery application, I managed to display the album along with its thumbnail.

I also want to display the name and total files of the album that I have got from my local gallery with the GridTileBar which the album name is on the left and the total files are on the right,

for my left I managed to display the album name using the title property but, for the right one which is the total file, I can't display it using the trailing property and strangely when I try to display the Icon Widget, the icon appears and is right beside the album name that I have displayed.

Result from flutter doctor

[?] Flutter (Channel stable, 1.22.5, on Linux, locale en_US.UTF-8)
 
[?] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[!] Android Studio (not installed)
[?] Connected device (1 available)

! Doctor found issues in 1 category.

Tools

Debugging on My actual device which is Xiaomi Redmi 1S Android 7.1 Nougat 

Expectation

expectation

Reality

reality

Code album_card.dart

import 'dart:io';

import "package:flutter/material.dart";

class AlbumCard extends StatelessWidget {
  AlbumCard(
      {@required this.albumName, this.thumbnail, this.totalFiles, this.isOdd});

  final String albumName;
  final int totalFiles;
  final File thumbnail;
  final bool isOdd;

  @override
  Widget build(BuildContext context) {
    return Card(
        margin: EdgeInsets.all(0),
        clipBehavior: Clip.antiAliasWithSaveLayer,
        child: GridTile(
          child: Image.file(
            thumbnail,
            fit: BoxFit.cover,
          ),
          footer: GridTileBar(
            backgroundColor: Colors.black45,
            title: Text('$albumName'),

            // Won't work if displaying a Text Widget but Work if it's an Icon Widget
            trailing: Text('$totalFiles'),
          ),
        ));
  }
}
question from:https://stackoverflow.com/questions/65641414/using-a-text-widget-on-the-trailing-property-is-not-shown-in-the-gridtilebar-w

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...