forked from wanggang1128/WGFlutterDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
王刚
committed
Aug 1, 2019
1 parent
f0eb344
commit 0a55550
Showing
8 changed files
with
168 additions
and
7 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,48 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:provide/provide.dart'; | ||
import '../provide/counter.dart'; | ||
|
||
class CartPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: Center( | ||
child: Text('购物车'), | ||
child: Column( | ||
children: <Widget>[ | ||
MyNumber(), | ||
MyButton() | ||
], | ||
) | ||
), | ||
); | ||
} | ||
} | ||
|
||
class MyNumber extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
margin: EdgeInsets.only(top: 200), | ||
child: Provide<Counter>( | ||
builder: (context, child, counter) { | ||
return Text('${counter.value}', style: TextStyle(fontSize: 30),); | ||
} | ||
), | ||
); | ||
} | ||
} | ||
|
||
class MyButton extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
child: RaisedButton( | ||
onPressed: (){ | ||
Provide.value<Counter>(context).increment(); | ||
}, | ||
child: Text('递增'), | ||
), | ||
); | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flutter/material.dart'; | ||
import '../model/category.dart'; | ||
|
||
class ChildCategory with ChangeNotifier{ | ||
|
||
List<BxMallSubDto> childCategoryList = []; | ||
|
||
getChildCategoryList(List<BxMallSubDto> list){ | ||
|
||
BxMallSubDto all = BxMallSubDto(); | ||
all.mallSubName = '全部'; | ||
all.comments = 'null'; | ||
all.mallCategoryId = '00'; | ||
all.mallSubId = '00'; | ||
childCategoryList = [all]; | ||
childCategoryList.addAll(list); | ||
notifyListeners(); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class Counter with ChangeNotifier { | ||
int value =0 ; | ||
|
||
increment(){ | ||
value++; | ||
notifyListeners(); | ||
} | ||
} |
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
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