import 'package:flutter/material.dart'; import 'package:gettext_i18n/gettext_i18n.dart'; import '../model/operating_system.dart'; class OperatingSystemSelection extends StatefulWidget { const OperatingSystemSelection({Key? key}) : super(key: key); @override State createState() => _OperatingSystemSelectionState(); } class _OperatingSystemSelectionState extends State { var term = ""; final focusNode = FocusNode(); @override void initState() { focusNode.requestFocus(); super.initState(); } @override Widget build(BuildContext context) { var list = gOperatingSystems.where((os) => os.name.toLowerCase().contains(term.toLowerCase())).toList(); return Scaffold( appBar: AppBar( title: Text(context.t('Select operating system')), bottom: PreferredSize( preferredSize: const Size.fromHeight(kToolbarHeight), child: Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( color: Theme.of(context).canvasColor, ), child: Padding( padding: const EdgeInsets.all(8), child: Material( child: Row( mainAxisSize: MainAxisSize.min, children: [ const Icon(Icons.search), Expanded( child: TextField( focusNode: focusNode, decoration: InputDecoration.collapsed(hintText: context.t('Search operating system')), onChanged: (value) { setState(() { term = value; }); }, ), ), ], ), ), ), ), ), ), ), body: SingleChildScrollView( child: Column( children: [ ListView.builder( padding: const EdgeInsets.only(top: 4), shrinkWrap: true, itemCount: list.length, itemBuilder: (context, index) { var item = list[index]; return Card( child: ListTile( title: Text(item.name), onTap: () { Navigator.of(context).pop(item); }, ), ); }, ), ], ), ), ); } }