Projek Mobile Computing Dengan Flutter ke 18
Coding Pada file main.dart
import 'package:flutter/material.dart';
import '../widget/soal_18.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
canvasColor: Colors.white,
),
home: Soal18(),
);
}
}
Coding Pada file soal_18.dart
import 'package:flutter/material.dart';
class Soal18 extends StatelessWidget {
const Soal18({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: FlutterLogo(),
title: Text("Text Judul"),
centerTitle: false,
actions: [
IconButton(
onPressed: () {
print("KLIK MORE");
},
icon: Icon(Icons.more_vert),
),
],
),
body: ListView.builder(
padding: EdgeInsets.all(20),
itemCount: 50,
itemBuilder: (context, index) {
if (index % 2 == 0) {
return Padding(
padding: const EdgeInsets.only(bottom: 25),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 150,
color: Colors.blue,
),
SizedBox(height: 10),
Text(
"Hello ${index + 1}",
style: TextStyle(
fontSize: 25,
),
),
],
),
);
} else {
return Padding(
padding: const EdgeInsets.only(bottom: 25),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 150,
color: Colors.amber,
),
SizedBox(height: 10),
Text(
"Hello ${index + 1}",
style: TextStyle(
fontSize: 25,
),
),
],
),
);
}
},
),
);
}
}
Hasil Running
Post a Comment