axis_layout 0.3.0 copy "axis_layout: ^0.3.0" to clipboard
axis_layout: ^0.3.0 copied to clipboard

outdated

Horizontal (row) and vertical (column) layout with fill and shrink features.

example/lib/main.dart

import 'package:axis_layout/axis_layout.dart';
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Axis Layout Demo',
      theme: ThemeData(
        scaffoldBackgroundColor: Colors.white,
        primarySwatch: Colors.blue,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  double _width = 200;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Axis Layout Demo'),
        ),
        body: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
          Center(child: SizedBox(width: 400, child: _slider())),
          Center(
              child: Container(
                  decoration: BoxDecoration(
                      border: Border.all(color: Colors.red, width: 4)),
                  child: SizedBox(width: _width, child: _axisLayout())))
        ]));
  }

  Widget _slider() {
    return Slider(
        min: 0,
        max: 400,
        value: _width,
        onChanged: (value) {
          setState(() {
            _width = value;
          });
        });
  }

  Widget _axisLayout() {
    return AxisLayout(axis: Axis.horizontal, children: [
      AxisLayoutChild(
          child: Container(width: 100, height: 50, color: Colors.blue),
          shrink: 1),
      AxisLayoutChild(
          child: Container(width: 100, height: 50, color: Colors.orange)),
      AxisLayoutChild(
          child: Container(height: 50, color: Colors.green), expand: 1)
    ]);
  }

  Widget _row() {
    return Row(children: [
      Container(width: 100, height: 50, color: Colors.blue),
      Container(width: 100, height: 50, color: Colors.orange),
      Expanded(child: Container(height: 50, color: Colors.green))
    ]);
  }
}
3
likes
90
points
506
downloads

Publisher

verified publishercaduandrade.net

Weekly Downloads

Horizontal (row) and vertical (column) layout with fill and shrink features.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on axis_layout