Home Mobile Apa Perbedaan Property Child dan Children ???

Apa Perbedaan Property Child dan Children ???

0
  1. Child

Child artinya adalah anak berarti widget tersebut hanya bisa memiliki 1 widget di bawahnya.

contoh code child :

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(home: MyHomePage()));
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Property Child"),
      ),
      body: Container(
        child: Text("Assalamu'alaikum Ukhti :)"),
        color: Colors.lightGreen,
        padding: EdgeInsets.all(16.0),
      ),
    );
  }
		}

hasilnya :

2. Children

Children atau anak-anak (jamak) berarti widget tersebut bisa berisi dengan banyak widget.

Contoh code children :

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(home: MyHomePage()));
}
class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Property Children"),
        ),
        body: Column(
          children: <Widget>[
            Container(
              child: Text("Assalamu'alaikum..."),
              color: Colors.orange,
              padding: EdgeInsets.all(16.0),
            ),
            Container(
              child: Text("Warahmatullahi..."),
              color: Colors.green,
              padding: EdgeInsets.all(16.0),
            ),

            Container(
              child: Text("Wabarakatuh..."),
              color: Colors.pink,
              padding: EdgeInsets.all(16.0),
            ),
          ],
        ));
  }
}

hasilnya :