Флаттер: объедините 2 объекта класса - PullRequest
0 голосов
/ 03 мая 2020

У меня есть 2 переменные класса, обе являются объектами BoxDecoration класса.

var buttonDownOuter = BoxDecoration(
boxShadow: [
  BoxShadow(
    color: Color.fromRGBO(55, 84, 170, 0.1),
    blurRadius: 8, // has the effect of softening the shadow
    offset: Offset(
      6, // horizontal, move right 10
      6, // vertical, move down 10
    ),
  ),
  BoxShadow(
    color: Color.fromRGBO(255, 255, 255, 0.69),
    blurRadius: 10, // has the effect of softening the shadow
    offset: Offset(
      -4, // horizontal, move right 10
      -4, // vertical, move down 10
    ),
  ),
],
borderRadius: BorderRadius.circular(26),
);

и,

var baseBack = BoxDecoration(
gradient: LinearGradient(
    begin: Alignment.topCenter,
    end: Alignment.bottomCenter,
    colors: [
  const Color(0xFFE2E8F0),
  const Color(0xFFD0D6DE),
]));

Как я могу объединить эти buttonDownOuter и baseBack применить к оформлению контейнера?

Кроме того, гипотетически, если у них были конфликтующие наследства, как я могу их объединить?

1 Ответ

0 голосов
/ 03 мая 2020

Вы можете объединить все свойства украшения:

Container(
          height: 100,
          width: 200,
          decoration: BoxDecoration(
            // box shadow here
            boxShadow: [
              BoxShadow(
                color: Color.fromRGBO(55, 84, 170, 0.1),
                blurRadius: 8, // has the effect of softening the shadow
                offset: Offset(
                  6, // horizontal, move right 10
                  6, // vertical, move down 10
                ),
              ),
              BoxShadow(
                color: Color.fromRGBO(255, 255, 255, 0.69),
                blurRadius: 10, // has the effect of softening the shadow
                offset: Offset(
                  -4, // horizontal, move right 10
                  -4, // vertical, move down 10
                ),
              ),
            ],
            // border radius here
            borderRadius: BorderRadius.circular(26),
            // gradient here
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              colors: [
                const Color(0xFFE2E8F0),
                const Color(0xFFD0D6DE),
              ],
            ),
          ),
        ),

Вывод: Output

Надеюсь, это поможет

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...