,
title: const Text('Search a city'),
),
body: Padding(
padding: const EdgeInsets.all(16),
child: Form(
key: _formKey,
child: Column(
children: [
TextFormField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Enter a city',
hintText: 'Enter a city',
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a city';
} else if (value.length < 3) {
return 'Please enter at least 3 characters';
}
return null;
},
onSaved: (value) {
_city = value;
},
),
ElevatedButton(
onPressed: () => _submit(context),
child: const Text('GET WEATHER'),
),
],
),
),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:weather_app/logic/cubits/settings/settings_cubit.dart';
class SettingsScreen extends StatelessWidget {
const SettingsScreen({Key? key}) : super(key: key);
static const routeName = '/settings';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('Settings'),
),
body: ListTile(
title: const Text(
'Temperature unit',
),
subtitle: const Text('Celsius / Fahrenheit (default: Celsius'),
trailing: Switch.adaptive(
value:
context.watch().state.tempUnit == TempUnits.celsius
? true
: false,
onChanged: (value) {
context.read().toggleTemperature()
Do'stlaringiz bilan baham: |