flex_with_main_child 0.2.1 copy "flex_with_main_child: ^0.2.1" to clipboard
flex_with_main_child: ^0.2.1 copied to clipboard

A Flex (i.e. Column or Row) that sizes itself to its main child in the cross axis direction.

example/lib/main.dart

import 'package:flex_with_main_child/flex_with_main_child.dart';
import 'package:flutter/widgets.dart';

void main() {
  runApp(const Example());
}

class Example extends StatelessWidget {
  const Example({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    final mainChildKey = GlobalKey();

    return Directionality(
      textDirection: TextDirection.ltr,
      child: Center(
        // without Center, ColumnWithMainChild would have to be the same size of
        // the screen, making it useless.
        child: ColumnWithMainChild(
          // ColumnWithMainChild have the same parameters as Column
          mainAxisAlignment: MainAxisAlignment.center,
          // except children, obviously.
          children: [
            // Because the underlying implementation uses Flex, any child that work
            // in Column will work exactly the same way in ColumnWithMainChild.
            const Spacer(flex: 5),
            const Text('very very very very long description'),
            const Spacer(),
            Text(
              'short Title',
              key: mainChildKey,
            ),
            const Spacer(),
            const Text('another very very very very very long text'),
            const Spacer(flex: 10),
          ],
          mainChildKey: mainChildKey,
        ),
      ),
    );
  }
}
7
likes
140
pub points
71%
popularity

Publisher

unverified uploader

A Flex (i.e. Column or Row) that sizes itself to its main child in the cross axis direction.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on flex_with_main_child