Fakultas Ilmu Komputer UI

Commit 020e73dc authored by Muhammad Farhan Ghaffar's avatar Muhammad Farhan Ghaffar
Browse files

[GREEN] added code for typeahead latar belakang

parent 3a3bda15
Pipeline #78429 passed with stages
in 7 minutes and 28 seconds
import 'package:flutter/material.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:fundex_app/assets/colors.dart';
import 'package:fundex_app/main-screen.dart';
import 'package:fundex_app/pages/kyc/data_identitas.dart';
......@@ -23,6 +24,12 @@ class ValidasiEmail {
}
}
class ValidasiTempat{
static String validate(String value){
return value.isEmpty ? 'Harus di isi.' : null;
}
}
class DataPendukung extends StatefulWidget {
@override
_DataPendukungState createState() => _DataPendukungState();
......@@ -30,6 +37,7 @@ class DataPendukung extends StatefulWidget {
class _DataPendukungState extends State<DataPendukung> {
final GlobalKey<FormState> _formkey = GlobalKey<FormState>();
final TextEditingController _typeAheadController = TextEditingController();
// ignore: unused_field
String _latarBelakang;
......@@ -52,6 +60,7 @@ class _DataPendukungState extends State<DataPendukung> {
bool valueCheckbox = false;
bool _checkBox = false;
var _onPressed;
String dropdownValue;
final notifikasiCheckbox = [
CheckboxNotificationSetting(title: 'Gaji'),
......@@ -99,6 +108,20 @@ class _DataPendukungState extends State<DataPendukung> {
_onPressed = null;
}
List<String> listLatarBelakang(String query) {
List<String> matches = [];
matches.add("SD");
matches.add("SMP");
matches.add("SMA");
matches.add("D3");
matches.add("D4");
matches.add("S1");
matches.add("S2");
matches.add("S3");
matches.add("Lainnya");
matches.retainWhere((s) => s.toLowerCase().contains(query.toLowerCase()));
return matches;
}
return MaterialApp(
home: Scaffold(
......@@ -243,6 +266,34 @@ class _DataPendukungState extends State<DataPendukung> {
style: miniTitleTextStyle(),
),
),
Container(
width: 343,
child: TypeAheadFormField(
key: Key('latarBelakangPend'),
textFieldConfiguration: TextFieldConfiguration(
controller: this._typeAheadController,
decoration: formInputDecoration()
),
suggestionsCallback: (pattern) {
return listLatarBelakang(pattern);
},
itemBuilder: (context, suggestion) {
return ListTile(
title: Text(suggestion),
);
},
transitionBuilder: (context, suggestionsBox, controller) {
return suggestionsBox;
},
onSuggestionSelected: (suggestion) {
this._typeAheadController.text = suggestion;
},
// ignore: missing_return
validator: ValidasiTempat.validate,
onSaved: (value) => this._latarBelakang = value,
),
),
])
],
),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment