This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| onPressed: () { | |
| final _cart = Provider.of<CartProvider>(context); | |
| _cart.addProduct(this.product); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final _cart = Provider.of<CartProvider>(context); | |
| ... | |
| FlatButton( | |
| child: Text( | |
| "${_cart.products.length}", | |
| style: TextStyle(color: Colors.white, fontSize: 20), | |
| ), | |
| onPressed: () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData( | |
| primarySwatch: Colors.blue, | |
| ), | |
| home: ChangeNotifierProvider.value( | |
| value: CartProvider(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CartProvider with ChangeNotifier { | |
| List<Product> products = []; | |
| addProduct(Product product) { | |
| products.add(product); | |
| notifyListeners(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Widget _buildInformationMiddleContainer(BuildContext context) { | |
| return Padding( | |
| padding: EdgeInsets.fromLTRB(0, 4, 0, 4), | |
| child: Text( | |
| this.product.description, | |
| maxLines: 2, | |
| overflow: TextOverflow.ellipsis, | |
| style: TextStyle(color: Colors.grey, fontSize: 12), | |
| ), | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Widget _buildInformationTopContainer(BuildContext context) { | |
| return Container( | |
| child: Row( | |
| children: <Widget>[ | |
| Expanded( | |
| child: Text(this.product.title), | |
| flex: 1, | |
| ), | |
| Expanded( | |
| child: ListView.builder( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Column( | |
| children: <Widget>[ | |
| _buildInformationTopContainer(context), | |
| _buildInformationMiddleContainer(context), | |
| _buildInformationBottomContainer(context), | |
| ], | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Widget _buildImageContainer(BuildContext context) { | |
| return ClipRRect( | |
| child: SizedBox( | |
| child: Image.asset( | |
| this.product.imagePath, | |
| fit: BoxFit.cover, | |
| ), | |
| ), | |
| borderRadius: BorderRadius.circular(10), | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @override | |
| Widget build(BuildContext context) { | |
| return Center( | |
| child: SizedBox.fromSize( | |
| size: Size.fromHeight(550), | |
| child: TripPageTransformer( | |
| pageViewBuilder: (context, visibilityResolver) { | |
| return PageView.builder( | |
| controller: PageController(viewportFraction: 0.85), | |
| itemCount: trips.length, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @override | |
| Widget build(BuildContext context) { | |
| final pageView = this.widget.pageViewBuilder( | |
| context, | |
| _visibilityResolver ?? TripPageVisibilityResolver(), | |
| ); | |
| return NotificationListener<ScrollNotification>( | |
| child: pageView, | |
| onNotification: (ScrollNotification notification) { |
NewerOlder