coding
coding
dart
import 'package:flutter/material.dart';
import 'home.dart';
import 'setting.dart';
void main() {
runApp(MyApp());
}
@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';
@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';
@override
_SettingPageState createState() => _SettingPageState();
}
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