Solution: Dependency Injection
Explore solutions to the dependency injection challenges.
We'll cover the following...
- Solutions
- Challenge 1: Add the Get package
- Challenge 2: Create the CartController class
- Challenge 3: Provide the CartController to the Get library dependency injector and display the number of items in the cart
- Challenge 4: Display the list of items in the cart and the cart total
- Challenge 5: Remove items in the cart when the user dismisses them
- Challenge 6: Add products to the shopping cart
- Final app
Solutions
Compare your solutions with the ones provided below.
name: ecommerce_appdescription: A new Flutter application.publish_to: 'none' # Remove this line if you wish to publish to pub.devversion: 1.0.0+1environment:sdk: ">=2.12.0 <3.0.0"dependencies:flutter:sdk: flutter# SOLUTION-1: Import the get dependencyget: ^4.6.5dev_dependencies:flutter_lints: ^1.0.4flutter:uses-material-design: true
Challenge 1: Add the Get package
In pubspec.yaml
file, we ...