Managing State in Flutter

Sep 22 2022 · Dart 2.17, Flutter 3.0, Android Studio Chipmunk

Part 2: Use Provider

10. Add a Simple Provider

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 09. Understand Provider Next episode: 11. Use a Change Provider

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Now that you have an understanding of Provider, it’s time to put it to the test. We’re going to create a widget aptly called Provider. This widget provides two important methods, create and dispose.

provider: ^6.0.3
import 'package:provider/provider.dart';
import 'models/pillar.dart';
body: Provider<Pillar>(
    child: const TutorialsPage()),
create: (context) =>
                Pillar(type: PillarType.flutter, articleCount: 115),
import 'package:provider/provider.dart';
import '../models/pillar.dart';
final pillar = Provider.of<Pillar>(context);
children: <Widget>[
  const Center(
    child: TutorialWidget(),
    padding: const EdgeInsets.only(top: 24.0),
    child: Text(
      'Total Tutorials: ${pillar.articleCount}',
      style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
import 'package:provider/provider.dart';
import '../models/pillar.dart';
final pillar = Provider.of<Pillar>(context);
return Stack(
  children: [
      onTap: () {
          Image.asset('assets/images/${pillar.type.imageName}', width: 110, height: 110),
      bottom: 2,
      child: CircleAvatar(
        child: Text(pillar.articleCount.toString()),