membuat app mobile sederhana
Membuat app mobile sederhana
1.membuat tampilan sederhana
-appbar dengan judul
-body berisi column
-minimal 3 widget text
dengan kode:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Latihan'),
backgroundColor: Colors.blue,
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 20),
const Text(
'Text Pertama',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 20),
const Text(
'Text Kedua',
style: TextStyle(
fontSize: 18,
color: Colors.blue,
),
),
const SizedBox(height: 20),
const Text(
'Text Ketiga',
style: TextStyle(
fontSize: 16,
fontStyle: FontStyle.italic,
),
),
],
),
),
);
}
}
2.Eksperimen
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Latihan'),
backgroundColor: Colors.deepPurple, // Warna berubah
),
body: Padding(
padding: const EdgeInsets.all(30.0), // Padding lebih besar
child: Row(
children: [
const SizedBox(width: 10), // SizedBox pertama
const Text('Text 1'),
const SizedBox(width: 30), // SizedBox besar
const Text('Text 2'),
const SizedBox(width: 30), // SizedBox besar
const Text('Text 3'),
const SizedBox(width: 10), // SizedBox terakhir
],
),
),
);
}
}


Komentar
Posting Komentar