Флаттер Почему ширина контейнера не учитывается?

Для: Хасан А. Эль-Сеуди

Ваш билет закрыт, поэтому я не могу ответить на него ^^ '. Но вы можете попробовать следующее:

'
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int     countChar(char *str)
{
  int   count;
  int   i;

  i = 0;
  count = 0;
  while (str[i] != '=') // our delimiter character
    {
      i++;
      count++;
    }

  return (count);
}

void    split(char *str)
{
  int   i;
  int   j;
  int   count;
  int   restCount;
  char  *str1;
  char  *str2;

  i = 0;
  j = 0;
  count = countChar(str) - 1; // we have our str1 lenght, -1 for the ' '
  restCount = (strlen(str) - count) -1; // we have our str2 legnht, -1 for the ' '
  str1 = malloc(sizeof(char) * count);
  str2 = malloc(sizeof(char) * restCount);

  while(i < count)
    {
      str1[i] = str[i++];
    }
  i = i + 2; // to jump directly to the first char of our str2 (no ' = ')
  while (str[i])
    {
      str2[j++] = str[i++];
    }
  printf("str1 = %s, str2 = %s\n", str1, str2);
}

int     main()
{
  char  *str = "Xo = 100k";

  split(str);

  return (0);
}'
3
задан Robin Dijkhof 16 January 2019 в 21:14
поделиться

1 ответ

Это немного сложно, но именно так работает Флаттер, ваш Container не знает ограничений Родителя, затем он пытается заполнить все доступное пространство.

Вы можете исправить это, добавив Align виджет

    _getCircleImage(String url) {
      return Align(
        alignment: Alignment.centerLeft,
        child: Container(
          width: 64.0,
          height: 64.0,
          decoration: new BoxDecoration(
            image: new DecorationImage(
              image: new NetworkImage(url),
              fit: BoxFit.cover,
            ),
            shape: BoxShape.circle,
          ),
        ),
      );
    }

Дополнительная информация: https://docs.flutter.io/flutter/widgets/Container-class.html

0
ответ дан diegoveloper 16 January 2019 в 21:14
поделиться
Другие вопросы по тегам:

Похожие вопросы: