Flutter Riverpod – AndroidCoding.in

Flutter Riverpod :

In this part of the tutorial we will be covering riverpod implementation in flutter app.We will be going through the easiest way to implement state management in flutter.


pubspec.yaml :

Add the required flutter riverpod with the latest version.

    sdk: flutter

  flutter_riverpod: ^2.3.4



main.dart :

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter/material.dart';

void main()runApp(ProviderScope(child: MyApp()));

final dataProvider = StateNotifierProvider<DataStateNotifier, String>((ref)  return DataStateNotifier(); );

class DataStateNotifier extends StateNotifier<String>
  DataStateNotifier(): super('AmplifyAbhi');

  void dataMessage(String data)
    state = data;

class MyApp extends ConsumerWidget 
  const MyApp(Key? key) : super(key: key);

  Widget build(BuildContext context, WidgetRef ref) 
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("Riverpod"),),
        body: Padding(
          padding: const EdgeInsets.all(24.0),
          child: Column(
            children: [
              const SizedBox(height: 100,),
              Consumer(builder: (context, watch, _)
                final data = ref.watch(dataProvider);
                return Text(data,
                  style: Theme.of(context).textTheme.headlineLarge,);
              const SizedBox(height: 200,),
                onChanged: (newData)
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'Enter a message',


If you have any query’s in this tutorial on flutter riverpod example do let us know in the comment section below.If you like this tutorial do like and share us for more interesting updates.

Next Post

How to Do an SEO Audit in 4 Steps

Now that you know why SEO audits are an essential part of your SEO strategy, let’s move on to the practical aspect—how to do an SEO audit. SEO audits help ensure the success of your website by identifying problems so that you can deploy strategies to solve them. SEO audits […]
How to Do an SEO Audit in 4 Steps