Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

ChangeProviderNotifier update not reflected in Cupertino App tutorial #15

Open
KyruCabading opened this issue May 31, 2019 · 3 comments
Assignees

Comments

@KyruCabading
Copy link

KyruCabading commented May 31, 2019

In the Cupertino App Tutorial Step 5, outdated code is still shown.
See runApp: model: model should be changed to
builder: (context) => AppStateModel()..loadProducts(),
Screen Shot 2019-05-31 at 10 57 37 PM

Following the outdated tutorial, I wasn't sure where to call loadProducts() safely.
Luckily this repo is always updated. Found it by looking at the repo, but it may trip up other people following the tutorial as it will;

  • Not show any error
  • Product Tab List just shows nothing

There was no hint that we need to load products first.

Solution: Update Tutorial Text & Add the "Get the full content on GitHub: lib/model/main.dart." link so people get directed to latest code incase it becomes outdated again.

Thanks!

@aaronmyatt
Copy link

Just ran into the issue myself. Can we contribute updates to the Codelab somewhere?

@domesticmouse
Copy link
Member

/cc @sfshaza2

@crazcdll
Copy link

crazcdll commented Dec 29, 2019

While the ChangeNotifierProvider API changed another time, now we should use create not builder like below.

import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';

import 'app.dart';
import 'model/app_state_model.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);

  return runApp(ChangeNotifierProvider<AppStateModel>(
    create: (context) => AppStateModel()..loadProducts(),
    child: CupertinoStoreApp(),
  ));
}

@domesticmouse domesticmouse self-assigned this Jan 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants