Debug School

rakesh kumar
rakesh kumar

Posted on

Different way of refreshing in flutter

After click button redirect main.dart page

Future<void> logout(BuildContext context) async {
    await secureStorage.delete(key: 'email');
    await secureStorage.delete(key: 'password');
    isLoggedIn = false;
    notifyListeners();

    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('Logged out successfully')),
    );
    Navigator.pushReplacementNamed(context, '/'); // Redirect to main screen
  }
Enter fullscreen mode Exit fullscreen mode

After getting server side response reload dart file

 return buildBaseScreen(
      currentIndex: 0, // Set the appropriate index for the bottom nav bar
      title: 'Publisher',
      body: RefreshIndicator(
        onRefresh: () async {
          await influencerViewModel.fetchInfluencers();
        },
Enter fullscreen mode Exit fullscreen mode
  Future<void> updateInfluencerSelection(String influencerId, String socialKey, bool isSelected, String email) async {
    try {
      await api.updateInfluencerSelection(influencerId, socialKey, isSelected, email);
      print("Selection updated successfully");
      await fetchInfluencers(); // Fetch the updated list of influencers
      notifyListeners(); // Notify listeners after updating the selection
    } catch (e) {
      print("Error updating selection: $e");
    }
  }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)