Flutter MergeableMaterialItem

简介: 简介 MaterialSlice 和 MaterialGap的基本类型 所有的MergeableMaterialItem对象都需要LocalKey 基础用法 MaterialSlice进行演示 MaterialSlice做为 MergeableMaterial子类。

简介

MaterialSlice 和 MaterialGap的基本类型

  • 所有的MergeableMaterialItem对象都需要LocalKey

基础用法

MaterialSlice进行演示

  • MaterialSlice做为 MergeableMaterial子类。它作为Material,可以和其他的slices合并使用

实例演示


import 'package:flutter/material.dart';

class MergeableMaterialItemDemo extends StatefulWidget {
  _MergeableMaterialItemState createState() => _MergeableMaterialItemState();
}

class _MergeableMaterialItemState extends State<MergeableMaterialItemDemo> {
  final List<MergeableMaterialItem> items = <MergeableMaterialItem>[];
  bool currIndex = false;
  int currIndexNum = 1;

  _isChildExpanded() {
    setState(() {
      currIndex ? currIndex = false : currIndex = true;
      currIndexNum++;
    });
  }

  @override
  Widget build(BuildContext context) {
    items.add(

        //class MaterialSlice extends MergeableMaterialItem
         MaterialSlice(
            key:  ValueKey<int>(currIndexNum),
            child:  Column(children: <Widget>[
              // header,
               AnimatedCrossFade(
                firstChild:  Container(
                  height: 20.0,
                  width: 20.0,
                  color: Colors.green,
                ),
                secondChild:  Container(
                  height: 20.0,
                  width: 20.0,
                  color: Colors.red,
                ),
                crossFadeState: currIndex
                    ? CrossFadeState.showSecond
                    : CrossFadeState.showFirst,
                firstCurve:
                    const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
                secondCurve:
                    const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
                sizeCurve: Curves.fastOutSlowIn,
                duration: Duration(microseconds: 6),
              )
            ])));

    return Column(
      children: <Widget>[
         MergeableMaterial(hasDividers: true, children: items),
         RaisedButton(
          child: Text("点击添加"),
          onPressed: () {
            _isChildExpanded();
          },
        )
      ],
    );
  }
}

目录
相关文章
|
2月前
|
网络架构
一文来带你了解 Flutter MaterialApp
一文来带你了解 Flutter MaterialApp
一文来带你了解 Flutter MaterialApp
|
9月前
|
Dart Android开发 开发者
使用Flutter
使用Flutter
51 0
|
Dart 开发工具 Android开发
Flutter
Flutter 是 Google 开发的一款开源 UI 工具包,它可以帮助开发者使用一套代码库快速构建美观且高性能的 Android 和 iOS 应用程序。Flutter 具有热重载(Hot Reload)和快速应用程序开发(Rapid Application Development)的特点,使得开发过程更加高效。
178 6
|
9月前
Flutter中的OverflowBox、SizedOverflowBox,详细介绍
Flutter中的OverflowBox、SizedOverflowBox,详细介绍 在Flutter中,当一个widget的大小超出了其父widget的大小时,通常会发生溢出现象。为了解决这个问题,Flutter提供了两个widget:OverflowBox和SizedOverflowBox。
282 0
flutter系列之:使用SliverList和SliverGird
在上一篇文章我们讲解SliverAppBar的时候有提到过,Sliver的组件一般都用在CustomScrollView中。除了SliverAppBar之外,我们还可以为CustomScrollView添加List或者Grid来实现更加复杂的组合效果。 今天要向大家介绍的就是SliverList和SliverGird。
flutter系列之:使用SliverList和SliverGird
|
监控 JavaScript 前端开发
使用 Flutter Navigator2.0 最舒服的姿势
使用 Flutter Navigator2.0 最舒服的姿势
337 0
使用 Flutter LinearGradient
使用 Flutter LinearGradient
471 0
使用 Flutter LinearGradient
|
容器
Flutter | Sliver 系列
Flutter | Sliver 系列