Flutter插件flutter_in的特性与使用方法介绍

Flutter插件flutter_in的特性与使用方法介绍

Flutter插件flutter_in的特性

你是否厌倦了在Column中反复书写常见的小部件组合,比如Expanded
我也有同样的感受!希望这个包能帮助到你 😊


Flutter插件flutter_in的使用方法

示例:在Row中使用Expanded来填充可用宽度

旧方法 🧐
class SomeWidget extends StatelessWidget {
  const SomeWidget({Key? key}): super(key: key);

  [@override](/user/override)
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          children: [
            Expanded(
              child: OutlinedButton(
                onPressed: () {
                  print(':)');
                },
                child: const Text('A button taking up all horizontal space'),
              ),
            ),
          ],
        ),
      ],
    );
  }
}
新方法 😎

通过引入flutter_in包,我们可以简化代码:

import 'package:flutter_in/flutter_in.dart';

class SomeWidget extends StatelessWidget {
  const SomeWidget({Key? key}): super(key: key);
  
  [@override](/user/override)
  Widget build(BuildContext context) {
    return Column(
      children: [
        // 使用 ExpandedInRow 替代 Expanded 和 Row 的组合
        ExpandedInRow(
          child: OutlinedButton(
            onPressed: () {
              print(':)');
            },
            child: const Text('A button taking up all horizontal space')
          ),
        ),
      ],
    );
  }
}

更多关于Flutter插件flutter_in的特性与使用方法介绍的实战教程也可以访问 https://www.itying.com/category-92-b0.html

回到顶部