/*
 * @Author: XianKaiQun
 * @Date: 2020-04-21 10:57:19
 * @LastEditors: XianKaiQun
 * @LastEditTime: 2020-08-27 15:14:28
 * @Descripttion: 
 */

import 'package:flutter/widgets.dart';

///
extension ExtensionWidget on Widget {
  ///在外部套一个Sliver
  SliverToBoxAdapter asSliver() {
    return SliverToBoxAdapter(child: this);
  }

  ///在外部套一个Expanded
  Expanded asExpanded() {
    return Expanded(child: this);
  }

  ///在外部套一个Flexible
  Flexible asFlexible({
    int flex = 1,
    FlexFit fit = FlexFit.loose,
  }) {
    return Flexible(
      flex: flex,
      fit: FlexFit.loose,
      child: this,
    );
  }

  ///外部嵌套一个SliverToBoxAdapter
  SliverToBoxAdapter nestSliverToBoxAdapter() =>
      SliverToBoxAdapter(child: this);

  ///外部嵌套一个Expanded
  Expanded nestExpanded() => Expanded(child: this);

  ///外部嵌套一个Flexible
  Flexible nestFlexible({
    int flex = 1,
    FlexFit fit = FlexFit.loose,
  }) {
    return Flexible(flex: flex, fit: fit, child: this);
  }
}
