Merge branch 'develop' of github.com:alibaba/flutter-common-widgets-app into develop

This commit is contained in:
sanfan.hx
2019-02-03 11:51:42 +08:00
25 changed files with 190 additions and 138 deletions

View File

@ -25,7 +25,6 @@
0828E4A52206936100A59437 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0828E4A42206936100A59437 /* Images.xcassets */; };
084A20882202E4FD00428FF5 /* flutter go.png in Resources */ = {isa = PBXBuildFile; fileRef = 084A20872202E4FD00428FF5 /* flutter go.png */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
333E5DAE7FC10AC69FEC26C0 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA792F029EDD7A11295D192 /* libPods-Runner.a */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
@ -74,7 +73,10 @@
084A20872202E4FD00428FF5 /* flutter go.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "flutter go.png"; sourceTree = "<group>"; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
<<<<<<< HEAD
=======
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
>>>>>>> 12990ce0e83473226cfb16ad9c682c065856d684
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };

View File

@ -33,11 +33,13 @@ class DisclaimerMsgState extends State<DisclaimerMsg> {
void refs(bool value) async {
final SharedPreferences prefs = await _prefs;
final bool unKnow = value;
setState(() {
_unKnow = prefs.setBool("disclaimer::Boolean", unKnow).then((bool success) {
return unKnow;
if (mounted) {
setState(() {
_unKnow = prefs.setBool("disclaimer::Boolean", unKnow).then((bool success) {
return unKnow;
});
});
});
}
}
@override
@ -135,12 +137,12 @@ class DisclaimerMsgState extends State<DisclaimerMsg> {
tristate: false,
value: _valBool,
onChanged: (bool bol) {
setState(() {
_valBool = bol;
});
// refs(bol);
Navigator.of(context)
.pop(); // here I pop to avoid multiple Dialogs
if(mounted) {
setState(() {
_valBool = bol;
});
}
Navigator.of(context).pop(); // here I pop to avoid multiple Dialogs
showAlertDialog(context); //here i call the same function
}),
Text('不再自动提示', style: TextStyle(fontSize: 14)),

View File

@ -43,16 +43,23 @@ class _FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
if (_exampleCode == null) {
body = const Center(child: CircularProgressIndicator());
} else {
body = SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: RichText(
text: TextSpan(
Widget _codeWidget;
try{
DartSyntaxHighlighter(style).format(_exampleCode);
_codeWidget = RichText(
text: TextSpan(
style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0),
children: <TextSpan>[
DartSyntaxHighlighter(style).format(_exampleCode)
]),
),
],),
);
}catch (err){
_codeWidget = Text(_exampleCode);
}
body = SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: _codeWidget,
),
);
}

View File

@ -61,7 +61,9 @@ class _ListRefreshState extends State<ListRefresh> {
Future _getMoreData() async {
if (!isLoading && _hasMore) {
// 如果上一次异步请求数据完成 同时有数据可以加载
setState(() => isLoading = true);
if (mounted) {
setState(() => isLoading = true);
}
//if(_hasMore){ // 还有数据可以拉新
List newEntries = await mokeHttpRequest();
//if (newEntries.isEmpty) {

View File

@ -24,52 +24,54 @@ class FourthPageState extends State<FourthPage> with TickerProviderStateMixin {
slideUpdateStream = new StreamController<SlideUpdate>();
slideUpdateStream.stream.listen((SlideUpdate event) {
setState(() {
if (event.updateType == UpdateType.dragging) {
slideDirection = event.direction;
slidePercent = event.slidePercent;
if(mounted) {
setState(() {
if (event.updateType == UpdateType.dragging) {
slideDirection = event.direction;
slidePercent = event.slidePercent;
if (slideDirection == SlideDirection.leftToRight) {
nextPageIndex = activeIndex - 1;
} else if (slideDirection == SlideDirection.rightToLeft) {
nextPageIndex = activeIndex + 1;
} else {
nextPageIndex = activeIndex;
if (slideDirection == SlideDirection.leftToRight) {
nextPageIndex = activeIndex - 1;
} else if (slideDirection == SlideDirection.rightToLeft) {
nextPageIndex = activeIndex + 1;
} else {
nextPageIndex = activeIndex;
}
} else if (event.updateType == UpdateType.doneDragging) {
if (slidePercent > 0.5) {
animatedPageDragger = new AnimatedPageDragger(
slideDirection: slideDirection,
transitionGoal: TransitionGoal.open,
slidePercent: slidePercent,
slideUpdateStream: slideUpdateStream,
vsync: this,
);
} else {
animatedPageDragger = new AnimatedPageDragger(
slideDirection: slideDirection,
transitionGoal: TransitionGoal.close,
slidePercent: slidePercent,
slideUpdateStream: slideUpdateStream,
vsync: this,
);
nextPageIndex = activeIndex;
}
animatedPageDragger.run();
} else if (event.updateType == UpdateType.animating) {
slideDirection = event.direction;
slidePercent = event.slidePercent;
} else if (event.updateType == UpdateType.doneAnimating) {
activeIndex = nextPageIndex;
slideDirection = SlideDirection.none;
slidePercent = 0.0;
animatedPageDragger.dispose();
}
} else if (event.updateType == UpdateType.doneDragging) {
if (slidePercent > 0.5) {
animatedPageDragger = new AnimatedPageDragger(
slideDirection: slideDirection,
transitionGoal: TransitionGoal.open,
slidePercent: slidePercent,
slideUpdateStream: slideUpdateStream,
vsync: this,
);
} else {
animatedPageDragger = new AnimatedPageDragger(
slideDirection: slideDirection,
transitionGoal: TransitionGoal.close,
slidePercent: slidePercent,
slideUpdateStream: slideUpdateStream,
vsync: this,
);
nextPageIndex = activeIndex;
}
animatedPageDragger.run();
} else if (event.updateType == UpdateType.animating) {
slideDirection = event.direction;
slidePercent = event.slidePercent;
} else if (event.updateType == UpdateType.doneAnimating) {
activeIndex = nextPageIndex;
slideDirection = SlideDirection.none;
slidePercent = 0.0;
animatedPageDragger.dispose();
}
});
});
}
});
}

View File

@ -43,9 +43,11 @@ class _AnimatedListFullDefault extends State<AnimatedListFullDefault> {
void remove() {
if (_selectedItem != null) {
_list.removeAt(_list.indexOf(_selectedItem));
setState(() {
_selectedItem = null;
});
if(mounted) {
setState(() {
_selectedItem = null;
});
}
}
}

View File

@ -25,9 +25,11 @@ class _BottomNavigationBarFullDefault extends State {
int _currentIndex = 1;
void _onItemTapped(int index) {
setState(() {
_currentIndex = index;
});
if(mounted) {
setState(() {
_currentIndex = index;
});
}
}
@override

View File

@ -124,9 +124,11 @@ class DropdownButtonCustom extends StatelessWidget {
value: selectItemValue,
//下拉菜单item点击之后的回调
onChanged: (T){
parent.setState((){
selectItemValue = T;
});
if (parent.mounted) {
parent.setState(() {
selectItemValue = T;
});
}
},
//设置阴影的高度
elevation: 24,

View File

@ -50,9 +50,11 @@ class _DemoState extends State<Demo> {
String buttonShapeType = 'border'; // 边框类型
void setButtonShapeType(){
String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
this.setState((){
buttonShapeType = _buttonShapeType;
});
if(mounted) {
this.setState(() {
buttonShapeType = _buttonShapeType;
});
}
}
@override
Widget build(BuildContext context) {

View File

@ -45,9 +45,11 @@ class _DemoState extends State<Demo> {
String buttonShapeType = 'border'; // 边框类型
void setButtonShapeType(){
String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
this.setState((){
buttonShapeType = _buttonShapeType;
});
if(mounted) {
this.setState(() {
buttonShapeType = _buttonShapeType;
});
}
}
@override
Widget build(BuildContext context) {

View File

@ -54,9 +54,11 @@ class _DemoState extends State<Demo> {
String buttonShapeType = 'border'; // 边框类型
void setButtonShapeType(){
String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
this.setState((){
buttonShapeType = _buttonShapeType;
});
if (mounted) {
this.setState(() {
buttonShapeType = _buttonShapeType;
});
}
}
@override
Widget build(BuildContext context) {

View File

@ -53,9 +53,11 @@ class _DemoState extends State<Demo> {
String buttonShapeType = 'border'; // 边框类型
void setButtonShapeType(){
String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
this.setState((){
buttonShapeType = _buttonShapeType;
});
if(mounted) {
this.setState(() {
buttonShapeType = _buttonShapeType;
});
}
}
@override
Widget build(BuildContext context) {

View File

@ -43,9 +43,11 @@ class _DemoState extends State<Demo> {
String buttonShapeType = 'border'; // 边框类型
void setButtonShapeType(){
//String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border';
this.setState((){
//buttonShapeType = _buttonShapeType;
});
if( mounted ) {
this.setState(() {
//buttonShapeType = _buttonShapeType;
});
}
}
@override
Widget build(BuildContext context) {

View File

@ -30,9 +30,11 @@ class _CheckboxDefault extends State {
tristate:false,
value: isChecked,
onChanged: (bool bol) {
setState((){
isChecked = bol;
});
if(mounted) {
setState(() {
isChecked = bol;
});
}
}
);
}
@ -58,9 +60,11 @@ class CheckboxSelect extends StatelessWidget {
tristate:false,
value: parent.selectValue == this.index,
onChanged: (bool bol) {
parent.setState((){
parent.selectValue = bol ? this.index : -1;
});
if(parent.mounted) {
parent.setState(() {
parent.selectValue = bol ? this.index : -1;
});
}
}
);
}

View File

@ -25,7 +25,9 @@ class _CheckboxListTileStateDefault extends State {
for (var i = 0; i < isChecks.length; i++) {
isChecks[i] = value;
}
setState(() => _value = value);
if(mounted) {
setState(() => _value = value);
}
}
bool isCheck=false;
List<bool> isChecks=[false,false,false,false];
@ -55,9 +57,11 @@ class _CheckboxListTileStateDefault extends State {
activeColor: _value ? Colors.red : Colors.green,
controlAffinity: ListTileControlAffinity.platform,
onChanged: (bool){
setState(() {
isChecks[0]=bool;
});
if(mounted) {
setState(() {
isChecks[0] = bool;
});
}
}),
),
Center(

View File

@ -46,10 +46,6 @@ const contentB = '''
### **高级用法**
> 自定义Slider 样式
<<<<<<< HEAD
如果当前Slider样式 无法满足需求, 可以通过 **SliderTheme** 定制复杂样式
=======
如果当前Slider样式 无法满足需求, 可以通过 ** SliderTheme ** 定制复杂样式
```
@ -69,7 +65,6 @@ const contentB = '''
)
```
>>>>>>> ccb5c9e42883b23266fb95b9caf4e958d817ff48
### **基本实例**

View File

@ -21,9 +21,6 @@ const contentA = '''
> 通过更改sliderTheme.data, 修改Slider总体样式
<<<<<<< HEAD
具体属性, 请查阅: SliderThemeData.data.
=======
基本属性参考以下代码:
```
@ -50,7 +47,6 @@ const contentA = '''
),
```
>>>>>>> ccb5c9e42883b23266fb95b9caf4e958d817ff48
### **基本实例**

View File

@ -1,9 +1,8 @@
/*
* @Author: 一凨
* @Date: 2018-11-28 20:09:40
* @Last Modified by: 一凨
* @Last Modified time: 2018-11-28 20:10:32
*/
/// @Author: 一凨
/// @Date: 2018-11-28 20:09:40
/// @Last Modified by: 一凨
/// @Last Modified time: 2018-11-28 20:10:32
import 'package:flutter/material.dart';
class ExpandedDemo extends StatelessWidget {

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../../../../model/widget.dart';
import 'package:flutter_go/model/widget.dart';
import './Expanded/index.dart' as Expanded;

View File

@ -39,9 +39,11 @@ class CustomViewPageState extends State<CustomViewPage>
void initState() {
super.initState();
getImage("assets/images/painterImg.jpeg").then((data) {
setState(() {
image = data;
});
if (mounted) {
setState(() {
image = data;
});
}
});
}

View File

@ -30,7 +30,9 @@ class CustomViewPageState extends State<CustomViewPage>
_doubleAnimation = Tween(begin: 0.0, end: 360.0).animate(_controller);
_controller.addListener(() {
this.setState(() {});
if(mounted){
this.setState(() {});
}
});
onAnimationStart();
}

View File

@ -23,7 +23,7 @@ class _DemoState extends State<Demo> {
@override
Widget build(BuildContext context) {
return WidgetDemo(
title: 'Canvas',
title: 'CircleProgressBarPainter',
codeUrl: 'elements/Media/Canvas/CircleProgressBarPainter/demo.dart',
contentList: [
Text,

View File

@ -30,9 +30,11 @@ class _PainterSketchDomeState extends State<PainterSketchDome> {
final Offset xy = box.globalToLocal(detail.globalPosition);// 重要需要转换以下坐标位置
Offset p = Offset(xy.dx, xy.dy - 60);
//Offset p = Offset(detail.globalPosition.dx, detail.globalPosition.dy - 60);
setState(() {
nowPoints.add(p);
});
if (mounted) {
setState(() {
nowPoints.add(p);
});
}
}
void newGestureDetector(DragStartDetails detail) {
@ -45,9 +47,11 @@ class _PainterSketchDomeState extends State<PainterSketchDome> {
final Offset xy = box.globalToLocal(detail.globalPosition);// 重要需要转换以下坐标位置
Offset p = Offset(xy.dx, xy.dy - 60);
//Offset p = Offset(detail.globalPosition.dx, detail.globalPosition.dy - 60);
setState(() {
nowPoints.add(p);
});
if (mounted) {
setState(() {
nowPoints.add(p);
});
}
}
void changeColor (Color c){
@ -55,10 +59,12 @@ class _PainterSketchDomeState extends State<PainterSketchDome> {
LinePoints l = LinePoints(new List<Offset>.from(nowPoints), nowColor);
lines.add(l);
}
setState(() {
nowPoints.clear();
nowColor = c;
});
if (mounted) {
setState(() {
nowPoints.clear();
nowColor = c;
});
}
}
List<Color> colors = <Color>[
@ -74,10 +80,12 @@ class _PainterSketchDomeState extends State<PainterSketchDome> {
Colors.cyanAccent,];
void _tapClear(){
setState(() {
lines.clear();
nowPoints.clear();
});
if (mounted) {
setState(() {
lines.clear();
nowPoints.clear();
});
}
}
@override

View File

@ -23,7 +23,7 @@ class _DemoState extends State<Demo> {
@override
Widget build(BuildContext context) {
return WidgetDemo(
title: 'Canvas',
title: 'PainterSketch',
codeUrl: 'elements/Media/Canvas/PainterSketch/demo.dart',
contentList: [
Text,

View File

@ -108,7 +108,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
backgroundColor: CupertinoColors.white,// 所有子节点下面的背景颜色
useMagnifier:true,// 是否使用放大效果
onSelectedItemChanged: (int index) { // 当正中间选项改变时的回调
setState(() => _selectedColorIndex = index);
if (mounted) {
setState(() => _selectedColorIndex = index);
}
},
children: List<Widget>.generate(coolColorNames.length, (int index) {
return Center(child:
@ -144,7 +146,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
CupertinoTimerPicker(
initialTimerDuration: timer,
onTimerDurationChanged: (Duration newTimer) {
setState(() => timer = newTimer);
if (mounted) {
setState(() => timer = newTimer);
}
},
),
);
@ -176,7 +180,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
mode: CupertinoDatePickerMode.date,
initialDateTime: date,
onDateTimeChanged: (DateTime newDateTime) {
setState(() => date = newDateTime);
if (mounted) {
setState(() => date = newDateTime);
}
},
),
);
@ -206,7 +212,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
mode: CupertinoDatePickerMode.time,
initialDateTime: time,
onDateTimeChanged: (DateTime newDateTime) {
setState(() => time = newDateTime);
if (mounted) {
setState(() => time = newDateTime);
}
},
),
);
@ -236,7 +244,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
mode: CupertinoDatePickerMode.dateAndTime,
initialDateTime: dateTime,
onDateTimeChanged: (DateTime newDateTime) {
setState(() => dateTime = newDateTime);
if (mounted) {
setState(() => dateTime = newDateTime);
}
},
),
);