by @kodeazy

How to divide row elements into n equal parts in flutter?

Home » flutter » How to divide row elements into n equal parts in flutter?
  • To divide flutter row elements into n equal parts follow below steps.
  • using Spacer we can divide the elements with equal distance inside a row.
  • Below is the syntax of the function.
  • Spacer()
  • Below is the example code on how to set equal spaces between n elements in a row.

    import 'package:flutter/material.dart';
    void main() {
    runApp(MyApp());
    }
    class MyApp extends StatelessWidget {
    Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Elements Equal Space',
        home: Scaffold(
          body: Row(children: [
            Text("data1"),
            Spacer(),
            Text("data2"),
            Spacer(),
            Text("data3"),
          ]),
        ));
    }
    }

    Output: flutter Elements Equal Space