'how can i change bool variable using Flutter Riverpod

i am new to Flutter Riverpod management

i have stfl widget using Flutter Riverpod management, i need to change the test bool varible to true but cannot handle it

final testProvider = StateProvider<bool>((ref) => false);

`class FriendsList extends ConsumerStatefulWidget {


  const FriendsList({Key? key}) : super(key: key);

  @override
  _FriendsListState createState() => _FriendsListState();



}

class _FriendsListState extends ConsumerState<FriendsList> {







 @override
 Widget build(BuildContext context) {
 bool test = ref.watch(testProvider);
        return Stack( //edit
    children [
    !test ? Text('bool varible is false')
                         :  Text('bool varible is true')
     FutureBuilder(
           future: FirebaseFirestore.instance.collection('users')
                      .doc('userId').get(),
            builder: (context, AsyncSnapshot snapshot) {
               if(!snapshot.hasData){
                     return Text('');
                  }else{ 
                    
                        ref.read(testProvider.state).state = true;
                   }  
               return snapshot.data['name'];

i have no idea how to handle this . also i am not sure of my code if it right , and how to dispose it if it need to



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source