73 lines
1.7 KiB
Dart
73 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
void main() => runApp(UbahJadwal());
|
|
|
|
class UbahJadwal extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
home: AlarmApp(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class AlarmApp extends StatefulWidget {
|
|
@override
|
|
_AlarmAppState createState() => _AlarmAppState();
|
|
}
|
|
|
|
class _AlarmAppState extends State<AlarmApp> {
|
|
DateTime _selectedTime = DateTime.now();
|
|
TimeOfDay _selectedAlarmTime = TimeOfDay(hour: 0, minute: 0);
|
|
|
|
void _showTimePicker() async {
|
|
final TimeOfDay? selectedTime = await showTimePicker(
|
|
context: context,
|
|
initialTime: _selectedAlarmTime,
|
|
);
|
|
|
|
if (selectedTime != null) {
|
|
setState(() {
|
|
_selectedAlarmTime = selectedTime;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Text(
|
|
"Waktu Sekarang",
|
|
style: TextStyle(fontSize: 18),
|
|
),
|
|
Text(
|
|
DateFormat('HH:mm:ss').format(_selectedTime),
|
|
style: TextStyle(fontSize: 32),
|
|
),
|
|
SizedBox(height: 20),
|
|
Text(
|
|
"Waktu Alarm",
|
|
style: TextStyle(fontSize: 18),
|
|
),
|
|
Text(
|
|
_selectedAlarmTime.format(context),
|
|
style: TextStyle(fontSize: 32),
|
|
),
|
|
SizedBox(height: 20),
|
|
ElevatedButton(
|
|
onPressed: _showTimePicker,
|
|
child: Text("Atur Alarm"),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|