0% found this document useful (0 votes)
4 views

coding

The document contains a Flutter application with three main files: main.dart, home.dart, and setting.dart. The application features a home page with user input fields and a button to navigate to a settings page, which also includes a back button. Both pages display an image and have a consistent layout with an AppBar and centered content.

Uploaded by

nopaa2627
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

coding

The document contains a Flutter application with three main files: main.dart, home.dart, and setting.dart. The application features a home page with user input fields and a button to navigate to a settings page, which also includes a back button. Both pages display an image and have a consistent layout with an AppBar and centered content.

Uploaded by

nopaa2627
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1. File main.

dart

import 'package:flutter/material.dart';
import 'home.dart';
import 'setting.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Pertemuan 7',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
routes: {
'/settings': (context) => SettingPage(),
},
);
}
}

2. File home.dart

import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Card(
child:
Image.asset('assets/stmik.png'),
),
Divider(),
SizedBox(height: 20),
Text(
'TUGAS PERTEMUAN 7',
style: TextStyle(fontSize: 24),
),
SizedBox(height: 20),

Text(
'Welcome to Home',
style: TextStyle(fontSize: 24),
),
SizedBox(height: 20),
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'NAMA : ',
hintText: 'Masukkan Nama Anda',
),
),
SizedBox(height: 20),
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'NIM : ',
hintText: 'Masukkan NIM Anda',
),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.pushNamed(context, '/settings');
},
child: Text('Go to setting'),
),
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.home),
SizedBox(width: 10),
Text('Home'),
],
),
],
),
),
);
}
}

3. File setting.dart

import 'package:flutter/material.dart';

class SettingPage extends StatefulWidget {

@override
_SettingPageState createState() => _SettingPageState();
}

class _SettingPageState extends State<SettingPage> {


@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Setting'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Card(
child:
Image.asset('assets/stmik.png'),
),
Divider(),
SizedBox(height: 20),
Text(
'Setting Page',
style: TextStyle(fontSize: 24),
),

SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Back to Home'),
),
SizedBox(height: 20),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.settings),
SizedBox(width: 10),
Text('Setting'),
],
),
],
),
),
);
}
}
4. TAMPILAN

 TAMPILAN HOME

 TAMPILAN SETTING

You might also like