import 'package:flutter/material.dart'; import 'package:servermanager/structs/credentials.dart'; class CredentialsPage extends StatefulWidget { @override CredentialsPrompt createState() => CredentialsPrompt(); } // Returns a Credentials Object class CredentialsPrompt extends State { TextEditingController username = TextEditingController(); TextEditingController password = TextEditingController(); bool initialInitDone = false; @override void initState() { final args = ModalRoute.of(context)!.settings.arguments as Credentials?; if (args != null) { if (!initialInitDone) { username.text = args.username; password.text = args.password; initialInitDone = true; } } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Conan Exiles Server Manager - Credentials"), backgroundColor: Color.fromARGB(255, 100, 0, 0), ), floatingActionButton: ElevatedButton( child: Text("Save"), onPressed: () { Navigator.pop( context, Credentials( username: username.text, password: password.text, )); }, ), body: SingleChildScrollView( padding: EdgeInsets.all(16), child: Column( children: [ Row( children: [ SizedBox( width: 150, child: Row( children: [ Icon(Icons.person), Text("Username:"), ], )), Expanded( child: TextField( controller: username, decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(4))), ), ) ], ), SizedBox( height: 16, ), Row( children: [ SizedBox( width: 150, child: Row( children: [ Icon(Icons.key), Text("Password:"), ], )), Expanded( child: TextField( controller: password, keyboardType: TextInputType.visiblePassword, decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(4))), ), ) ], ), ], ))); } }