The Sample and Simple Provider using in flutter
Provider Class import 'package:flutter/widgets.dart'; import 'package:provider/provider.dart';
//Create Provider class class NameProvider extends ChangeNotifier { var name = '';
nameChange(String changeValue) { name = changeValue; notifyListeners(); } }
Main.dart:
use Multi Provider MultiProvider( providers: [ ChangeNotifierProvider(create: ((context) => NameProvider())) ], child: const MyApp(), ),
first Page: import 'package:git1/Provider/name_provider.dart'; import 'package:provider/provider.dart';
NameProvider firstnameProvider = Provider.of(context, listen: true); firstName.text = firstnameProvider.name;
Second Page import 'package:git1/Provider/name_provider.dart'; import 'package:provider/provider.dart';
NameProvider secondnameProvider = Provider.of(context, listen: true); secondName.text = secondnameProvider.name;