import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:colorize_logger/colorize_logger.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:ustest/BuildHistoryList.dart'; import 'Services/BuildService.dart'; class BuildView extends StatefulWidget { @override State createState() { // TODO: implement createState return _BuildView(); } } class _BuildView extends State { final platforms = ["Windows", "Linux", "IOS"]; String? selectedPlatform; GlobalKey> platformKey = GlobalKey>(); @override Widget build(BuildContext context) { Future> future = fetchBuildHistories(); GlobalKey listKey = GlobalKey(); return Scaffold( body: Center( child: Column( children: [ Row( children: [ Text( 'Platform:', style: TextStyle(backgroundColor: Colors.lightBlueAccent), textAlign: TextAlign.center, ), SizedBox( width: 136, child: Expanded( child: DropdownButtonFormField( decoration: InputDecoration( hintText: "Select an platform", contentPadding: EdgeInsets.all(0.0)), onChanged: (item) { setState(() => this.selectedPlatform = item); }, key: platformKey, value: selectedPlatform, items: platforms .map((e) => DropdownMenuItem( child: Container( child: Text(e), width: 100, ), value: e, )) .toList(), ), )), TextButton.icon( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.lightBlueAccent)), onPressed: () => onBuild(context), icon: Icon(Icons.rule_rounded), label: Text( "Build", style: TextStyle(color: Colors.white), )), ], ), Row( children: [ TextButton.icon( onPressed: () => setState(() {}), icon: Icon(Icons.search), label: Text("Search")), ], ), Expanded( child: Center( child: FutureBuilder>( key: listKey, future: future, builder: (context, snapshot) { if (snapshot.hasError) { return const Center( child: Text('An error has occurred!'), ); } else if (snapshot.hasData) { return BuildHistoryList( token: "accessToken", histories: snapshot.data!); } else { return const Center( child: CircularProgressIndicator(), ); } }, ), )), ], ), ), ); } Future> fetchBuildHistories() async { try { var service = GetIt.instance.get(); return List.empty(); } catch (ex) { Logger.error('fetchBuildHistories ex:' + ex.toString()); return List.empty(); } } void onBuild(context) { try { var service = GetIt.instance.get(); service.Run(); } catch (ex) { Logger.error("onBuild ex:${ex}"); } } }