import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class LanguageChangeController with ChangeNotifier { Locale? _appLocale; Locale? get appLocale => _appLocale; Future changeLanguage(Locale type) async { SharedPreferences sp = await SharedPreferences.getInstance(); //print(type); if (type == const Locale('en')) { _appLocale = type; await sp.setString('locale', 'en'); } if (type == const Locale('ml')) { _appLocale = type; await sp.setString('locale', 'ml'); } notifyListeners(); } }