apiurl.dart 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import '../controller.dart';
  4. class _SetApiUrl extends StatefulWidget {
  5. @override
  6. _SetApiUrlState createState() => _SetApiUrlState();
  7. }
  8. class _SetApiUrlState extends State<_SetApiUrl> {
  9. String apiUrl;
  10. Controller controller = Get.find();
  11. @override
  12. Widget build(BuildContext context) {
  13. if (controller == null) {
  14. return null;
  15. }
  16. return Dialog(child: Column(
  17. children: <Widget>[
  18. Text('Current value: ${controller.apiUrl}'),
  19. TextField(
  20. onChanged: (newValue) {
  21. this.apiUrl = newValue;
  22. },
  23. decoration: InputDecoration(
  24. border: InputBorder.none,
  25. hintText: 'Set API URL',
  26. ),
  27. ),
  28. TextButton(
  29. child: Text('Set'),
  30. onPressed: () {
  31. controller.setApiUrl(apiUrl);
  32. Navigator.pop(context);
  33. },
  34. ),
  35. ],
  36. ));
  37. }
  38. }
  39. Widget widgetBuilderSetApiUrl(BuildContext context) {
  40. return _SetApiUrl();
  41. }