This commit is contained in:
Imran Remtulla
2023-12-16 01:24:43 -05:00
parent 7413f693d7
commit 2dec52e221

View File

@@ -1,5 +1,3 @@
import 'dart:math';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -38,6 +36,7 @@ class AddAppPageState extends State<AddAppPage> {
bool additionalSettingsValid = true; bool additionalSettingsValid = true;
bool inferAppIdIfOptional = true; bool inferAppIdIfOptional = true;
List<String> pickedCategories = []; List<String> pickedCategories = [];
int urlInputKey = 0;
SourceProvider sourceProvider = SourceProvider(); SourceProvider sourceProvider = SourceProvider();
linkFn(String input) { linkFn(String input) {
@@ -46,16 +45,20 @@ class AddAppPageState extends State<AddAppPage> {
throw UnsupportedURLError(); throw UnsupportedURLError();
} }
sourceProvider.getSource(input); sourceProvider.getSource(input);
changeUserInput(input, true, false); changeUserInput(input, true, false, updateUrlInput: true);
} catch (e) { } catch (e) {
showError(e, context); showError(e, context);
} }
} }
changeUserInput(String input, bool valid, bool isBuilding) { changeUserInput(String input, bool valid, bool isBuilding,
{bool updateUrlInput = false}) {
userInput = input; userInput = input;
if (!isBuilding) { if (!isBuilding) {
setState(() { setState(() {
if (updateUrlInput) {
urlInputKey++;
}
var prevHost = pickedSource?.host; var prevHost = pickedSource?.host;
try { try {
var naturalSource = var naturalSource =
@@ -214,7 +217,7 @@ class AddAppPageState extends State<AddAppPage> {
children: [ children: [
Expanded( Expanded(
child: GeneratedForm( child: GeneratedForm(
key: Key(Random().nextInt(10000).toString()), key: Key(urlInputKey.toString()),
items: [ items: [
[ [
GeneratedFormTextField('appSourceURL', GeneratedFormTextField('appSourceURL',
@@ -334,7 +337,7 @@ class AddAppPageState extends State<AddAppPage> {
); );
}); });
if (selectedUrls != null && selectedUrls.isNotEmpty) { if (selectedUrls != null && selectedUrls.isNotEmpty) {
changeUserInput(selectedUrls[0], true, false); changeUserInput(selectedUrls[0], true, false, updateUrlInput: true);
} }
} }
} catch (e) { } catch (e) {