zoukankan      html  css  js  c++  java
  • Flutter 滚动改变透明度

    import 'package:flutter/cupertino.dart';
    import 'package:flutter/material.dart';
    import 'dart:ui';


    class HomeNavigationBar extends StatefulWidget {
    HomeNavigationBar({ this.sctrollController }) : super();
    ScrollController sctrollController = new ScrollController();

    @override
    _HomeNavigationBar createState() {
    return _HomeNavigationBar();
    }
    }

    class _HomeNavigationBar extends State<HomeNavigationBar> {
    final double _statusBarHeight = MediaQueryData.fromWindow(window).padding.top;
    // 滚动视图
    ScrollController _sctrollController = new ScrollController();
    double _opacity = 0;

    @override
    void initState() {
    // TODO: implement initState
    super.initState();
    setState(() {
    _sctrollController = widget.sctrollController;
    _sctrollController.addListener(() {
    double scrollProportion = _sctrollController.offset / (400 - _statusBarHeight - 44);
    if (scrollProportion > 1) {
    scrollProportion = 1;
    }else if (scrollProportion < 0) {
    scrollProportion = 0;
    }
    setState(() {
    _opacity = scrollProportion;
    });
    });
    });
    }

    @override
    Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    final width = size.width;

    return new Opacity(
    opacity: _opacity,
    child: Container(
    width,
    height: _statusBarHeight + 44,
    color: Colors.white,
    ),
    );
    }
    }
  • 相关阅读:
    baomi
    保密|原创解决您的后顾之忧
    为什么选择我们
    c++实现平面上的形状编辑
    完美售后提供完善修改服务
    冰山理论
    边集数组
    图的存储结构(十字链表、邻接多重表、边集数组) 数据结构和算法58
    邻接多重表
    邻接多重表
  • 原文地址:https://www.cnblogs.com/diweinan/p/13518302.html
Copyright © 2011-2022 走看看