Files

80 lines
2.3 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../../providers/labels.dart';
class LabelSearchBox extends StatelessWidget {
const LabelSearchBox({
Key? key,
required this.searchCTRL,
required double deviceBlockSize,
}) : _deviceBlockSize = deviceBlockSize,
super(key: key);
final TextEditingController searchCTRL;
final double _deviceBlockSize;
@override
Widget build(BuildContext context) {
var searchVal;
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: 3,
),
Expanded(
child: TextField(
onEditingComplete: () {
FocusScope.of(context).unfocus();
},
controller: searchCTRL,
onChanged: (value) async {
searchVal = value;
},
decoration: InputDecoration(
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Search by package name',
isDense: true,
contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.number,
),
),
InkWell(
onTap: () async {
var labels =
await Provider.of<LabelsProvider>(context, listen: false);
labels.setLoading();
await labels.search(searchVal);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
margin: EdgeInsets.only(left: 5),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Center(
child: Icon(
Icons.search,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
),
),
],
);
}
}