Nama : Onis Alamsyah
Nim : 2201010222
Kelas : D
TUGAS 1
import 'package:flutter/material.dart';
class RowExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Row Tugas 1"),
),
body: Padding(
padding: const EdgeInsets.only(top: 20),
child: Row(
children: <Widget>[
Container(
color: Colors.blue,
height: 100,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Kolom 1', style: TextStyle(color: Colors.white)),
],
),
),
Container(
color: Colors.yellow,
height: 100,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Kolom 2', style: TextStyle(color: Colors.white)),
],
),
),
Container(
color: Colors.green,
height: 100,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Kolom 3', style: TextStyle(color: Colors.white)),
],
),
),
],
),
),
);
}
}
TUGAS 2
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: WidgetExample(),
));
}
class WidgetExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Widget'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Wrap Widget Example
Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: List.generate(
12,
(index) => Container(
padding: EdgeInsets.all(8.0),
color: Color.fromARGB(255, 236, 240, 7),
child: Container(
height: 100,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Wrap Widget $index', style: TextStyle(color:
Colors.white)),
],
)),
),
),
),
SizedBox(height: 16.0),
// Expand Widget Example
Expanded(
child: Container(
color: Color.fromARGB(255, 186, 226, 53),
child: Center(
child: Text(
'Expanded Widget',
style: TextStyle(color: Colors.white),
),
),
),
),
SizedBox(height: 16.0),
// Stack Widget Example
Stack(
alignment: Alignment.center,
children: [
Positioned(
child: Container(
width: 200,
height: 200,
color: Color.fromARGB(255, 113, 170, 15),
),
),
Positioned(
child: Container(
width: 150,
height: 150,
color: Color.fromARGB(255, 124, 202, 64),
),
),
Positioned(
child: Container(
width: 100,
height: 100,
color: Color.fromARGB(255, 207, 250, 120),
),
),
Positioned(
child: Text(
'Stack Widget',
style: TextStyle(color: Colors.white),
),
),
],
),
],
),
),
);
}
}