iT邦幫忙

2023 iThome 鐵人賽

DAY 16
0
自我挑戰組

基礎學習Flutter系列 第 16

Day16-學習[Building for iOS with Flutter]子界面小部件(記錄)

  • 分享至 

  • xImage
  •  

使用圖像過濾器,新增磨砂玻璃的效果.
新增數據圖像顯示器,隨拉桿的增加或減少數量,圖像顯示也會改變.
新增按鈕,將數據回傳到日誌

int get numberofServings => int.parse(_servingsTextController,text) ;
int get totalCalories => widget.veggie.caloriesPerServing * numberofServings;
int get totalvitaminA => widget.veggie.vitaminAPercentage * numberofServings;
int get totalvitaminC => widget.veggie.vitaminCPercentage * numberofServings;
Padding(
      padding: EdgeInsets.all(12),
      child: Text('10', style: textheme. bodysmall),
), // Padding
],
),// Row
SizedBox(height: 8),
line(),
QuoteText(text: widget.vegggie.shortDescription),
},
),
Positioned(
  bottom: MediaQuery.of(context).padding.bottom,
  left: 0,
  right: 0,
  child: BlurredBackground(
    intensity: 12,
    color: Color(OxAAF2F2F2),
    child: Padding(
      padding: EdgeInsets.all (16),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Summary(
            calorise: totalCalories,
            vitaminA: totalVitaminA,
            vitaminC: totalVitaminc,
            ],
            Container(
              margin: EdgeInsets.only(top: 8)
              alignment: Alignment.center,
              child: CupertinoButton(
              child: Text ('Add to Log'),
              onPressed: () {
                widget.onEntryCreated(LogEntry(
                  veggield: widget.veggie.id,
                  servings: numberofServings.floor(),
                  timestamp: DateTime.now(),
                  mealType: MealType.values[_mealType],
                )): // LogEntry
                },
               ), //CupertinoButton
              )// Container
            },
          ),
        ),
      ),
    ),
  ],
);

class BlurredBackground extends Statelesswidget {
  const Blurredeackground( sthis.color, this.intensity = 25, this.child});
  
  final Color color;
  final double intensity:
  final Widget child;

@override
Widget build(BuildContext context) {
  return ClipRect(
    filter: ImageFilter.blur(sigmaX: intensity, sigmaY: intensity),
    child: DecoratedBox(
    decoration: BoxDecoration(
      color: color,
    ),
    child: child,
  ),
 ),
 );
 }
 }

上一篇
Day15-學習[Building for iOS with Flutter]子界面小部件(記錄)
下一篇
Day17-學習[Building for iOS with Flutter]子界面小部件(記錄)
系列文
基礎學習Flutter30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言