Projek Mobile Computing Dengan Flutter ke 24
Coding Pada file main.dart
import 'package:flutter/material.dart';
import '../widget/soal_24.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: Soal24(),
);
}
}
Coding Pada file soal_24.dart
import 'package:flutter/material.dart';
class Soal24 extends StatelessWidget {
const Soal24({
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: Column(
children: [
Container(
padding: EdgeInsets.only(
top: 20,
left: 20,
bottom: 20,
),
height: 140,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 20,
itemBuilder: (context, index) {
if (index % 2 == 0) {
return Container(
width: 100,
height: 120,
color: Colors.blue[900],
margin: EdgeInsets.only(right: 20),
);
} else {
return Container(
width: 100,
height: 120,
color: Colors.amber,
margin: EdgeInsets.only(right: 20),
);
}
},
),
),
Expanded(
child: 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