Skip to content

Instantly share code, notes, and snippets.

@budasuyasa
Created April 9, 2024 07:19
Show Gist options
  • Save budasuyasa/3a4a91c1ed16a1ba3bd5e51f1f850470 to your computer and use it in GitHub Desktop.
Save budasuyasa/3a4a91c1ed16a1ba3bd5e51f1f850470 to your computer and use it in GitHub Desktop.
Belajar Flutter Layout
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
// home: Container(
// color: Colors.blue[200],
// width: 50,
// height: 90,
// padding: const EdgeInsets.all(20.0),
// child: Container(
// child: const Text('Hello World',
// style: TextStyle(
// color: Colors.white, decoration: TextDecoration.lineThrough)),
// color: Colors.red,
// )
// )
home: Column(
children: [
Container(
child: Text('K1', style: TextStyle(fontSize: 30.0, color: Colors.white)),
margin: const EdgeInsets.all(20),
width: 50,
),
Container(
child: Text(
'K2',
style: TextStyle(
fontSize: 30.0,
color: Colors.white
)
),
margin: const EdgeInsets.all(20),
width: 50,
),
Container(
child: Text('K3', style: TextStyle(fontSize: 30.0, color: Colors.white)),
margin: const EdgeInsets.all(20),
width: 50,
),
],
));
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment