import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:wetter/components/locations/add_location_form.dart'; class Locations extends StatefulWidget { const Locations({super.key}); @override State createState() => _LocationsState(); } class _LocationsState extends State { late final SharedPreferences? prefs; @override void initState() { SharedPreferences.getInstance().then((value) => prefs = value); super.initState(); } Future initializePreferences() async { prefs = await SharedPreferences.getInstance(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Locations'), ), body: Padding( padding: const EdgeInsets.all(20), child: AddLocationsForm(prefs!), )); } }