This file contains 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
RaisedButton( | |
child: Text("Add Item"), | |
onPressed: () async { | |
final form = _formKey.currentState; | |
form.save(); | |
if (form.validate()) { | |
Provider.of(context) | |
.add(new Item(_name, num.parse(_price))); | |
} else { | |
print('validate failed'); |
This file contains 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 TabBarDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
var count = Provider.of(context).items.length; |
This file contains 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
import 'dart:collection'; | |
import 'package:flutter/material.dart'; | |
class Item { | |
String name; | |
num price; | |
Item(this.name, this.price); | |
} |
This file contains 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
void main() => runApp( | |
ChangeNotifierProvider( | |
child: TabBarDemo(), | |
builder: (BuildContext context) { | |
return CartModel(); | |
}, | |
), | |
); |
This file contains 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
// FILE: App.tsx | |
} /> |
This file contains 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
// FILE: TabRoot.tsx | |
interface IAppProps {} | |
const TabRoot: React.FC = props => { | |
return ( | |
This file contains 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
// FILE: Tab1Detail.tsx | |
import React from 'react'; | |
import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/react'; | |
const Tab1Detail: React.SFC = () => { | |
return ( | |
<> | |
This file contains 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
// FILE: App.tsx | |
const App: React.SFC = () => ( | |
} /> | |
This file contains 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
// FILE: Tab1Detail.tsx | |
import { withRouter } from "react-router"; // <== NEW | |
const Tab1Detail: React.SFC = (props) => { // <== NEW | |
return ( | |
<> | |
This file contains 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
// FILE: Tab1.tsx | |
// add the import.. | |
import { withRouter } from "react-router"; |