diff --git a/lib/api/api.dart b/lib/api/api.dart index 748e3422..65c9d0ae 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -1,36 +1,36 @@ -class Api{ +class Api { // static const String BASE_URL = 'http://flutter-go.alibaba.net/'; static const String BASE_URL = 'https://flutter-go.pub/api/'; - static const String DO_LOGIN = BASE_URL+'doLogin';//登陆 + static const String DO_LOGIN = BASE_URL + 'doLogin'; //登陆 - static const String CHECK_LOGIN = BASE_URL+'checkLogin';//验证登陆 - - static const String LOGOUT = BASE_URL+'logout';//退出登陆 + static const String CHECK_LOGIN = BASE_URL + 'checkLogin'; //验证登陆 - static const String GET_USER_INFO = BASE_URL+'getUserInfo';//获取用户信息 + static const String LOGOUT = BASE_URL + 'logout'; //退出登陆 + static const String GET_USER_INFO = BASE_URL + 'getUserInfo'; //获取用户信息 - static const String VERSION = BASE_URL+'getAppVersion';//检查版本 + static const String VERSION = BASE_URL + 'getAppVersion'; //检查版本 - static const String FEEDBACK = BASE_URL+'auth/feedback';//建议反馈 + static const String FEEDBACK = BASE_URL + 'auth/feedback'; //建议反馈 // static const String LOTOUT = BASE_URL+'logout';//退出登陆 - static const String GET_ALL_COLLECTION = BASE_URL+'auth/getAllUserCollection';//获取全部收藏 + static const String GET_ALL_COLLECTION = + BASE_URL + 'auth/getAllUserCollection'; //获取全部收藏 - static const String REMOVE_COLLECTION = BASE_URL+'auth/removeCollection';//移除收藏 + static const String REMOVE_COLLECTION = + BASE_URL + 'auth/removeCollection'; //移除收藏 - static const String ADD_COLLECTION = BASE_URL+'auth/addCollection';//添加收藏 - - static const String CHECK_COLLECTED = BASE_URL+'checkCollected';//校验收藏 + static const String ADD_COLLECTION = BASE_URL + 'auth/addCollection'; //添加收藏 - static const String SET_THEMECOLOR = BASE_URL+'auth/setThemeColor';//设置主题颜色 + static const String CHECK_COLLECTED = BASE_URL + 'checkCollected'; //校验收藏 - static const String GET_THEMECOLOR = BASE_URL +'/getThemeColor';//获取主题颜色 + static const String SET_THEMECOLOR = BASE_URL + 'auth/setThemeColor'; //设置主题颜色 - static const String GET_WIDGET_TREE = BASE_URL + 'getCateList';//获取widget列表树 + static const String GET_THEMECOLOR = BASE_URL + '/getThemeColor'; //获取主题颜色 - static const String SEARCH_WIDGET = BASE_URL+'searchWidget';//搜索组件 + static const String GET_WIDGET_TREE = BASE_URL + 'getCateList'; //获取widget列表树 + + static const String SEARCH_WIDGET = BASE_URL + 'searchWidget'; //搜索组件 } - diff --git a/lib/blocs/industry_api.dart b/lib/blocs/industry_api.dart index 7b271ca0..0dac3431 100644 --- a/lib/blocs/industry_api.dart +++ b/lib/blocs/industry_api.dart @@ -12,6 +12,7 @@ import 'package:html/parser.dart' show parse; import './search_result.dart'; var dio = new Dio(); + //class Api2 { // /// 关键字提示(起点) // Future> suggestion(String query) async { @@ -42,9 +43,11 @@ class Api { // http.Response response = await http.get( // "https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query"); /// var response = await dio.get("https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query", data: {}); - var response = await dio.get("https://www.so.com/s?ie=utf-8&q=$query flutter"); + var response = + await dio.get("https://www.so.com/s?ie=utf-8&q=$query flutter"); var document = parse(response.data); var app = document.querySelectorAll('.res-title a'); + ///print('1=====>${query}'); ///print('2=====>${response.data}'); ////print('3=====>${app}'); @@ -59,11 +62,11 @@ class Api { ); }); - return Future.delayed(Duration(seconds:2), () { + return Future.delayed(Duration(seconds: 2), () { return res; }); //return suggestion; } } -Api api = Api(); \ No newline at end of file +Api api = Api(); diff --git a/lib/blocs/industry_bloc.dart b/lib/blocs/industry_bloc.dart index 1757f3b4..06a065aa 100644 --- a/lib/blocs/industry_bloc.dart +++ b/lib/blocs/industry_bloc.dart @@ -16,8 +16,8 @@ class SuggestionBloc extends Bloc { @override SuggestionState get initialState => SuggestionUninitialized(); @override - Stream mapEventToState(SuggestionEvent event)async* { - //Stream mapEventToState(SuggestionState currentState, SuggestionEvent event,) async* { + Stream mapEventToState(SuggestionEvent event) async* { + //Stream mapEventToState(SuggestionState currentState, SuggestionEvent event,) async* { if (event is SuggestionFetch) { //print('event==>${event}'); try { diff --git a/lib/blocs/industry_event.dart b/lib/blocs/industry_event.dart index b54e7940..e606a24c 100644 --- a/lib/blocs/industry_event.dart +++ b/lib/blocs/industry_event.dart @@ -23,4 +23,4 @@ class SuggestionClearFetch extends SuggestionEvent { @override String toString() => 'SuggestionClearFetch:清空界面'; -} \ No newline at end of file +} diff --git a/lib/blocs/industry_main.dart b/lib/blocs/industry_main.dart index fa49fac5..e331babb 100644 --- a/lib/blocs/industry_main.dart +++ b/lib/blocs/industry_main.dart @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import './industry_bloc.dart'; + /// import './industry_event.dart'; import './industry_state.dart'; @@ -15,7 +16,7 @@ final SuggestionBloc suggestion = SuggestionBloc(); class IndustryPage extends StatefulWidget { final Function itemTitle; - IndustryPage({Key key,this.itemTitle}) : super(key: key); + IndustryPage({Key key, this.itemTitle}) : super(key: key); @override _IndustryState createState() => _IndustryState(); @@ -40,15 +41,13 @@ class _IndustryState extends State { return Center( child: Text('没有适合的结果,更换查询条件试试'), ); - }else { + } else { if (widget.itemTitle is Function) { return widget.itemTitle(state); } } } - return Center( - child: Text('没有适合的结果,更换查询条件试试') - ); + return Center(child: Text('没有适合的结果,更换查询条件试试')); } @override @@ -59,7 +58,7 @@ class _IndustryState extends State { Expanded( child: BlocBuilder( bloc: suggestion, - builder: (BuildContext context, SuggestionState state){ + builder: (BuildContext context, SuggestionState state) { /// print('BlocBuilder----${state}'); return renderItem(state); }, @@ -75,4 +74,4 @@ class _IndustryState extends State { //suggestion.dispose();//添加这个第二次进入会失灵 super.dispose(); } -} \ No newline at end of file +} diff --git a/lib/blocs/industry_model.dart b/lib/blocs/industry_model.dart index 550d29c7..74577c07 100644 --- a/lib/blocs/industry_model.dart +++ b/lib/blocs/industry_model.dart @@ -69,4 +69,4 @@ class Data { data['category'] = this.category; return data; } -} \ No newline at end of file +} diff --git a/lib/blocs/search_result.dart b/lib/blocs/search_result.dart index bf64d1b1..753619df 100644 --- a/lib/blocs/search_result.dart +++ b/lib/blocs/search_result.dart @@ -11,4 +11,4 @@ class SearchResult { String source; SearchResult({this.title, this.source}); -} \ No newline at end of file +} diff --git a/lib/components/cate_card.dart b/lib/components/cate_card.dart index aab9fa48..108a5e76 100644 --- a/lib/components/cate_card.dart +++ b/lib/components/cate_card.dart @@ -21,8 +21,6 @@ class _CateCardState extends State { _firstChildList = widget.category.children; } - - @override Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; @@ -100,14 +98,11 @@ class _CateCardState extends State { padding: const EdgeInsets.only(bottom: 10.0, top: 5.0), decoration: BoxDecoration( image: DecorationImage( - image: AssetImage('assets/images/paimaiLogo.png'), - alignment: Alignment.bottomRight - ), + image: AssetImage('assets/images/paimaiLogo.png'), + alignment: Alignment.bottomRight), ), child: WidgetItemContainer( - commonItems: this._firstChildList, - columnCount: 3 - ), + commonItems: this._firstChildList, columnCount: 3), ); } } diff --git a/lib/components/category.dart b/lib/components/category.dart index eee1035e..e285fe12 100644 --- a/lib/components/category.dart +++ b/lib/components/category.dart @@ -3,18 +3,16 @@ import 'dart:async'; import 'package:flutter/material.dart'; import '../routers/application.dart'; + /// import '../model/cat.dart'; import '../model/widget.dart'; import '../widgets/index.dart'; import '../components/widget_item_container.dart'; - - class CategoryHome extends StatefulWidget { CategoryHome(this.token); final String token; - @override _CategoryHome createState() => new _CategoryHome(); } @@ -26,7 +24,6 @@ class _CategoryHome extends State { List widgetPoints = []; List catHistory = new List(); - // 所有的可用demos; List widgetDemosList = new WidgetDemoList().getDemos(); @@ -39,17 +36,13 @@ class _CategoryHome extends State { CommonItem targetGroup = Application.widgetTree.find(widget.token) ?? []; print("targetGroup::: $targetGroup"); - catHistory.add( - targetGroup - ); + catHistory.add(targetGroup); this.setState(() { items = targetGroup.children; }); searchCatOrWidget(); } - - Future back() { // if (catHistory.length == 1) { // return Future.value(true); @@ -66,10 +59,9 @@ class _CategoryHome extends State { void searchCatOrWidget() async { /// CommonItem widgetTree = Application.widgetTree; - // 假设进入这个界面的parent一定存在 + // 假设进入这个界面的parent一定存在 CommonItem targetGroup = catHistory.last; - this.setState(() { title = targetGroup.name; }); @@ -79,14 +71,9 @@ class _CategoryHome extends State { go(cat); } - - Widget _buildContent() { - WidgetItemContainer wiContaienr = WidgetItemContainer( - columnCount: 3, - commonItems: items - ); - + WidgetItemContainer wiContaienr = + WidgetItemContainer(columnCount: 3, commonItems: items); return Container( padding: const EdgeInsets.only(bottom: 10.0, top: 5.0), @@ -102,14 +89,11 @@ class _CategoryHome extends State { @override Widget build(BuildContext context) { - - return Scaffold( appBar: AppBar( title: Text("$title"), ), body: WillPopScope( - onWillPop: () { return back(); }, @@ -124,4 +108,3 @@ class _CategoryHome extends State { ); } } - diff --git a/lib/components/disclaimer_msg.dart b/lib/components/disclaimer_msg.dart index d7c4bf7f..a2383815 100644 --- a/lib/components/disclaimer_msg.dart +++ b/lib/components/disclaimer_msg.dart @@ -22,7 +22,6 @@ class DisclaimerMsg extends StatefulWidget { DisclaimerMsgState createState() => DisclaimerMsgState(); } - class DisclaimerMsgState extends State { Future _prefs = SharedPreferences.getInstance(); Future _unKnow; @@ -39,8 +38,8 @@ class DisclaimerMsgState extends State { setState(() { _unKnow = prefs.setBool("disclaimer::Boolean", unKnow).then((bool success) { - return unKnow; - }); + return unKnow; + }); }); } } @@ -63,15 +62,13 @@ class DisclaimerMsgState extends State { context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { - return DisclaimerMsgDialog(_valBool, _readed, (b){ + return DisclaimerMsgDialog(_valBool, _readed, (b) { refs(b); }); }, ); } - - Widget build(BuildContext context) { return GestureDetector( onTap: () { @@ -85,7 +82,7 @@ class DisclaimerMsgState extends State { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: - BorderRadius.horizontal(right: Radius.circular(10)), + BorderRadius.horizontal(right: Radius.circular(10)), color: Colors.black45, ), child: Text( @@ -102,14 +99,11 @@ class DisclaimerMsgState extends State { } } - class DisclaimerMsgDialog extends StatefulWidget { - final bool valBool; final bool readed; final ValueChanged onValueChanged; - DisclaimerMsgDialog(this.valBool, this.readed, this.onValueChanged); @override @@ -117,18 +111,14 @@ class DisclaimerMsgDialog extends StatefulWidget { } class _DisclaimerMsgDialogState extends State { - bool readBool; - @override void initState() { super.initState(); readBool = widget.valBool; } - - Row _create() { //已读 if (widget.readed) { @@ -140,9 +130,7 @@ class _DisclaimerMsgDialogState extends State { child: Text('已阅读知晓', style: TextStyle(fontSize: 16, color: Colors.white)), //可点击 - color: Theme - .of(context) - .primaryColor, + color: Theme.of(context).primaryColor, onPressed: () { Navigator.of(context).pop(); }, @@ -155,7 +143,7 @@ class _DisclaimerMsgDialogState extends State { } /// 选中状态更新,并返回数据 - checkChanged(){ + checkChanged() { if (mounted) { setState(() { readBool = !readBool; @@ -168,16 +156,14 @@ class _DisclaimerMsgDialogState extends State { //crossAxisAlignment:CrossAxisAlignment.start, children: [ GestureDetector( - onTap: (){ + onTap: () { checkChanged(); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Checkbox( - activeColor: Theme - .of(context) - .primaryColor, + activeColor: Theme.of(context).primaryColor, tristate: false, value: readBool, onChanged: (bool bol) { @@ -192,13 +178,8 @@ class _DisclaimerMsgDialogState extends State { style: TextStyle(fontSize: 16, color: Colors.white)), //可点击 color: readBool - ? Theme - .of(context) - .primaryColor - : Theme - .of(context) - .primaryColor - .withAlpha(800), + ? Theme.of(context).primaryColor + : Theme.of(context).primaryColor.withAlpha(800), onPressed: () { widget.onValueChanged(readBool); Navigator.of(context).pop(); @@ -220,7 +201,7 @@ class _DisclaimerMsgDialogState extends State { height: 35, child: Text('免责声明', style: - TextStyle(fontSize: 18, fontWeight: FontWeight.w700)), + TextStyle(fontSize: 18, fontWeight: FontWeight.w700)), decoration: BoxDecoration( //color: Colors.blue, image: DecorationImage( @@ -247,4 +228,5 @@ class _DisclaimerMsgDialogState extends State { ) ], ); - }} + } +} diff --git a/lib/components/flutter_markdown/lib/src/builder.dart b/lib/components/flutter_markdown/lib/src/builder.dart index 089e83c3..ba1f533f 100644 --- a/lib/components/flutter_markdown/lib/src/builder.dart +++ b/lib/components/flutter_markdown/lib/src/builder.dart @@ -44,18 +44,18 @@ class _BlockElement { /// A collection of widgets that should be placed adjacent to (inline with) /// other inline elements in the same parent block. -/// -/// Inline elements can be textual (a/em/strong) represented by [RichText] +/// +/// Inline elements can be textual (a/em/strong) represented by [RichText] /// widgets or images (img) represented by [Image.network] widgets. -/// +/// /// Inline elements can be nested within other inline elements, inheriting their /// parent's style along with the style of the block they are in. -/// -/// When laying out inline widgets, first, any adjacent RichText widgets are +/// +/// When laying out inline widgets, first, any adjacent RichText widgets are /// merged, then, all inline widgets are enclosed in a parent [Wrap] widget. class _InlineElement { _InlineElement(this.tag, {this.style}); - + final String tag; /// Created by merging the style defined for this element's [tag] in the @@ -85,12 +85,8 @@ abstract class MarkdownBuilderDelegate { /// * [Markdown], which is a widget that parses and displays Markdown. class MarkdownBuilder implements md.NodeVisitor { /// Creates an object that builds a [Widget] tree from parsed Markdown. - MarkdownBuilder({ - this.delegate, - this.styleSheet, - this.imageDirectory, - this.demoParser - }); + MarkdownBuilder( + {this.delegate, this.styleSheet, this.imageDirectory, this.demoParser}); /// A delegate that controls how link and `pre` elements behave. final MarkdownBuilderDelegate delegate; @@ -99,6 +95,7 @@ class MarkdownBuilder implements md.NodeVisitor { final MarkdownStyleSheet styleSheet; final DemoBuilder demoParser; + /// The base directory holding images referenced by Img tags with local file paths. final Directory imageDirectory; @@ -107,7 +104,6 @@ class MarkdownBuilder implements md.NodeVisitor { final List<_InlineElement> _inlines = <_InlineElement>[]; final List _linkHandlers = []; - /// Returns widgets that display the given Markdown nodes. /// /// The returned widgets are typically used as children in a [ListView]. @@ -136,12 +132,12 @@ class MarkdownBuilder implements md.NodeVisitor { _addParentInlineIfNeeded(_blocks.last.tag); final TextSpan span = _blocks.last.tag == 'pre' - ? delegate.formatText(styleSheet, text.text) - : new TextSpan( - style: _inlines.last.style, - text: text.text, - recognizer: _linkHandlers.isNotEmpty ? _linkHandlers.last : null, - ); + ? delegate.formatText(styleSheet, text.text) + : new TextSpan( + style: _inlines.last.style, + text: text.text, + recognizer: _linkHandlers.isNotEmpty ? _linkHandlers.last : null, + ); _inlines.last.children.add(new RichText( textScaleFactor: styleSheet.textScaleFactor, @@ -155,8 +151,7 @@ class MarkdownBuilder implements md.NodeVisitor { final String tag = element.tag; if (_isBlockTag(tag)) { _addAnonymousBlockIfNeeded(styleSheet.styles[tag]); - if (_isListTag(tag)) - _listIndents.add(tag); + if (_isListTag(tag)) _listIndents.add(tag); _blocks.add(new _BlockElement(tag)); } else { _addParentInlineIfNeeded(_blocks.last.tag); @@ -232,7 +227,6 @@ class MarkdownBuilder implements md.NodeVisitor { } _addBlockChild(child); } else { - final _InlineElement current = _inlines.removeLast(); final _InlineElement parent = _inlines.last; @@ -245,12 +239,12 @@ class MarkdownBuilder implements md.NodeVisitor { current.children.add(_buildGoDemos(element.attributes)); } - if (current.children.isNotEmpty) { parent.children.addAll(current.children); } } } + Widget _buildGoDemos(Map attrs) { Widget targetGoDemos; @@ -263,8 +257,7 @@ class MarkdownBuilder implements md.NodeVisitor { Widget _buildImage(String src) { final List parts = src.split('#'); - if (parts.isEmpty) - return const SizedBox(); + if (parts.isEmpty) return const SizedBox(); final String path = parts.first; double width; @@ -300,10 +293,12 @@ class MarkdownBuilder implements md.NodeVisitor { } } - Widget _handleDataSchemeUri(Uri uri, final double width, final double height) { + Widget _handleDataSchemeUri( + Uri uri, final double width, final double height) { final String mimeType = uri.data.mimeType; if (mimeType.startsWith('image/')) { - return new Image.memory(uri.data.contentAsBytes(), width: width, height: height); + return new Image.memory(uri.data.contentAsBytes(), + width: width, height: height); } else if (mimeType.startsWith('text/')) { return new Text(uri.data.contentAsString()); } @@ -312,12 +307,14 @@ class MarkdownBuilder implements md.NodeVisitor { Widget _buildBullet(String listTag) { if (listTag == 'ul') - return new Text('•', textAlign: TextAlign.center, style: styleSheet.styles['li']); + return new Text('•', + textAlign: TextAlign.center, style: styleSheet.styles['li']); final int index = _blocks.last.nextListIndex; return new Padding( padding: const EdgeInsets.only(right: 5.0), - child: new Text('${index + 1}.', textAlign: TextAlign.right, style: styleSheet.styles['li']), + child: new Text('${index + 1}.', + textAlign: TextAlign.right, style: styleSheet.styles['li']), ); } @@ -356,7 +353,9 @@ class MarkdownBuilder implements md.NodeVisitor { List _mergeInlineChildren(_InlineElement inline) { List mergedTexts = []; for (Widget child in inline.children) { - if (mergedTexts.isNotEmpty && mergedTexts.last is RichText && child is RichText) { + if (mergedTexts.isNotEmpty && + mergedTexts.last is RichText && + child is RichText) { RichText previous = mergedTexts.removeLast(); List children = previous.text.children != null ? new List.from(previous.text.children) diff --git a/lib/components/flutter_markdown/lib/src/style_sheet.dart b/lib/components/flutter_markdown/lib/src/style_sheet.dart index 6c44b773..4750284d 100644 --- a/lib/components/flutter_markdown/lib/src/style_sheet.dart +++ b/lib/components/flutter_markdown/lib/src/style_sheet.dart @@ -7,45 +7,45 @@ import 'package:flutter/material.dart'; /// Defines which [TextStyle] objects to use for which Markdown elements. class MarkdownStyleSheet { /// Creates an explicit mapping of [TextStyle] objects to Markdown elements. - MarkdownStyleSheet({ - this.a, - this.p, - this.code, - this.h1, - this.h2, - this.h3, - this.h4, - this.h5, - this.h6, - this.em, - this.strong, - this.blockquote, - this.img, - this.blockSpacing, - this.listIndent, - this.blockquotePadding, - this.blockquoteDecoration, - this.codeblockPadding, - this.codeblockDecoration, - this.horizontalRuleDecoration, - this.textScaleFactor = 1.0 - }) : _styles = { - 'a': a, - 'p': p, - 'li': p, - 'code': code, - 'pre': p, - 'h1': h1, - 'h2': h2, - 'h3': h3, - 'h4': h4, - 'h5': h5, - 'h6': h6, - 'em': em, - 'strong': strong, - 'blockquote': blockquote, - 'img': img, - }; + MarkdownStyleSheet( + {this.a, + this.p, + this.code, + this.h1, + this.h2, + this.h3, + this.h4, + this.h5, + this.h6, + this.em, + this.strong, + this.blockquote, + this.img, + this.blockSpacing, + this.listIndent, + this.blockquotePadding, + this.blockquoteDecoration, + this.codeblockPadding, + this.codeblockDecoration, + this.horizontalRuleDecoration, + this.textScaleFactor = 1.0}) + : _styles = { + 'a': a, + 'p': p, + 'li': p, + 'code': code, + 'pre': p, + 'h1': h1, + 'h2': h2, + 'h3': h3, + 'h4': h4, + 'h5': h5, + 'h6': h6, + 'em': em, + 'strong': strong, + 'blockquote': blockquote, + 'img': img, + }; /// Creates a [MarkdownStyleSheet] from the [TextStyle]s in the provided [ThemeData]. factory MarkdownStyleSheet.fromTheme(ThemeData theme) { @@ -54,10 +54,9 @@ class MarkdownStyleSheet { a: const TextStyle(color: Colors.blue), p: theme.textTheme.body1, code: new TextStyle( - color: Colors.grey.shade700, - fontFamily: "monospace", - fontSize: theme.textTheme.body1.fontSize * 0.85 - ), + color: Colors.grey.shade700, + fontFamily: "monospace", + fontSize: theme.textTheme.body1.fontSize * 0.85), h1: theme.textTheme.headline, h2: theme.textTheme.title, h3: theme.textTheme.subhead, @@ -72,18 +71,15 @@ class MarkdownStyleSheet { listIndent: 32.0, blockquotePadding: 8.0, blockquoteDecoration: new BoxDecoration( - color: Colors.blue.shade100, - borderRadius: new BorderRadius.circular(2.0) - ), + color: Colors.blue.shade100, + borderRadius: new BorderRadius.circular(2.0)), codeblockPadding: 8.0, codeblockDecoration: new BoxDecoration( - color: Colors.grey.shade100, - borderRadius: new BorderRadius.circular(2.0) - ), + color: Colors.grey.shade100, + borderRadius: new BorderRadius.circular(2.0)), horizontalRuleDecoration: new BoxDecoration( border: new Border( - top: new BorderSide(width: 5.0, color: Colors.grey.shade300) - ), + top: new BorderSide(width: 5.0, color: Colors.grey.shade300)), ), ); } @@ -97,10 +93,9 @@ class MarkdownStyleSheet { a: const TextStyle(color: Colors.blue), p: theme.textTheme.body1, code: new TextStyle( - color: Colors.grey.shade700, - fontFamily: "monospace", - fontSize: theme.textTheme.body1.fontSize * 0.85 - ), + color: Colors.grey.shade700, + fontFamily: "monospace", + fontSize: theme.textTheme.body1.fontSize * 0.85), h1: theme.textTheme.display3, h2: theme.textTheme.display2, h3: theme.textTheme.display1, @@ -115,18 +110,15 @@ class MarkdownStyleSheet { listIndent: 32.0, blockquotePadding: 8.0, blockquoteDecoration: new BoxDecoration( - color: Colors.blue.shade100, - borderRadius: new BorderRadius.circular(2.0) - ), + color: Colors.blue.shade100, + borderRadius: new BorderRadius.circular(2.0)), codeblockPadding: 8.0, codeblockDecoration: new BoxDecoration( - color: Colors.grey.shade100, - borderRadius: new BorderRadius.circular(2.0) - ), + color: Colors.grey.shade100, + borderRadius: new BorderRadius.circular(2.0)), horizontalRuleDecoration: new BoxDecoration( border: new Border( - top: new BorderSide(width: 5.0, color: Colors.grey.shade300) - ), + top: new BorderSide(width: 5.0, color: Colors.grey.shade300)), ), ); } @@ -176,8 +168,9 @@ class MarkdownStyleSheet { blockquoteDecoration: blockquoteDecoration ?? this.blockquoteDecoration, codeblockPadding: codeblockPadding ?? this.codeblockPadding, codeblockDecoration: codeblockDecoration ?? this.codeblockDecoration, - horizontalRuleDecoration: horizontalRuleDecoration ?? this.horizontalRuleDecoration, - textScaleFactor : textScaleFactor ?? this.textScaleFactor, + horizontalRuleDecoration: + horizontalRuleDecoration ?? this.horizontalRuleDecoration, + textScaleFactor: textScaleFactor ?? this.textScaleFactor, ); } @@ -250,32 +243,30 @@ class MarkdownStyleSheet { @override bool operator ==(dynamic other) { - if (identical(this, other)) - return true; - if (other.runtimeType != MarkdownStyleSheet) - return false; + if (identical(this, other)) return true; + if (other.runtimeType != MarkdownStyleSheet) return false; final MarkdownStyleSheet typedOther = other; - return typedOther.a == a - && typedOther.p == p - && typedOther.code == code - && typedOther.h1 == h1 - && typedOther.h2 == h2 - && typedOther.h3 == h3 - && typedOther.h4 == h4 - && typedOther.h5 == h5 - && typedOther.h6 == h6 - && typedOther.em == em - && typedOther.strong == strong - && typedOther.blockquote == blockquote - && typedOther.img == img - && typedOther.blockSpacing == blockSpacing - && typedOther.listIndent == listIndent - && typedOther.blockquotePadding == blockquotePadding - && typedOther.blockquoteDecoration == blockquoteDecoration - && typedOther.codeblockPadding == codeblockPadding - && typedOther.codeblockDecoration == codeblockDecoration - && typedOther.horizontalRuleDecoration == horizontalRuleDecoration - && typedOther.textScaleFactor == textScaleFactor; + return typedOther.a == a && + typedOther.p == p && + typedOther.code == code && + typedOther.h1 == h1 && + typedOther.h2 == h2 && + typedOther.h3 == h3 && + typedOther.h4 == h4 && + typedOther.h5 == h5 && + typedOther.h6 == h6 && + typedOther.em == em && + typedOther.strong == strong && + typedOther.blockquote == blockquote && + typedOther.img == img && + typedOther.blockSpacing == blockSpacing && + typedOther.listIndent == listIndent && + typedOther.blockquotePadding == blockquotePadding && + typedOther.blockquoteDecoration == blockquoteDecoration && + typedOther.codeblockPadding == codeblockPadding && + typedOther.codeblockDecoration == codeblockDecoration && + typedOther.horizontalRuleDecoration == horizontalRuleDecoration && + typedOther.textScaleFactor == textScaleFactor; } @override diff --git a/lib/components/flutter_markdown/lib/src/widget.dart b/lib/components/flutter_markdown/lib/src/widget.dart index c9d5cbaf..269e7bbb 100644 --- a/lib/components/flutter_markdown/lib/src/widget.dart +++ b/lib/components/flutter_markdown/lib/src/widget.dart @@ -11,6 +11,7 @@ import 'package:meta/meta.dart'; import 'builder.dart'; import 'style_sheet.dart'; + // typedef Widget ItemDemoBuilder(Map attrs); @@ -22,7 +23,8 @@ typedef void MarkdownTapLinkCallback(String href); /// Creates a format [TextSpan] given a string. /// /// Used by [MarkdownWidget] to highlight the contents of `pre` elements. -abstract class SyntaxHighlighter { // ignore: one_member_abstracts +abstract class SyntaxHighlighter { + // ignore: one_member_abstracts /// Returns the formated [TextSpan] for the given string. TextSpan format(String source); } @@ -49,8 +51,8 @@ abstract class MarkdownWidget extends StatefulWidget { this.onTapLink, this.imageDirectory, this.demoBuilder, - }) : assert(data != null), - super(key: key); + }) : assert(data != null), + super(key: key); /// The Markdown to display. final String data; @@ -72,6 +74,7 @@ abstract class MarkdownWidget extends StatefulWidget { final Directory imageDirectory; final ItemDemoBuilder demoBuilder; + /// Subclasses should override this function to display the given children, /// which are the parsed representation of [data]. @protected @@ -91,7 +94,8 @@ class DemosSyntax extends md.InlineSyntax { } } -class _MarkdownWidgetState extends State implements MarkdownBuilderDelegate { +class _MarkdownWidgetState extends State + implements MarkdownBuilderDelegate { List _children; final List _recognizers = []; @@ -104,9 +108,8 @@ class _MarkdownWidgetState extends State implements MarkdownBuil @override void didUpdateWidget(MarkdownWidget oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.data != oldWidget.data - || widget.styleSheet != oldWidget.styleSheet) - _parseMarkdown(); + if (widget.data != oldWidget.data || + widget.styleSheet != oldWidget.styleSheet) _parseMarkdown(); } @override @@ -116,44 +119,43 @@ class _MarkdownWidgetState extends State implements MarkdownBuil } void _parseMarkdown() { - final MarkdownStyleSheet styleSheet = widget.styleSheet ?? new MarkdownStyleSheet.fromTheme(Theme.of(context)); + final MarkdownStyleSheet styleSheet = widget.styleSheet ?? + new MarkdownStyleSheet.fromTheme(Theme.of(context)); _disposeRecognizers(); // TODO: This can be optimized by doing the split and removing \r at the same time final List lines = widget.data.replaceAll('\r\n', '\n').split('\n'); final md.ExtensionSet extens = new md.ExtensionSet([ - md.FencedCodeBlockSyntax() + md.FencedCodeBlockSyntax() ], [ new DemosSyntax(), new md.InlineHtmlSyntax(), ]); - final md.Document document = new md.Document(encodeHtml: false, extensionSet: extens); + final md.Document document = + new md.Document(encodeHtml: false, extensionSet: extens); final MarkdownBuilder builder = new MarkdownBuilder( - delegate: this, - styleSheet: styleSheet, - imageDirectory: widget.imageDirectory, - demoParser: widget.demoBuilder - ); + delegate: this, + styleSheet: styleSheet, + imageDirectory: widget.imageDirectory, + demoParser: widget.demoBuilder); _children = builder.build(document.parseLines(lines)); } void _disposeRecognizers() { - if (_recognizers.isEmpty) - return; - final List localRecognizers = new List.from(_recognizers); + if (_recognizers.isEmpty) return; + final List localRecognizers = + new List.from(_recognizers); _recognizers.clear(); - for (GestureRecognizer recognizer in localRecognizers) - recognizer.dispose(); + for (GestureRecognizer recognizer in localRecognizers) recognizer.dispose(); } @override GestureRecognizer createLink(String href) { final TapGestureRecognizer recognizer = new TapGestureRecognizer() ..onTap = () { - if (widget.onTapLink != null) - widget.onTapLink(href); - }; + if (widget.onTapLink != null) widget.onTapLink(href); + }; _recognizers.add(recognizer); return recognizer; } @@ -189,19 +191,17 @@ class MarkdownBody extends MarkdownWidget { Directory imageDirectory, ItemDemoBuilder demoBuilder, }) : super( - key: key, - data: data, - styleSheet: styleSheet, - syntaxHighlighter: syntaxHighlighter, - onTapLink: onTapLink, - imageDirectory: imageDirectory, - demoBuilder: demoBuilder - ); + key: key, + data: data, + styleSheet: styleSheet, + syntaxHighlighter: syntaxHighlighter, + onTapLink: onTapLink, + imageDirectory: imageDirectory, + demoBuilder: demoBuilder); @override Widget build(BuildContext context, List children) { - if (children.length == 1) - return children.single; + if (children.length == 1) return children.single; return new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: children, @@ -229,13 +229,13 @@ class Markdown extends MarkdownWidget { Directory imageDirectory, this.padding: const EdgeInsets.all(16.0), }) : super( - key: key, - data: data, - styleSheet: styleSheet, - syntaxHighlighter: syntaxHighlighter, - onTapLink: onTapLink, - imageDirectory: imageDirectory, - ); + key: key, + data: data, + styleSheet: styleSheet, + syntaxHighlighter: syntaxHighlighter, + onTapLink: onTapLink, + imageDirectory: imageDirectory, + ); /// The amount of space by which to inset the children. final EdgeInsets padding; diff --git a/lib/components/full_screen_code_dialog.dart b/lib/components/full_screen_code_dialog.dart index 5a40d9cf..c9eddcce 100644 --- a/lib/components/full_screen_code_dialog.dart +++ b/lib/components/full_screen_code_dialog.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-14 11:42:32 +/// @Author: 一凨 +/// @Date: 2019-01-14 11:42:32 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-14 14:42:00 @@ -24,7 +24,8 @@ class _FullScreenCodeDialogState extends State { void didChangeDependencies() { print('widget.filePath=======${widget.filePath}'); if (widget.filePath != null) { - getExampleCode(context,'${widget.filePath}', DefaultAssetBundle.of(context)) + getExampleCode( + context, '${widget.filePath}', DefaultAssetBundle.of(context)) .then((String code) { if (mounted) { setState(() { @@ -48,6 +49,7 @@ class _FullScreenCodeDialogState extends State { }); } } + @override Widget build(BuildContext context) { final SyntaxHighlighterStyle style = @@ -60,16 +62,17 @@ class _FullScreenCodeDialogState extends State { body = const Center(child: CircularProgressIndicator()); } else { Widget _codeWidget; - try{ + try { DartSyntaxHighlighter(style).format(_exampleCode); _codeWidget = RichText( text: TextSpan( - style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0), - children: [ - DartSyntaxHighlighter(style).format(_exampleCode) - ],), + style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0), + children: [ + DartSyntaxHighlighter(style).format(_exampleCode) + ], + ), ); - }catch (err){ + } catch (err) { _codeWidget = Text(_exampleCode); } body = SingleChildScrollView( diff --git a/lib/components/home_banner.dart b/lib/components/home_banner.dart index 36345cbe..23d46e69 100644 --- a/lib/components/home_banner.dart +++ b/lib/components/home_banner.dart @@ -8,8 +8,7 @@ class HomeBanner extends StatefulWidget { final List bannerStories; final OnTapBannerItem onTap; - HomeBanner(this.bannerStories, this.onTap, {Key key}) - :super(key: key); + HomeBanner(this.bannerStories, this.onTap, {Key key}) : super(key: key); @override State createState() { @@ -27,11 +26,11 @@ class _BannerState extends State { void initState() { super.initState(); controller = PageController(initialPage: realIndex); - timer = Timer.periodic(Duration(seconds: 5), (timer) { // 自动滚动 + timer = Timer.periodic(Duration(seconds: 5), (timer) { + // 自动滚动 /// print(realIndex); controller.animateToPage(realIndex + 1, - duration: Duration(milliseconds: 300), - curve: Curves.linear); + duration: Duration(milliseconds: 300), curve: Curves.linear); }); } @@ -50,7 +49,10 @@ class _BannerState extends State { margin: EdgeInsets.only(top: 10.0, right: 5.0), padding: EdgeInsets.symmetric(horizontal: 6.0, vertical: 2.0), child: Text("${++index}/$itemCount", - style: TextStyle( color: Colors.white70, fontSize: 12.0, fontWeight:FontWeight.bold )), + style: TextStyle( + color: Colors.white70, + fontSize: 12.0, + fontWeight: FontWeight.bold)), ); } @@ -58,43 +60,45 @@ class _BannerState extends State { Widget build(BuildContext context) { return Container( height: 226.0, - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - PageView( - controller: controller, - onPageChanged: _onPageChanged, - children: _buildItems(),), - _buildIndicator(), // 下面的小点 - Positioned(//方法二 - top: 0.0, - right: 0.0, - child: _numberIndicator(context,virtualIndex,widget.bannerStories.length), - ) - ]), + child: Stack(alignment: Alignment.bottomCenter, children: [ + PageView( + controller: controller, + onPageChanged: _onPageChanged, + children: _buildItems(), + ), + _buildIndicator(), // 下面的小点 + Positioned( + //方法二 + top: 0.0, + right: 0.0, + child: _numberIndicator( + context, virtualIndex, widget.bannerStories.length), + ) + ]), ); } - List _buildItems() { // 排列轮播数组 + List _buildItems() { + // 排列轮播数组 List items = []; if (widget.bannerStories.length > 0) { // 头部添加一个尾部Item,模拟循环 items.add( _buildItem(widget.bannerStories[widget.bannerStories.length - 1])); // 正常添加Item - items.addAll( - widget.bannerStories.map((story) => _buildItem(story)).toList( - growable: false)); + items.addAll(widget.bannerStories + .map((story) => _buildItem(story)) + .toList(growable: false)); // 尾部 - items.add( - _buildItem(widget.bannerStories[0])); + items.add(_buildItem(widget.bannerStories[0])); } return items; } Widget _buildItem(StoryModel story) { return GestureDetector( - onTap: () { // 按下 + onTap: () { + // 按下 if (widget.onTap != null) { widget.onTap(story); } @@ -102,14 +106,17 @@ class _BannerState extends State { child: Stack( fit: StackFit.expand, children: [ - Image.network(story.image, fit: BoxFit.cover), + Image.network(story.image, fit: BoxFit.cover), _buildItemTitle(story.title), // 内容文字,大意 - ],),); + ], + ), + ); } Widget _buildItemTitle(String title) { return Container( - decoration: BoxDecoration( /// 背景的渐变色 + decoration: BoxDecoration( + /// 背景的渐变色 gradient: LinearGradient( begin: Alignment.bottomCenter, end: const Alignment(0.0, -0.8), @@ -120,7 +127,10 @@ class _BannerState extends State { child: Container( margin: EdgeInsets.symmetric(vertical: 22.0, horizontal: 16.0), child: Text( - title, style: TextStyle(color: Colors.white, fontSize: 18.0),),), + title, + style: TextStyle(color: Colors.white, fontSize: 18.0), + ), + ), ); } @@ -136,8 +146,7 @@ class _BannerState extends State { color: i == virtualIndex ? Colors.white : Colors.grey))); } return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: indicators); + mainAxisAlignment: MainAxisAlignment.center, children: indicators); } _onPageChanged(int index) { @@ -156,4 +165,4 @@ class _BannerState extends State { } } -typedef void OnTapBannerItem(StoryModel story); \ No newline at end of file +typedef void OnTapBannerItem(StoryModel story); diff --git a/lib/components/list_refresh.dart b/lib/components/list_refresh.dart index c5d3b0d8..22229de3 100644 --- a/lib/components/list_refresh.dart +++ b/lib/components/list_refresh.dart @@ -14,7 +14,8 @@ class ListRefresh extends StatefulWidget { final requestApi; final headerView; - const ListRefresh([this.requestApi, this.renderItem, this.headerView]) : super(); + const ListRefresh([this.requestApi, this.renderItem, this.headerView]) + : super(); @override State createState() => _ListRefreshState(); @@ -91,6 +92,7 @@ class _ListRefreshState extends State { }); } } + // 下拉加载的事件,清空之前list内容,取前X个 // 其实就是列表重置 Future _handleRefresh() async { @@ -158,9 +160,9 @@ class _ListRefreshState extends State { itemCount: items.length + 1, itemBuilder: (context, index) { if (index == 0 && index != items.length) { - if(widget.headerView is Function){ + if (widget.headerView is Function) { return widget.headerView(); - }else { + } else { return Container(height: 0); } } diff --git a/lib/components/list_view_item.dart b/lib/components/list_view_item.dart index c8aa682d..9ceb89d4 100644 --- a/lib/components/list_view_item.dart +++ b/lib/components/list_view_item.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-14 17:53:54 +/// @Author: 一凨 +/// @Date: 2019-01-14 17:53:54 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-14 17:57:51 @@ -8,7 +8,6 @@ import '../routers/application.dart'; import '../routers/routers.dart'; import 'dart:core'; - class ListViewItem extends StatelessWidget { final String itemUrl; final String itemTitle; @@ -17,7 +16,6 @@ class ListViewItem extends StatelessWidget { const ListViewItem({Key key, this.itemUrl, this.itemTitle, this.data}) : super(key: key); - @override Widget build(BuildContext context) { return Card( @@ -27,7 +25,8 @@ class ListViewItem extends StatelessWidget { child: ListTile( onTap: () { // _launchURL(itemUrl, context); - Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}'); + Application.router.navigateTo(context, + '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}'); }, title: Padding( child: Text( diff --git a/lib/components/loading.dart b/lib/components/loading.dart index 659b2ff8..b2c30719 100644 --- a/lib/components/loading.dart +++ b/lib/components/loading.dart @@ -19,11 +19,11 @@ class NetLoadingDialog extends StatefulWidget { NetLoadingDialog( {Key key, - this.loadingText = "loading...", - this.outsideDismiss = true, - this.dismissCallback, - this.loading, - this.requestCallBack}) + this.loadingText = "loading...", + this.outsideDismiss = true, + this.dismissCallback, + this.loading, + this.requestCallBack}) : super(key: key); @override diff --git a/lib/components/markdown.dart b/lib/components/markdown.dart index af055381..6a70666e 100644 --- a/lib/components/markdown.dart +++ b/lib/components/markdown.dart @@ -6,21 +6,18 @@ import 'package:flutter_go/utils/high_light_code.dart'; /// 使用方法 /// MarkdownBody(markdown) final hightlighter = new HighLight(); + class HighLight extends md.SyntaxHighlighter { @override TextSpan format(String source) { - final SyntaxHighlighterStyle style = SyntaxHighlighterStyle.lightThemeStyle(); + final SyntaxHighlighterStyle style = + SyntaxHighlighterStyle.lightThemeStyle(); return TextSpan( style: const TextStyle(fontSize: 10.0), - children: [ - DartSyntaxHighlighter(style).format(source) - ] - ); + children: [DartSyntaxHighlighter(style).format(source)]); } } - - class MarkdownBody extends StatelessWidget { final String data; MarkdownBody(this.data); @@ -28,4 +25,4 @@ class MarkdownBody extends StatelessWidget { Widget build(BuildContext context) { return md.MarkdownBody(data: data, syntaxHighlighter: new HighLight()); } -} \ No newline at end of file +} diff --git a/lib/components/pagination.dart b/lib/components/pagination.dart index e7fdd379..8b8f579d 100644 --- a/lib/components/pagination.dart +++ b/lib/components/pagination.dart @@ -20,10 +20,39 @@ class Pagination extends StatelessWidget { ]; final List arr = [ - {'image': 'https://img.alicdn.com/tfs/TB1W4hMAwHqK1RjSZJnXXbNLpXa-519-260.jpg', 'type': 0, 'id': 9695909, 'url': 'https://www.zhihu.com/question/294145797/answer/551162834', 'title': '为什么阿里巴巴、腾讯和 Google 之类的企业都在使用 Flutter 开发 App?'}, - {'image': 'https://img.alicdn.com/tfs/TB1XmFIApzqK1RjSZSgXXcpAVXa-720-338.jpg', 'type': 0, 'id': 9695859, 'url': 'https://zhuanlan.zhihu.com/p/51696594', 'title': 'Flutter 1.0 正式发布: Google 的便携 UI 工具包'}, - {'image': 'https://img.alicdn.com/tfs/TB1mClCABLoK1RjSZFuXXXn0XXa-600-362.jpg', 'type': 0, 'id': 96956491409, 'url':'https://zhuanlan.zhihu.com/p/53497167','title': 'Flutter 示范应用现已开源 — 万物起源(The History of Everything)'}, - {'image': 'https://img.alicdn.com/tfs/TB1fXxIAAvoK1RjSZFNXXcxMVXa-600-362.jpg', 'type': 0, 'id': 9695816, 'url': 'https://mp.weixin.qq.com/s?__biz=MzAwODY4OTk2Mg==&mid=2652048101&idx=1&sn=20296088e4bd8ca33c5c9991167d9f7d&chksm=808caaa0b7fb23b65c0e5806209f8d86da6732f3a00a70353f3606018339518b0a8656f14dc5&mpsshare=1&scene=2&srcid=0106SZapVysZdIS6Oc5AhNH6&from=timeline&ascene=2&devicetype=android-27&version=27000038&nettype=WIFI&abtest_cookie=BQABAAgACgALABMAFAAFAJ2GHgAjlx4AV5keAJuZHgCcmR4AAAA%3D&lang=zh_CN&pass_ticket=4K1%2FUpsxP4suPj2iubR17wbAP7r9LW9iYrPAC2dppTqv7j7JO5FWMXtcKeBRxueV&wx_header=1', 'title': 'Flutter 与 Material Design 双剑合璧,助您构建精美应用'} + { + 'image': + 'https://img.alicdn.com/tfs/TB1W4hMAwHqK1RjSZJnXXbNLpXa-519-260.jpg', + 'type': 0, + 'id': 9695909, + 'url': 'https://www.zhihu.com/question/294145797/answer/551162834', + 'title': '为什么阿里巴巴、腾讯和 Google 之类的企业都在使用 Flutter 开发 App?' + }, + { + 'image': + 'https://img.alicdn.com/tfs/TB1XmFIApzqK1RjSZSgXXcpAVXa-720-338.jpg', + 'type': 0, + 'id': 9695859, + 'url': 'https://zhuanlan.zhihu.com/p/51696594', + 'title': 'Flutter 1.0 正式发布: Google 的便携 UI 工具包' + }, + { + 'image': + 'https://img.alicdn.com/tfs/TB1mClCABLoK1RjSZFuXXXn0XXa-600-362.jpg', + 'type': 0, + 'id': 96956491409, + 'url': 'https://zhuanlan.zhihu.com/p/53497167', + 'title': 'Flutter 示范应用现已开源 — 万物起源(The History of Everything)' + }, + { + 'image': + 'https://img.alicdn.com/tfs/TB1fXxIAAvoK1RjSZFNXXcxMVXa-600-362.jpg', + 'type': 0, + 'id': 9695816, + 'url': + 'https://mp.weixin.qq.com/s?__biz=MzAwODY4OTk2Mg==&mid=2652048101&idx=1&sn=20296088e4bd8ca33c5c9991167d9f7d&chksm=808caaa0b7fb23b65c0e5806209f8d86da6732f3a00a70353f3606018339518b0a8656f14dc5&mpsshare=1&scene=2&srcid=0106SZapVysZdIS6Oc5AhNH6&from=timeline&ascene=2&devicetype=android-27&version=27000038&nettype=WIFI&abtest_cookie=BQABAAgACgALABMAFAAFAJ2GHgAjlx4AV5keAJuZHgCcmR4AAAA%3D&lang=zh_CN&pass_ticket=4K1%2FUpsxP4suPj2iubR17wbAP7r9LW9iYrPAC2dppTqv7j7JO5FWMXtcKeBRxueV&wx_header=1', + 'title': 'Flutter 与 Material Design 双剑合璧,助您构建精美应用' + } ]; void _launchURL(String url) async { @@ -37,12 +66,12 @@ class Pagination extends StatelessWidget { List _pageSelector(BuildContext context) { List list = []; List bannerStories = []; + /// super.initState(); arr.forEach((item) { bannerStories.add(StoryModel.fromJson(item)); }); - if (arr.length > 0) { list.add(HomeBanner(bannerStories, (story) { _launchURL('${story.url}'); @@ -53,12 +82,10 @@ class Pagination extends StatelessWidget { @override Widget build(BuildContext context) { - return - Column( - key:Key('__header__'), + return Column( + key: Key('__header__'), //physics: AlwaysScrollableScrollPhysics(), //padding: EdgeInsets.only(), - children: _pageSelector(context) - ); + children: _pageSelector(context)); } } diff --git a/lib/components/single_theme_color.dart b/lib/components/single_theme_color.dart index 8a9088a0..5ab67e73 100644 --- a/lib/components/single_theme_color.dart +++ b/lib/components/single_theme_color.dart @@ -13,10 +13,11 @@ class SingleThemeColor extends StatelessWidget { @override Widget build(BuildContext context) { return InkWell( - onTap: (){ - if(ApplicationEvent.event != null){ + onTap: () { + if (ApplicationEvent.event != null) { print('fire ${this.themeColor}'); - ApplicationEvent.event.fire(UserSettingThemeColorEvent(this.themeColor)); + ApplicationEvent.event + .fire(UserSettingThemeColorEvent(this.themeColor)); Navigator.of(context).pop(); } }, diff --git a/lib/components/widget_demo.dart b/lib/components/widget_demo.dart index 1e2d5744..6f5538ca 100644 --- a/lib/components/widget_demo.dart +++ b/lib/components/widget_demo.dart @@ -9,6 +9,7 @@ import 'package:flutter_go/utils/data_utils.dart'; import '../routers/application.dart'; import '../routers/routers.dart'; import '../components/markdown.dart'; + /// import '../model/collection.dart'; import '../widgets/index.dart'; import '../event/event_bus.dart'; @@ -35,6 +36,7 @@ class WidgetDemo extends StatefulWidget { class _WidgetDemoState extends State { bool _hasCollected = false; + /// CollectionControlModel _collectionControl = new CollectionControlModel(); var _collectionIcons; List widgetDemosList = new WidgetDemoList().getDemos(); @@ -141,38 +143,36 @@ class _WidgetDemoState extends State { '${Routes.codeView}?filePath=${Uri.encodeComponent(widget.codeUrl)}'); } } + List> buildPopupMenu() { List> comps = []; if (widget.docUrl != null) { - comps.add( - PopupMenuItem( - value: 'doc', - child: ListTile( - leading: Icon( - Icons.library_books, - size: 22.0, - ), - title: Text('查看文档'), - ), - ) - ); + comps.add(PopupMenuItem( + value: 'doc', + child: ListTile( + leading: Icon( + Icons.library_books, + size: 22.0, + ), + title: Text('查看文档'), + ), + )); } if (widget.codeUrl != null) { - comps.add( - PopupMenuItem( - value: 'code', - child: ListTile( - leading: Icon( - Icons.code, - size: 22.0, - ), - title: Text('查看Demo'), - ), - ) - ); + comps.add(PopupMenuItem( + value: 'code', + child: ListTile( + leading: Icon( + Icons.code, + size: 22.0, + ), + title: Text('查看Demo'), + ), + )); } return comps; } + @override Widget build(BuildContext context) { if (_hasCollected) { @@ -185,7 +185,7 @@ class _WidgetDemoState extends State { new IconButton( tooltip: 'goBack home', onPressed: () { - Navigator.popUntil(context, ModalRoute.withName(Routes.root)); + Navigator.popUntil(context, ModalRoute.withName(Routes.root)); }, icon: Icon(Icons.home), ), @@ -196,12 +196,10 @@ class _WidgetDemoState extends State { ), ]; if (menus.length > 0) { - actions.add( - PopupMenuButton( - onSelected: _selectValue, - itemBuilder: (BuildContext context) => menus, - ) - ); + actions.add(PopupMenuButton( + onSelected: _selectValue, + itemBuilder: (BuildContext context) => menus, + )); } return Scaffold( key: _scaffoldKey, diff --git a/lib/components/widget_item_container.dart b/lib/components/widget_item_container.dart index d7438790..e0eae5a2 100644 --- a/lib/components/widget_item_container.dart +++ b/lib/components/widget_item_container.dart @@ -13,23 +13,21 @@ class WidgetItemContainer extends StatelessWidget { // 所有的可用demos; final List widgetDemosList = new WidgetDemoList().getDemos(); - WidgetItemContainer( - {Key key, - @required this.commonItems, - @required this.columnCount, + WidgetItemContainer({ + Key key, + @required this.commonItems, + @required this.columnCount, // @required this.isWidgetPoint - }) - : super(key: key); + }) : super(key: key); /// 跳转goup void tapToGroup(CategoryComponent cate, BuildContext context) { - Application.router - .navigateTo(context, "/category/${cate.token}", transition: TransitionType.inFromRight); + Application.router.navigateTo(context, "/category/${cate.token}", + transition: TransitionType.inFromRight); } /// 跳转到老的widget界面 void tapToOldWidget(WidgetLeaf leaf, BuildContext context) { - String targetName = leaf.name; String targetRouter = '/category/error/404'; widgetDemosList.forEach((item) { @@ -38,13 +36,15 @@ class WidgetItemContainer extends StatelessWidget { targetRouter = targetRouter.toLowerCase(); } }); - Application.router.navigateTo(context, targetRouter, transition: TransitionType.inFromRight); + Application.router.navigateTo(context, targetRouter, + transition: TransitionType.inFromRight); } /// 跳转到新的标准页 void tapToStandardPage(WidgetLeaf leaf, BuildContext context) { String targetRouter = '/standard-page/${leaf.pageId}'; - Application.router.navigateTo(context, targetRouter, transition: TransitionType.inFromRight); + Application.router.navigateTo(context, targetRouter, + transition: TransitionType.inFromRight); } List _buildColumns(context) { @@ -58,37 +58,37 @@ class WidgetItemContainer extends StatelessWidget { if (addI < length) { CommonItem item = commonItems[addI]; - _listRows.add( Expanded( flex: 1, child: WidgetItem( - title: item.name, - onTap: () { - String type = item.type; + title: item.name, + onTap: () { + String type = item.type; - if (type == "category") { - return tapToGroup(item as CategoryComponent, context); - } - if (type == "widget") { - WidgetLeaf leaf = item as WidgetLeaf; - - if (leaf.display == "standard") { - return tapToStandardPage(leaf, context); - } else { - return tapToOldWidget(leaf, context); + if (type == "category") { + return tapToGroup(item as CategoryComponent, context); } - } + if (type == "widget") { + WidgetLeaf leaf = item as WidgetLeaf; - Application.router - .navigateTo(context, "/category/error/404", transition: TransitionType.inFromRight); - }, - index: addI, - totalCount: length, - rowLength: columnCount, - /// textSize: true ? 'middle' : 'small', - textSize: 'middle' - ), + if (leaf.display == "standard") { + return tapToStandardPage(leaf, context); + } else { + return tapToOldWidget(leaf, context); + } + } + + Application.router.navigateTo( + context, "/category/error/404", + transition: TransitionType.inFromRight); + }, + index: addI, + totalCount: length, + rowLength: columnCount, + + /// textSize: true ? 'middle' : 'small', + textSize: 'middle'), ), ); } else { @@ -116,4 +116,3 @@ class WidgetItemContainer extends StatelessWidget { ); } } - diff --git a/lib/event/event_bus.dart b/lib/event/event_bus.dart index d51e9b10..aafb908e 100644 --- a/lib/event/event_bus.dart +++ b/lib/event/event_bus.dart @@ -1,5 +1,5 @@ import 'package:event_bus/event_bus.dart'; -class ApplicationEvent{ +class ApplicationEvent { static EventBus event; } diff --git a/lib/event/event_model.dart b/lib/event/event_model.dart index ca753ec9..f8062688 100644 --- a/lib/event/event_model.dart +++ b/lib/event/event_model.dart @@ -1,19 +1,19 @@ -class CollectionEvent{ +class CollectionEvent { final String widgetName; final String router; final bool isRemove; // token uid... - CollectionEvent(this.widgetName,this.router,this.isRemove); + CollectionEvent(this.widgetName, this.router, this.isRemove); } -class UserGithubOAuthEvent{ +class UserGithubOAuthEvent { final String loginName; final String token; final bool isSuccess; - UserGithubOAuthEvent(this.loginName,this.token,this.isSuccess); + UserGithubOAuthEvent(this.loginName, this.token, this.isSuccess); } -class UserSettingThemeColorEvent{ +class UserSettingThemeColorEvent { final int settingThemeColor; UserSettingThemeColorEvent(this.settingThemeColor); -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index c8a0c4cd..ea351b28 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,14 +54,17 @@ class _MyAppState extends State { Future _reqsMainPageIsOpen() async { const reqs = 'https://flutter-go.pub/api/isInfoOpen'; var response; - try{ + try { response = await NetUtils.get(reqs, {}); - print('response-$response'); - if(response['status'] == 200 && response['success'] ==true && response['data'] is Map && response['data']['isOpen'] == true) { + print('response-$response'); + if (response['status'] == 200 && + response['success'] == true && + response['data'] is Map && + response['data']['isOpen'] == true) { Application.pageIsOpen = true; print('是否需要展开【业界动态】${Application.pageIsOpen}'); } - }catch(e){ + } catch (e) { print('response-$e'); } return response; @@ -210,11 +213,11 @@ void main() async { new SearchHistoryList(sp); await DataUtils.getWidgetTreeList().then((List json) { - List data = WidgetTree.insertDevPagesToList(json, StandardPages().getLocalList()); + List data = + WidgetTree.insertDevPagesToList(json, StandardPages().getLocalList()); Application.widgetTree = WidgetTree.buildWidgetTree(data); print("Application.widgetTree>>>> ${Application.widgetTree}"); }); db = Provider.db; runApp(new MyApp()); } - diff --git a/lib/model/base.dart b/lib/model/base.dart index 43cb7a55..626409b9 100644 --- a/lib/model/base.dart +++ b/lib/model/base.dart @@ -1,10 +1,10 @@ import 'package:sqflite/sqflite.dart'; -class BaseModel{ - Database db; - final String table = ''; - var query; - BaseModel(this.db){ - query = db.query; - } -} \ No newline at end of file +class BaseModel { + Database db; + final String table = ''; + var query; + BaseModel(this.db) { + query = db.query; + } +} diff --git a/lib/model/collection.dart b/lib/model/collection.dart index 49233bbe..cdc90642 100644 --- a/lib/model/collection.dart +++ b/lib/model/collection.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-07 16:24:42 +/// @Author: 一凨 +/// @Date: 2019-01-07 16:24:42 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-08 17:37:42 @@ -18,8 +18,8 @@ class Collection implements CollectionInterface { Collection({this.name, this.router}); - factory Collection.fromJSON(Map json){ - return Collection(name: json['name'],router: json['router']); + factory Collection.fromJSON(Map json) { + return Collection(name: json['name'], router: json['router']); } Object toMap() { @@ -48,7 +48,7 @@ class CollectionControlModel { Future> getAllCollection() async { List list = await sql.getByCondition(); List resultList = []; - list.forEach((item){ + list.forEach((item) { print('collection item =>> $item'); resultList.add(Collection.fromJSON(item)); }); @@ -68,11 +68,12 @@ class CollectionControlModel { } // 删除 - Future deleteByName(String name) async{ - return await sql.delete(name,'name'); + Future deleteByName(String name) async { + return await sql.delete(name, 'name'); } + // 通过path删除 - Future deleteByPath(String path) async{ - return await sql.delete(path,'router'); + Future deleteByPath(String path) async { + return await sql.delete(path, 'router'); } } diff --git a/lib/model/responseData.dart b/lib/model/responseData.dart index 1b5327e5..b311138c 100644 --- a/lib/model/responseData.dart +++ b/lib/model/responseData.dart @@ -1,25 +1,20 @@ -class ResponseData{ +class ResponseData { int status; bool success; String message; - ResponseData(this.status, this.success,this.message); + ResponseData(this.status, this.success, this.message); ResponseData.fromJson(Map json) : status = json['status'], success = json['success'], - message=json['message']; + message = json['message']; Map toJson() => - { - 'status': status, - 'success': success, - 'messsage': message - }; - + {'status': status, 'success': success, 'messsage': message}; + @override String toString() { return 'status: $status ,success: $success,message: ${message.toString()}'; } - -} \ No newline at end of file +} diff --git a/lib/model/search_history.dart b/lib/model/search_history.dart index ecaef036..26f761db 100644 --- a/lib/model/search_history.dart +++ b/lib/model/search_history.dart @@ -12,7 +12,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_go/utils/shared_preferences.dart'; - class SearchHistory { final String name; final String targetRouter; diff --git a/lib/model/story.dart b/lib/model/story.dart index c8bfbab2..6080d255 100644 --- a/lib/model/story.dart +++ b/lib/model/story.dart @@ -4,20 +4,21 @@ class StoryModel { final int id; final String url; - StoryModel(this.id, this.title, {this.image,this.url}); + StoryModel(this.id, this.title, {this.image, this.url}); StoryModel.fromJson(Map json) - : this(json['id'], json['title'], - image: json['image'] != null ? json['image'] : (json['images'] != null ? json['images'][0] : null), - url: json['url'] != null ? json['url'] : (json['url'] != null ? json['url'][0] : null), - ); + : this( + json['id'], + json['title'], + image: json['image'] != null + ? json['image'] + : (json['images'] != null ? json['images'][0] : null), + url: json['url'] != null + ? json['url'] + : (json['url'] != null ? json['url'][0] : null), + ); Map toJson() { - return { - 'id': id, - 'title': title, - 'image': image, - 'url':url - }; + return {'id': id, 'title': title, 'image': image, 'url': url}; } -} \ No newline at end of file +} diff --git a/lib/model/user_info.dart b/lib/model/user_info.dart index 5007e512..39db2b10 100644 --- a/lib/model/user_info.dart +++ b/lib/model/user_info.dart @@ -14,13 +14,13 @@ class UserInformation { factory UserInformation.fromJson(Map json) { print('fromJOSN $json ${json['id'].runtimeType}'); String name = json['name']; - int userId ; - if(json['name'] == null){ + int userId; + if (json['name'] == null) { name = json['url_name']; } - if(json['id'].runtimeType == int){ + if (json['id'].runtimeType == int) { userId = json['id']; - }else{ + } else { userId = int.parse(json['id']); } return UserInformation( diff --git a/lib/model/user_info_cache.dart b/lib/model/user_info_cache.dart index 8bfe018c..20112882 100644 --- a/lib/model/user_info_cache.dart +++ b/lib/model/user_info_cache.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-07 16:24:42 +/// @Author: 一凨 +/// @Date: 2019-01-07 16:24:42 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-08 17:37:42 @@ -18,8 +18,8 @@ class UserInfo implements UserInfoInterface { UserInfo({this.username, this.password}); - factory UserInfo.fromJSON(Map json){ - return UserInfo(username: json['username'],password: json['password']); + factory UserInfo.fromJSON(Map json) { + return UserInfo(username: json['username'], password: json['password']); } Object toMap() { @@ -39,8 +39,8 @@ class UserInfoControlModel { // 插入新的缓存 Future insert(UserInfo userInfo) { - var result = - sql.insert({'username': userInfo.username, 'password': userInfo.password}); + var result = sql + .insert({'username': userInfo.username, 'password': userInfo.password}); return result; } @@ -48,7 +48,7 @@ class UserInfoControlModel { Future> getAllInfo() async { List list = await sql.getByCondition(); List resultList = []; - list.forEach((item){ + list.forEach((item) { print(item); resultList.add(UserInfo.fromJSON(item)); }); @@ -56,9 +56,7 @@ class UserInfoControlModel { } // 清空表中数据 - Future deleteAll() async{ + Future deleteAll() async { return await sql.deleteAll(); } - - } diff --git a/lib/model/widget.dart b/lib/model/widget.dart index c0f37d0d..936b01da 100644 --- a/lib/model/widget.dart +++ b/lib/model/widget.dart @@ -1,14 +1,10 @@ - import 'dart:async'; import "package:flutter/material.dart"; import "package:flutter_go/routers/application.dart"; import 'package:flutter_go/utils/sql.dart'; -enum treeNode { - CategoryComponent, - WidgetLeaf -} +enum treeNode { CategoryComponent, WidgetLeaf } //typedef aaa @@ -135,6 +131,7 @@ class WidgetControlModel { } return new WidgetPoint.fromJSON(json.first); } + Future> search(String name) async { List json = await sql.search(conditions: {'name': name}); @@ -149,6 +146,7 @@ class WidgetControlModel { return widgets; } } + // 抽象类 abstract class CommonItem { int id; @@ -179,19 +177,17 @@ class CategoryComponent extends CommonItem { CommonItem parent; String token; - List children = []; String type = 'category'; - CategoryComponent({ - @required this.id, - @required this.name, - @required this.parentId, - this.type = 'categoryw', - this.children, - this.parent - }); + CategoryComponent( + {@required this.id, + @required this.name, + @required this.parentId, + this.type = 'categoryw', + this.children, + this.parent}); CategoryComponent.fromJson(Map json) { if (json['id'] != null && json['id'].runtimeType == String) { this.id = int.parse(json['id']); @@ -206,27 +202,25 @@ class CategoryComponent extends CommonItem { if (item is CategoryComponent) { CategoryComponent cate = item; cate.parent = this; - this.children.add( - cate - ); + this.children.add(cate); } if (item is WidgetLeaf) { WidgetLeaf widget = item; widget.parent = this; - this.children.add( - widget - ); + this.children.add(widget); } } + @override CommonItem getChild(String token) { - return children.firstWhere((CommonItem item) => item.token == token, orElse: () => null); + return children.firstWhere((CommonItem item) => item.token == token, + orElse: () => null); } @override CommonItem find(String token, [CommonItem node]) { CommonItem ret; - if (node !=null) { + if (node != null) { if (node.token == token) { return node; } else { @@ -260,14 +254,13 @@ class WidgetLeaf extends CommonItem { CommonItem parent; String type = 'widget'; - WidgetLeaf({ - @required this.id, - @required this.name, - @required this.display, - this.author, - this.path, - this.pageId - }); + WidgetLeaf( + {@required this.id, + @required this.name, + @required this.display, + this.author, + this.path, + this.pageId}); WidgetLeaf.fromJson(Map json) { if (json['id'] != null && json['id'].runtimeType == String) { @@ -286,25 +279,27 @@ class WidgetLeaf extends CommonItem { CommonItem getChild(String token) { return null; } + @override addChildren(Object item) { // TODO: implement addChildren return null; } - CommonItem find(String token, [CommonItem node]){ + CommonItem find(String token, [CommonItem node]) { return null; } } class WidgetTree { // 构建树型结构 - static CategoryComponent buildWidgetTree(List json, [parent]){ + static CategoryComponent buildWidgetTree(List json, [parent]) { CategoryComponent current; if (parent != null) { current = parent; } else { - current = CategoryComponent(id: 0, name: 'root', parentId: null, children: []); + current = + CategoryComponent(id: 0, name: 'root', parentId: null, children: []); } json.forEach((item) { // 归属分类级别 @@ -357,10 +352,13 @@ class WidgetTree { }); return list; } - static CategoryComponent getCommonItemById(List path, CategoryComponent root) { + + static CategoryComponent getCommonItemById( + List path, CategoryComponent root) { print("getCommonItemByPath $path"); print("root $root"); CommonItem childLeaf; + /// int first = path.first; path = path.sublist(1); print("path:::: $path"); @@ -368,7 +366,6 @@ class WidgetTree { // childLeaf = root.getChild(path.first); } - return childLeaf; } -} \ No newline at end of file +} diff --git a/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart index f3f84726..18597449 100644 --- a/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart @@ -8,8 +8,4 @@ import 'src/index.dart'; -var demoWidgets = [ - new Demo() -]; - - \ No newline at end of file +var demoWidgets = [new Demo()]; diff --git a/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/src/index.dart b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/src/index.dart index 1558967c..2ebe44e3 100644 --- a/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/src/index.dart +++ b/lib/page_demo_package/PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/src/index.dart @@ -3,7 +3,6 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; - class Demo extends StatefulWidget { @override _State createState() => _State(); @@ -27,42 +26,45 @@ class Pulltorefresh extends StatefulWidget { } class _PulltorefreshState extends State { - List datas=ListData.getList(); - RefreshController _controller=RefreshController(initialRefresh: false); + List datas = ListData.getList(); + RefreshController _controller = RefreshController(initialRefresh: false); - void _onRefresh() async{ + void _onRefresh() async { await Future.delayed(Duration(milliseconds: 1000)); _controller.refreshCompleted(); } - void _onLoading() async{ + void _onLoading() async { await Future.delayed(Duration(milliseconds: 1500)); - ItemModel model=ItemModel(getRandomColor(), Icons.airplanemode_active, "军事新闻", "俄军大秀战略", - "酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 5000); + ItemModel model = ItemModel(getRandomColor(), Icons.airplanemode_active, + "军事新闻", "俄军大秀战略", "酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 5000); - this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount)); - this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount)); - this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount)); - this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount)); - this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount)); - this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount)); - this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount)); - this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount)); - if(mounted) - setState(() { - - }); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, + model.subTitle, model.des, model.readCount)); + if (mounted) setState(() {}); _controller.loadComplete(); } @override Widget build(BuildContext context) { - Widget _itemBuilder(BuildContext context, int position) { - return Card(child: this.datas[position]); - } + return Scaffold( appBar: AppBar( title: Text("Pulltorefresh"), @@ -78,30 +80,29 @@ class _PulltorefreshState extends State { onRefresh: _onRefresh, onLoading: _onLoading, controller: _controller, - child: ListView.builder(itemBuilder: _itemBuilder,itemCount: this.datas.length), - - + child: ListView.builder( + itemBuilder: _itemBuilder, itemCount: this.datas.length), ), - - ); } - - Color getRandomColor(){ - List colors=[Colors.deepOrange,Colors.amber,Colors.cyan,Colors.green,Colors.red,Colors.yellow]; - int randomValue=Random().nextInt(colors.length); - if(randomValue==colors.length){ - randomValue=colors.length-1; + Color getRandomColor() { + List colors = [ + Colors.deepOrange, + Colors.amber, + Colors.cyan, + Colors.green, + Colors.red, + Colors.yellow + ]; + int randomValue = Random().nextInt(colors.length); + if (randomValue == colors.length) { + randomValue = colors.length - 1; } return colors[randomValue]; - } - } - - class Item extends StatelessWidget { Color color; IconData icon; @@ -129,34 +130,34 @@ class Item extends StatelessWidget { SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text(mainTitle, - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 18.0))), - Expanded(child: Text(subTitle, style: TextStyle(fontSize: 14.0))), - Expanded( - child: Text( - des, - style: TextStyle(fontSize: 13.0), - overflow: TextOverflow.ellipsis, - )), - Expanded( - child: Text("阅读量:${readCount.toString()}", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - color: Colors.redAccent))), - ], - )) + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text(mainTitle, + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18.0))), + Expanded(child: Text(subTitle, style: TextStyle(fontSize: 14.0))), + Expanded( + child: Text( + des, + style: TextStyle(fontSize: 13.0), + overflow: TextOverflow.ellipsis, + )), + Expanded( + child: Text("阅读量:${readCount.toString()}", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + color: Colors.redAccent))), + ], + )) ], ), ); } } -class ItemModel{ +class ItemModel { Color _color; IconData _icon; String _mainTitle; @@ -202,40 +203,44 @@ class ItemModel{ set color(Color value) { _color = value; } - - } -class ListData{ - static List getList(){ - List models=[]; - ItemModel model1= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "俄军大秀战略", - "酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 2999); - ItemModel model2= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "俄“中部”演习", - "俄罗斯卫星网报道称,俄罗斯国防部长绍伊古表示,“中央-2019”战略演习是", 4588); - ItemModel model3= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "中国2.7万吨坞登舰", - "据印度新德里电视台16日报道,印度海军发现7艘中国军舰在印度洋", 7777); - ItemModel model4= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "针对中国?", - "美国空军着力打造军用5G网络,5G+VR,飞行员无需上天就能操控战机;美军濒海", 8888); - ItemModel model5= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "“凯旋”防空导弹系统", - "俄罗斯卫星通讯社报道,俄罗斯北方舰队(Russian Northern Fleet)新闻处", 9999); - ItemModel model6= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "火箭军还有骑兵连", - "迅速对禁区“敌特分子”活动区域进行侦察定位,战斗小分队", 104754); - ItemModel model7= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "侦察兵跨越冰川", - "在海拔5000多米的雪域高原,第77集团军某合成旅的侦察兵们正在进行野外驻训", 47545); - ItemModel model8= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "香港被护商船", - "新京报快讯 据北海舰队官微消息:“感谢海军!”“祖国万岁!”,当地时", 124574); +class ListData { + static List getList() { + List models = []; + ItemModel model1 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "俄军大秀战略", "酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 2999); + ItemModel model2 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "俄“中部”演习", "俄罗斯卫星网报道称,俄罗斯国防部长绍伊古表示,“中央-2019”战略演习是", 4588); + ItemModel model3 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "中国2.7万吨坞登舰", "据印度新德里电视台16日报道,印度海军发现7艘中国军舰在印度洋", 7777); + ItemModel model4 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "针对中国?", "美国空军着力打造军用5G网络,5G+VR,飞行员无需上天就能操控战机;美军濒海", 8888); + ItemModel model5 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "“凯旋”防空导弹系统", "俄罗斯卫星通讯社报道,俄罗斯北方舰队(Russian Northern Fleet)新闻处", 9999); + ItemModel model6 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "火箭军还有骑兵连", "迅速对禁区“敌特分子”活动区域进行侦察定位,战斗小分队", 104754); + ItemModel model7 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "侦察兵跨越冰川", "在海拔5000多米的雪域高原,第77集团军某合成旅的侦察兵们正在进行野外驻训", 47545); + ItemModel model8 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", + "香港被护商船", "新京报快讯 据北海舰队官微消息:“感谢海军!”“祖国万岁!”,当地时", 124574); - models.add(Item(model1.color, model1.icon, model1.mainTitle, model1.subTitle, model1.des, model1.readCount)); - models.add(Item(model2.color, model2.icon, model2.mainTitle, model2.subTitle, model2.des, model2.readCount)); - models.add(Item(model3.color, model3.icon, model3.mainTitle, model3.subTitle, model3.des, model3.readCount)); - models.add(Item(model4.color, model4.icon, model4.mainTitle, model4.subTitle, model4.des, model4.readCount)); - models.add(Item(model5.color, model5.icon, model5.mainTitle, model5.subTitle, model5.des, model5.readCount)); - models.add(Item(model6.color, model6.icon, model6.mainTitle, model6.subTitle, model6.des, model6.readCount)); - models.add(Item(model7.color, model7.icon, model7.mainTitle, model7.subTitle, model7.des, model7.readCount)); - models.add(Item(model8.color, model8.icon, model8.mainTitle, model8.subTitle, model8.des, model8.readCount)); + models.add(Item(model1.color, model1.icon, model1.mainTitle, + model1.subTitle, model1.des, model1.readCount)); + models.add(Item(model2.color, model2.icon, model2.mainTitle, + model2.subTitle, model2.des, model2.readCount)); + models.add(Item(model3.color, model3.icon, model3.mainTitle, + model3.subTitle, model3.des, model3.readCount)); + models.add(Item(model4.color, model4.icon, model4.mainTitle, + model4.subTitle, model4.des, model4.readCount)); + models.add(Item(model5.color, model5.icon, model5.mainTitle, + model5.subTitle, model5.des, model5.readCount)); + models.add(Item(model6.color, model6.icon, model6.mainTitle, + model6.subTitle, model6.des, model6.readCount)); + models.add(Item(model7.color, model7.icon, model7.mainTitle, + model7.subTitle, model7.des, model7.readCount)); + models.add(Item(model8.color, model8.icon, model8.mainTitle, + model8.subTitle, model8.des, model8.readCount)); return models; } } - - diff --git a/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart index 53760649..210ca1e5 100644 --- a/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/page_demo_package/RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart @@ -8,8 +8,4 @@ import 'src/index.dart'; -var demoWidgets = [ - new Demo() -]; - - \ No newline at end of file +var demoWidgets = [new Demo()]; diff --git a/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart index 68193686..e2767909 100644 --- a/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart @@ -8,8 +8,4 @@ import 'src/index.dart'; -var demoWidgets = [ - new Demo() -]; - - \ No newline at end of file +var demoWidgets = [new Demo()]; diff --git a/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/src/index.dart b/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/src/index.dart index e2992379..331dc4c9 100644 --- a/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/src/index.dart +++ b/lib/page_demo_package/demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/src/index.dart @@ -9,8 +9,6 @@ class _State extends State { @override Widget build(BuildContext context) { return Container( - child: RaisedButton(onPressed: () {}, child: Text('我是md中引入的demo')) - ); + child: RaisedButton(onPressed: () {}, child: Text('我是md中引入的demo'))); } } - \ No newline at end of file diff --git a/lib/page_demo_package/index.dart b/lib/page_demo_package/index.dart index c3ed991d..42fb0c10 100644 --- a/lib/page_demo_package/index.dart +++ b/lib/page_demo_package/index.dart @@ -1,10 +1,20 @@ -import 'PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096; -import 'RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096; -import 'demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096; -import 'local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096; -var demoObjects = { - '5553db80_52ae_4241_9c8a_5c9e1f92b096': StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096.demoWidgets, - 'e5f958bc_52ae_4241_9c8a_5c9e1f92b096': StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096.demoWidgets, - '1a29aa8e_32ae_4241_9c8a_5c9e1f92b096': StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096.demoWidgets, - '2c1d57d0_42ae_4241_9c8a_5c9e1f92b096': StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096.demoWidgets -}; \ No newline at end of file +import 'PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096; +import 'RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096; +import 'demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096; +import 'local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096; + +var demoObjects = { + '5553db80_52ae_4241_9c8a_5c9e1f92b096': + StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096 + .demoWidgets, + 'e5f958bc_52ae_4241_9c8a_5c9e1f92b096': + StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096.demoWidgets, + '1a29aa8e_32ae_4241_9c8a_5c9e1f92b096': + StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096.demoWidgets, + '2c1d57d0_42ae_4241_9c8a_5c9e1f92b096': + StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096.demoWidgets +}; diff --git a/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart index 4e315373..75063a13 100644 --- a/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart @@ -8,8 +8,4 @@ import 'src/index.dart'; -var demoWidgets = [ - new Demo() -]; - - \ No newline at end of file +var demoWidgets = [new Demo()]; diff --git a/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/src/index.dart b/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/src/index.dart index d0d3921e..510fb6de 100644 --- a/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/src/index.dart +++ b/lib/page_demo_package/local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/src/index.dart @@ -13,4 +13,3 @@ class _State extends State { ); } } - \ No newline at end of file diff --git a/lib/resources/icon_names.dart b/lib/resources/icon_names.dart index e7562778..a2764f14 100644 --- a/lib/resources/icon_names.dart +++ b/lib/resources/icon_names.dart @@ -9,9 +9,1110 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; class IconNames { - static List names = [Icons.ac_unit,Icons.access_alarm,Icons.access_alarms,Icons.access_time,Icons.accessibility,Icons.accessibility_new,Icons.accessible,Icons.accessible_forward,Icons.account_balance,Icons.account_balance_wallet,Icons.account_box,Icons.account_circle,Icons.adb,Icons.add,Icons.add_a_photo,Icons.add_alarm,Icons.add_alert,Icons.add_box,Icons.add_call,Icons.add_circle,Icons.add_circle_outline,Icons.add_comment,Icons.add_location,Icons.add_photo_alternate,Icons.add_shopping_cart,Icons.add_to_home_screen,Icons.add_to_photos,Icons.add_to_queue,Icons.adjust,Icons.airline_seat_flat,Icons.airline_seat_flat_angled,Icons.airline_seat_individual_suite,Icons.airline_seat_legroom_extra,Icons.airline_seat_legroom_normal,Icons.airline_seat_legroom_reduced,Icons.airline_seat_recline_extra,Icons.airline_seat_recline_normal,Icons.airplanemode_active,Icons.airplanemode_inactive,Icons.airplay,Icons.airport_shuttle,Icons.alarm,Icons.alarm_add,Icons.alarm_off,Icons.alarm_on,Icons.album,Icons.all_inclusive,Icons.all_out,Icons.alternate_email,Icons.android,Icons.announcement,Icons.apps,Icons.archive,Icons.arrow_back,Icons.arrow_back_ios,Icons.arrow_downward,Icons.arrow_drop_down,Icons.arrow_drop_down_circle,Icons.arrow_drop_up,Icons.arrow_forward,Icons.arrow_forward_ios,Icons.arrow_left,Icons.arrow_right,Icons.arrow_upward,Icons.art_track,Icons.aspect_ratio,Icons.assessment,Icons.assignment,Icons.assignment_ind,Icons.assignment_late,Icons.assignment_return,Icons.assignment_returned,Icons.assignment_turned_in,Icons.assistant,Icons.assistant_photo,Icons.atm,Icons.attach_file,Icons.attach_money,Icons.attachment,Icons.audiotrack,Icons.autorenew,Icons.av_timer,Icons.backspace,Icons.backup,Icons.battery_alert,Icons.battery_charging_full,Icons.battery_full,Icons.battery_std,Icons.battery_unknown,Icons.beach_access,Icons.beenhere,Icons.block,Icons.bluetooth,Icons.bluetooth_audio,Icons.bluetooth_connected,Icons.bluetooth_disabled,Icons.bluetooth_searching,Icons.blur_circular,Icons.blur_linear,Icons.blur_off,Icons.blur_on,Icons.book,Icons.bookmark,Icons.bookmark_border,Icons.border_all,Icons.border_bottom,Icons.border_clear,Icons.border_color,Icons.border_horizontal,Icons.border_inner,Icons.border_left,Icons.border_outer,Icons.border_right,Icons.border_style,Icons.border_top,Icons.border_vertical,Icons.branding_watermark,Icons.brightness_1,Icons.brightness_2,Icons.brightness_3,Icons.brightness_4,Icons.brightness_5,Icons.brightness_6,Icons.brightness_7,Icons.brightness_auto,Icons.brightness_high,Icons.brightness_low,Icons.brightness_medium,Icons.broken_image,Icons.brush,Icons.bubble_chart,Icons.bug_report,Icons.build,Icons.burst_mode,Icons.business,Icons.business_center,Icons.cached,Icons.cake,Icons.calendar_today,Icons.calendar_view_day,Icons.call,Icons.call_end,Icons.call_made,Icons.call_merge,Icons.call_missed,Icons.call_missed_outgoing,Icons.call_received,Icons.call_split,Icons.call_to_action,Icons.camera,Icons.camera_alt,Icons.camera_enhance,Icons.camera_front,Icons.camera_rear,Icons.camera_roll,Icons.cancel,Icons.card_giftcard,Icons.card_membership,Icons.card_travel,Icons.casino,Icons.cast,Icons.cast_connected,Icons.category,Icons.center_focus_strong,Icons.center_focus_weak,Icons.change_history,Icons.chat,Icons.chat_bubble,Icons.chat_bubble_outline,Icons.check,Icons.check_box,Icons.check_box_outline_blank,Icons.check_circle,Icons.check_circle_outline,Icons.chevron_left,Icons.chevron_right,Icons.child_care,Icons.child_friendly,Icons.chrome_reader_mode,Icons.class_,Icons.clear,Icons.clear_all,Icons.close,Icons.closed_caption,Icons.cloud,Icons.cloud_circle,Icons.cloud_done,Icons.cloud_download,Icons.cloud_off,Icons.cloud_queue,Icons.cloud_upload,Icons.code,Icons.collections,Icons.collections_bookmark,Icons.color_lens,Icons.colorize,Icons.comment,Icons.compare,Icons.compare_arrows,Icons.computer,Icons.confirmation_number,Icons.contact_mail,Icons.contact_phone,Icons.contacts,Icons.content_copy,Icons.content_cut,Icons.content_paste,Icons.control_point,Icons.control_point_duplicate,Icons.copyright,Icons.create,Icons.create_new_folder,Icons.credit_card,Icons.crop,Icons.crop_3_2,Icons.crop_5_4,Icons.crop_7_5,Icons.crop_16_9,Icons.crop_din,Icons.crop_free,Icons.crop_landscape,Icons.crop_original,Icons.crop_portrait,Icons.crop_rotate,Icons.crop_square,Icons.dashboard,Icons.data_usage,Icons.date_range,Icons.dehaze,Icons.delete,Icons.delete_forever,Icons.delete_outline,Icons.delete_sweep,Icons.departure_board,Icons.description,Icons.desktop_mac,Icons.desktop_windows,Icons.details,Icons.developer_board,Icons.developer_mode,Icons.device_hub,Icons.device_unknown,Icons.devices,Icons.devices_other,Icons.dialer_sip,Icons.dialpad,Icons.directions,Icons.directions_bike,Icons.directions_boat,Icons.directions_bus,Icons.directions_car,Icons.directions_railway,Icons.directions_run,Icons.directions_subway,Icons.directions_transit,Icons.directions_walk,Icons.disc_full,Icons.dns,Icons.do_not_disturb,Icons.do_not_disturb_alt,Icons.do_not_disturb_off,Icons.do_not_disturb_on,Icons.dock,Icons.domain,Icons.done,Icons.done_all,Icons.done_outline,Icons.donut_large,Icons.donut_small,Icons.drafts,Icons.drag_handle,Icons.drive_eta,Icons.dvr,Icons.edit,Icons.edit_attributes,Icons.edit_location,Icons.eject,Icons.email,Icons.enhanced_encryption,Icons.equalizer,Icons.error,Icons.error_outline,Icons.euro_symbol,Icons.ev_station,Icons.event,Icons.event_available,Icons.event_busy,Icons.event_note,Icons.event_seat,Icons.exit_to_app,Icons.expand_less,Icons.expand_more,Icons.explicit,Icons.explore,Icons.exposure,Icons.exposure_neg_1,Icons.exposure_neg_2,Icons.exposure_plus_1,Icons.exposure_plus_2,Icons.exposure_zero,Icons.extension,Icons.face,Icons.fast_forward,Icons.fast_rewind,Icons.fastfood,Icons.favorite,Icons.favorite_border,Icons.featured_play_list,Icons.featured_video,Icons.feedback,Icons.fiber_dvr,Icons.fiber_manual_record,Icons.fiber_new,Icons.fiber_pin,Icons.fiber_smart_record,Icons.file_download,Icons.file_upload,Icons.filter,Icons.filter_1,Icons.filter_2,Icons.filter_3,Icons.filter_4,Icons.filter_5,Icons.filter_6,Icons.filter_7,Icons.filter_8,Icons.filter_9,Icons.filter_9_plus,Icons.filter_b_and_w,Icons.filter_center_focus,Icons.filter_drama,Icons.filter_frames,Icons.filter_hdr,Icons.filter_list,Icons.filter_none,Icons.filter_tilt_shift,Icons.filter_vintage,Icons.find_in_page,Icons.find_replace,Icons.fingerprint,Icons.first_page,Icons.fitness_center,Icons.flag,Icons.flare,Icons.flash_auto,Icons.flash_off,Icons.flash_on,Icons.flight,Icons.flight_land,Icons.flight_takeoff,Icons.flip,Icons.flip_to_back,Icons.flip_to_front,Icons.folder,Icons.folder_open,Icons.folder_shared,Icons.folder_special,Icons.font_download,Icons.format_align_center,Icons.format_align_justify,Icons.format_align_left,Icons.format_align_right,Icons.format_bold,Icons.format_clear,Icons.format_color_fill,Icons.format_color_reset,Icons.format_color_text,Icons.format_indent_decrease,Icons.format_indent_increase,Icons.format_italic,Icons.format_line_spacing,Icons.format_list_bulleted,Icons.format_list_numbered,Icons.format_list_numbered_rtl,Icons.format_paint,Icons.format_quote,Icons.format_shapes,Icons.format_size,Icons.format_strikethrough,Icons.format_textdirection_l_to_r,Icons.format_textdirection_r_to_l,Icons.format_underlined,Icons.forum,Icons.forward,Icons.forward_5,Icons.forward_10,Icons.forward_30,Icons.four_k,Icons.free_breakfast,Icons.fullscreen,Icons.fullscreen_exit,Icons.functions,Icons.g_translate,Icons.gamepad,Icons.games,Icons.gavel,Icons.gesture,Icons.get_app,Icons.gif,Icons.golf_course,Icons.gps_fixed,Icons.gps_not_fixed,Icons.gps_off,Icons.grade,Icons.gradient,Icons.grain,Icons.graphic_eq,Icons.grid_off,Icons.grid_on,Icons.group,Icons.group_add,Icons.group_work,Icons.hd,Icons.hdr_off,Icons.hdr_on,Icons.hdr_strong,Icons.hdr_weak,Icons.headset,Icons.headset_mic,Icons.headset_off,Icons.healing,Icons.hearing,Icons.help,Icons.help_outline,Icons.high_quality,Icons.highlight,Icons.highlight_off,Icons.history,Icons.home,Icons.hot_tub,Icons.hotel,Icons.hourglass_empty,Icons.hourglass_full,Icons.http,Icons.https,Icons.image,Icons.image_aspect_ratio,Icons.import_contacts,Icons.import_export,Icons.important_devices,Icons.inbox,Icons.indeterminate_check_box,Icons.info,Icons.info_outline,Icons.input,Icons.insert_chart,Icons.insert_comment,Icons.insert_drive_file,Icons.insert_emoticon,Icons.insert_invitation,Icons.insert_link,Icons.insert_photo,Icons.invert_colors,Icons.invert_colors_off,Icons.iso,Icons.keyboard,Icons.keyboard_arrow_down,Icons.keyboard_arrow_left,Icons.keyboard_arrow_right,Icons.keyboard_arrow_up,Icons.keyboard_backspace,Icons.keyboard_capslock,Icons.keyboard_hide,Icons.keyboard_return,Icons.keyboard_tab,Icons.keyboard_voice,Icons.kitchen,Icons.label,Icons.label_important,Icons.label_outline,Icons.landscape,Icons.language,Icons.laptop,Icons.laptop_chromebook,Icons.laptop_mac,Icons.laptop_windows,Icons.last_page,Icons.launch,Icons.layers,Icons.layers_clear,Icons.leak_add,Icons.leak_remove,Icons.lens,Icons.library_add,Icons.library_books,Icons.library_music,Icons.lightbulb_outline,Icons.line_style,Icons.line_weight,Icons.linear_scale,Icons.link,Icons.link_off,Icons.linked_camera,Icons.list,Icons.live_help,Icons.live_tv,Icons.local_activity,Icons.local_airport,Icons.local_atm,Icons.local_bar,Icons.local_cafe,Icons.local_car_wash,Icons.local_convenience_store,Icons.local_dining,Icons.local_drink,Icons.local_florist,Icons.local_gas_station,Icons.local_grocery_store,Icons.local_hospital,Icons.local_hotel,Icons.local_laundry_service,Icons.local_library,Icons.local_mall,Icons.local_movies,Icons.local_offer,Icons.local_parking,Icons.local_pharmacy,Icons.local_phone,Icons.local_pizza,Icons.local_play,Icons.local_post_office,Icons.local_printshop,Icons.local_see,Icons.local_shipping,Icons.local_taxi,Icons.location_city,Icons.location_disabled,Icons.location_off,Icons.location_on,Icons.location_searching,Icons.lock,Icons.lock_open,Icons.lock_outline,Icons.looks,Icons.looks_3,Icons.looks_4,Icons.looks_5,Icons.looks_6,Icons.looks_one,Icons.looks_two,Icons.loop,Icons.loupe,Icons.low_priority,Icons.loyalty,Icons.mail,Icons.mail_outline,Icons.map,Icons.markunread,Icons.markunread_mailbox,Icons.maximize,Icons.memory,Icons.menu,Icons.merge_type,Icons.message,Icons.mic,Icons.mic_none,Icons.mic_off,Icons.minimize,Icons.missed_video_call,Icons.mms,Icons.mobile_screen_share,Icons.mode_comment,Icons.mode_edit,Icons.monetization_on,Icons.money_off,Icons.monochrome_photos,Icons.mood,Icons.mood_bad,Icons.more,Icons.more_horiz,Icons.more_vert,Icons.motorcycle,Icons.mouse,Icons.move_to_inbox,Icons.movie,Icons.movie_creation,Icons.movie_filter,Icons.multiline_chart,Icons.music_note,Icons.music_video,Icons.my_location,Icons.nature,Icons.nature_people,Icons.navigate_before,Icons.navigate_next,Icons.navigation,Icons.near_me,Icons.network_cell,Icons.network_check,Icons.network_locked,Icons.network_wifi,Icons.new_releases,Icons.next_week,Icons.nfc,Icons.no_encryption,Icons.no_sim,Icons.not_interested,Icons.not_listed_location,Icons.note,Icons.note_add,Icons.notification_important,Icons.notifications,Icons.notifications_active,Icons.notifications_none,Icons.notifications_off,Icons.notifications_paused,Icons.offline_bolt,Icons.offline_pin,Icons.ondemand_video,Icons.opacity,Icons.open_in_browser,Icons.open_in_new,Icons.open_with,Icons.outlined_flag,Icons.pages,Icons.pageview,Icons.palette,Icons.pan_tool,Icons.panorama,Icons.panorama_fish_eye,Icons.panorama_horizontal,Icons.panorama_vertical,Icons.panorama_wide_angle,Icons.party_mode,Icons.pause,Icons.pause_circle_filled,Icons.pause_circle_outline,Icons.payment,Icons.people,Icons.people_outline,Icons.perm_camera_mic,Icons.perm_contact_calendar,Icons.perm_data_setting,Icons.perm_device_information,Icons.perm_identity,Icons.perm_media,Icons.perm_phone_msg,Icons.perm_scan_wifi,Icons.person,Icons.person_add,Icons.person_outline,Icons.person_pin,Icons.person_pin_circle,Icons.personal_video,Icons.pets,Icons.phone,Icons.phone_android,Icons.phone_bluetooth_speaker,Icons.phone_forwarded,Icons.phone_in_talk,Icons.phone_iphone,Icons.phone_locked,Icons.phone_missed,Icons.phone_paused,Icons.phonelink,Icons.phonelink_erase,Icons.phonelink_lock,Icons.phonelink_off,Icons.phonelink_ring,Icons.phonelink_setup,Icons.photo,Icons.photo_album,Icons.photo_camera,Icons.photo_filter,Icons.photo_library,Icons.photo_size_select_actual,Icons.photo_size_select_large,Icons.photo_size_select_small,Icons.picture_as_pdf,Icons.picture_in_picture,Icons.picture_in_picture_alt,Icons.pie_chart,Icons.pie_chart_outlined,Icons.pin_drop,Icons.place,Icons.play_arrow,Icons.play_circle_filled,Icons.play_circle_outline,Icons.play_for_work,Icons.playlist_add,Icons.playlist_add_check,Icons.playlist_play,Icons.plus_one,Icons.poll,Icons.polymer,Icons.pool,Icons.portable_wifi_off,Icons.portrait,Icons.power,Icons.power_input,Icons.power_settings_new,Icons.pregnant_woman,Icons.present_to_all,Icons.print,Icons.priority_high,Icons.public,Icons.publish,Icons.query_builder,Icons.question_answer,Icons.queue,Icons.queue_music,Icons.queue_play_next,Icons.radio,Icons.radio_button_checked,Icons.radio_button_unchecked,Icons.rate_review,Icons.receipt,Icons.recent_actors,Icons.record_voice_over,Icons.redeem,Icons.redo,Icons.refresh,Icons.remove,Icons.remove_circle,Icons.remove_circle_outline,Icons.remove_from_queue,Icons.remove_red_eye,Icons.remove_shopping_cart,Icons.reorder,Icons.repeat,Icons.repeat_one,Icons.replay,Icons.replay_5,Icons.replay_10,Icons.replay_30,Icons.reply,Icons.reply_all,Icons.report,Icons.report_off,Icons.report_problem,Icons.restaurant,Icons.restaurant_menu,Icons.restore,Icons.restore_from_trash,Icons.restore_page,Icons.ring_volume,Icons.room,Icons.room_service,Icons.rotate_90_degrees_ccw,Icons.rotate_left,Icons.rotate_right,Icons.rounded_corner,Icons.router,Icons.rowing,Icons.rss_feed,Icons.rv_hookup,Icons.satellite,Icons.save,Icons.save_alt,Icons.scanner,Icons.scatter_plot,Icons.schedule,Icons.school,Icons.score,Icons.screen_lock_landscape,Icons.screen_lock_portrait,Icons.screen_lock_rotation,Icons.screen_rotation,Icons.screen_share,Icons.sd_card,Icons.sd_storage,Icons.search,Icons.security,Icons.select_all,Icons.send,Icons.sentiment_dissatisfied,Icons.sentiment_neutral,Icons.sentiment_satisfied,Icons.sentiment_very_dissatisfied,Icons.sentiment_very_satisfied,Icons.settings,Icons.settings_applications,Icons.settings_backup_restore,Icons.settings_bluetooth,Icons.settings_brightness,Icons.settings_cell,Icons.settings_ethernet,Icons.settings_input_antenna,Icons.settings_input_component,Icons.settings_input_composite,Icons.settings_input_hdmi,Icons.settings_input_svideo,Icons.settings_overscan,Icons.settings_phone,Icons.settings_power,Icons.settings_remote,Icons.settings_system_daydream,Icons.settings_voice,Icons.share,Icons.shop,Icons.shop_two,Icons.shopping_basket,Icons.shopping_cart,Icons.short_text,Icons.show_chart,Icons.shuffle,Icons.shutter_speed,Icons.signal_cellular_4_bar,Icons.signal_cellular_connected_no_internet_4_bar,Icons.signal_cellular_no_sim,Icons.signal_cellular_null,Icons.signal_cellular_off,Icons.signal_wifi_4_bar,Icons.signal_wifi_4_bar_lock,Icons.signal_wifi_off,Icons.sim_card,Icons.sim_card_alert,Icons.skip_next,Icons.skip_previous,Icons.slideshow,Icons.slow_motion_video,Icons.smartphone,Icons.smoke_free,Icons.smoking_rooms,Icons.sms,Icons.sms_failed,Icons.snooze,Icons.sort,Icons.sort_by_alpha,Icons.spa,Icons.space_bar,Icons.speaker,Icons.speaker_group,Icons.speaker_notes,Icons.speaker_notes_off,Icons.speaker_phone,Icons.spellcheck,Icons.star,Icons.star_border,Icons.star_half,Icons.stars,Icons.stay_current_landscape,Icons.stay_current_portrait,Icons.stay_primary_landscape,Icons.stay_primary_portrait,Icons.stop,Icons.stop_screen_share,Icons.storage,Icons.store,Icons.store_mall_directory,Icons.straighten,Icons.streetview,Icons.strikethrough_s,Icons.style,Icons.subdirectory_arrow_left,Icons.subdirectory_arrow_right,Icons.subject,Icons.subscriptions,Icons.subtitles,Icons.subway,Icons.supervised_user_circle,Icons.supervisor_account,Icons.surround_sound,Icons.swap_calls,Icons.swap_horiz,Icons.swap_horizontal_circle,Icons.swap_vert,Icons.swap_vertical_circle,Icons.switch_camera,Icons.switch_video,Icons.sync,Icons.sync_disabled,Icons.sync_problem,Icons.system_update,Icons.system_update_alt,Icons.tab,Icons.tab_unselected,Icons.table_chart,Icons.tablet,Icons.tablet_android,Icons.tablet_mac,Icons.tag_faces,Icons.tap_and_play,Icons.terrain,Icons.text_fields,Icons.text_format,Icons.text_rotate_up,Icons.text_rotate_vertical,Icons.text_rotation_angledown,Icons.text_rotation_angleup,Icons.text_rotation_down,Icons.text_rotation_none,Icons.textsms,Icons.texture,Icons.theaters,Icons.threed_rotation,Icons.threesixty,Icons.thumb_down,Icons.thumb_up,Icons.thumbs_up_down,Icons.time_to_leave,Icons.timelapse,Icons.timeline,Icons.timer,Icons.timer_3,Icons.timer_10,Icons.timer_off,Icons.title,Icons.toc,Icons.today,Icons.toll,Icons.tonality,Icons.touch_app,Icons.toys,Icons.track_changes,Icons.traffic,Icons.train,Icons.tram,Icons.transfer_within_a_station,Icons.transform,Icons.transit_enterexit,Icons.translate,Icons.trending_down,Icons.trending_flat,Icons.trending_up,Icons.trip_origin,Icons.tune,Icons.turned_in,Icons.turned_in_not,Icons.tv,Icons.unarchive,Icons.undo,Icons.unfold_less,Icons.unfold_more,Icons.update,Icons.usb,Icons.verified_user,Icons.vertical_align_bottom,Icons.vertical_align_center,Icons.vertical_align_top,Icons.vibration,Icons.video_call,Icons.video_label,Icons.video_library,Icons.videocam,Icons.videocam_off,Icons.videogame_asset,Icons.view_agenda,Icons.view_array,Icons.view_carousel,Icons.view_column,Icons.view_comfy,Icons.view_compact,Icons.view_day,Icons.view_headline,Icons.view_list,Icons.view_module,Icons.view_quilt,Icons.view_stream,Icons.view_week,Icons.vignette,Icons.visibility,Icons.visibility_off,Icons.voice_chat,Icons.voicemail,Icons.volume_down,Icons.volume_mute,Icons.volume_off,Icons.volume_up,Icons.vpn_key,Icons.vpn_lock,Icons.wallpaper,Icons.warning,Icons.watch,Icons.watch_later,Icons.wb_auto,Icons.wb_cloudy,Icons.wb_incandescent,Icons.wb_iridescent,Icons.wb_sunny,Icons.wc,Icons.web,Icons.web_asset,Icons.weekend,Icons.whatshot,Icons.widgets,Icons.wifi,Icons.wifi_lock,Icons.wifi_tethering,Icons.work,Icons.wrap_text,Icons.youtube_searched_for,Icons.zoom_in,Icons.zoom_out,Icons.zoom_out_map]; + static List names = [ + Icons.ac_unit, + Icons.access_alarm, + Icons.access_alarms, + Icons.access_time, + Icons.accessibility, + Icons.accessibility_new, + Icons.accessible, + Icons.accessible_forward, + Icons.account_balance, + Icons.account_balance_wallet, + Icons.account_box, + Icons.account_circle, + Icons.adb, + Icons.add, + Icons.add_a_photo, + Icons.add_alarm, + Icons.add_alert, + Icons.add_box, + Icons.add_call, + Icons.add_circle, + Icons.add_circle_outline, + Icons.add_comment, + Icons.add_location, + Icons.add_photo_alternate, + Icons.add_shopping_cart, + Icons.add_to_home_screen, + Icons.add_to_photos, + Icons.add_to_queue, + Icons.adjust, + Icons.airline_seat_flat, + Icons.airline_seat_flat_angled, + Icons.airline_seat_individual_suite, + Icons.airline_seat_legroom_extra, + Icons.airline_seat_legroom_normal, + Icons.airline_seat_legroom_reduced, + Icons.airline_seat_recline_extra, + Icons.airline_seat_recline_normal, + Icons.airplanemode_active, + Icons.airplanemode_inactive, + Icons.airplay, + Icons.airport_shuttle, + Icons.alarm, + Icons.alarm_add, + Icons.alarm_off, + Icons.alarm_on, + Icons.album, + Icons.all_inclusive, + Icons.all_out, + Icons.alternate_email, + Icons.android, + Icons.announcement, + Icons.apps, + Icons.archive, + Icons.arrow_back, + Icons.arrow_back_ios, + Icons.arrow_downward, + Icons.arrow_drop_down, + Icons.arrow_drop_down_circle, + Icons.arrow_drop_up, + Icons.arrow_forward, + Icons.arrow_forward_ios, + Icons.arrow_left, + Icons.arrow_right, + Icons.arrow_upward, + Icons.art_track, + Icons.aspect_ratio, + Icons.assessment, + Icons.assignment, + Icons.assignment_ind, + Icons.assignment_late, + Icons.assignment_return, + Icons.assignment_returned, + Icons.assignment_turned_in, + Icons.assistant, + Icons.assistant_photo, + Icons.atm, + Icons.attach_file, + Icons.attach_money, + Icons.attachment, + Icons.audiotrack, + Icons.autorenew, + Icons.av_timer, + Icons.backspace, + Icons.backup, + Icons.battery_alert, + Icons.battery_charging_full, + Icons.battery_full, + Icons.battery_std, + Icons.battery_unknown, + Icons.beach_access, + Icons.beenhere, + Icons.block, + Icons.bluetooth, + Icons.bluetooth_audio, + Icons.bluetooth_connected, + Icons.bluetooth_disabled, + Icons.bluetooth_searching, + Icons.blur_circular, + Icons.blur_linear, + Icons.blur_off, + Icons.blur_on, + Icons.book, + Icons.bookmark, + Icons.bookmark_border, + Icons.border_all, + Icons.border_bottom, + Icons.border_clear, + Icons.border_color, + Icons.border_horizontal, + Icons.border_inner, + Icons.border_left, + Icons.border_outer, + Icons.border_right, + Icons.border_style, + Icons.border_top, + Icons.border_vertical, + Icons.branding_watermark, + Icons.brightness_1, + Icons.brightness_2, + Icons.brightness_3, + Icons.brightness_4, + Icons.brightness_5, + Icons.brightness_6, + Icons.brightness_7, + Icons.brightness_auto, + Icons.brightness_high, + Icons.brightness_low, + Icons.brightness_medium, + Icons.broken_image, + Icons.brush, + Icons.bubble_chart, + Icons.bug_report, + Icons.build, + Icons.burst_mode, + Icons.business, + Icons.business_center, + Icons.cached, + Icons.cake, + Icons.calendar_today, + Icons.calendar_view_day, + Icons.call, + Icons.call_end, + Icons.call_made, + Icons.call_merge, + Icons.call_missed, + Icons.call_missed_outgoing, + Icons.call_received, + Icons.call_split, + Icons.call_to_action, + Icons.camera, + Icons.camera_alt, + Icons.camera_enhance, + Icons.camera_front, + Icons.camera_rear, + Icons.camera_roll, + Icons.cancel, + Icons.card_giftcard, + Icons.card_membership, + Icons.card_travel, + Icons.casino, + Icons.cast, + Icons.cast_connected, + Icons.category, + Icons.center_focus_strong, + Icons.center_focus_weak, + Icons.change_history, + Icons.chat, + Icons.chat_bubble, + Icons.chat_bubble_outline, + Icons.check, + Icons.check_box, + Icons.check_box_outline_blank, + Icons.check_circle, + Icons.check_circle_outline, + Icons.chevron_left, + Icons.chevron_right, + Icons.child_care, + Icons.child_friendly, + Icons.chrome_reader_mode, + Icons.class_, + Icons.clear, + Icons.clear_all, + Icons.close, + Icons.closed_caption, + Icons.cloud, + Icons.cloud_circle, + Icons.cloud_done, + Icons.cloud_download, + Icons.cloud_off, + Icons.cloud_queue, + Icons.cloud_upload, + Icons.code, + Icons.collections, + Icons.collections_bookmark, + Icons.color_lens, + Icons.colorize, + Icons.comment, + Icons.compare, + Icons.compare_arrows, + Icons.computer, + Icons.confirmation_number, + Icons.contact_mail, + Icons.contact_phone, + Icons.contacts, + Icons.content_copy, + Icons.content_cut, + Icons.content_paste, + Icons.control_point, + Icons.control_point_duplicate, + Icons.copyright, + Icons.create, + Icons.create_new_folder, + Icons.credit_card, + Icons.crop, + Icons.crop_3_2, + Icons.crop_5_4, + Icons.crop_7_5, + Icons.crop_16_9, + Icons.crop_din, + Icons.crop_free, + Icons.crop_landscape, + Icons.crop_original, + Icons.crop_portrait, + Icons.crop_rotate, + Icons.crop_square, + Icons.dashboard, + Icons.data_usage, + Icons.date_range, + Icons.dehaze, + Icons.delete, + Icons.delete_forever, + Icons.delete_outline, + Icons.delete_sweep, + Icons.departure_board, + Icons.description, + Icons.desktop_mac, + Icons.desktop_windows, + Icons.details, + Icons.developer_board, + Icons.developer_mode, + Icons.device_hub, + Icons.device_unknown, + Icons.devices, + Icons.devices_other, + Icons.dialer_sip, + Icons.dialpad, + Icons.directions, + Icons.directions_bike, + Icons.directions_boat, + Icons.directions_bus, + Icons.directions_car, + Icons.directions_railway, + Icons.directions_run, + Icons.directions_subway, + Icons.directions_transit, + Icons.directions_walk, + Icons.disc_full, + Icons.dns, + Icons.do_not_disturb, + Icons.do_not_disturb_alt, + Icons.do_not_disturb_off, + Icons.do_not_disturb_on, + Icons.dock, + Icons.domain, + Icons.done, + Icons.done_all, + Icons.done_outline, + Icons.donut_large, + Icons.donut_small, + Icons.drafts, + Icons.drag_handle, + Icons.drive_eta, + Icons.dvr, + Icons.edit, + Icons.edit_attributes, + Icons.edit_location, + Icons.eject, + Icons.email, + Icons.enhanced_encryption, + Icons.equalizer, + Icons.error, + Icons.error_outline, + Icons.euro_symbol, + Icons.ev_station, + Icons.event, + Icons.event_available, + Icons.event_busy, + Icons.event_note, + Icons.event_seat, + Icons.exit_to_app, + Icons.expand_less, + Icons.expand_more, + Icons.explicit, + Icons.explore, + Icons.exposure, + Icons.exposure_neg_1, + Icons.exposure_neg_2, + Icons.exposure_plus_1, + Icons.exposure_plus_2, + Icons.exposure_zero, + Icons.extension, + Icons.face, + Icons.fast_forward, + Icons.fast_rewind, + Icons.fastfood, + Icons.favorite, + Icons.favorite_border, + Icons.featured_play_list, + Icons.featured_video, + Icons.feedback, + Icons.fiber_dvr, + Icons.fiber_manual_record, + Icons.fiber_new, + Icons.fiber_pin, + Icons.fiber_smart_record, + Icons.file_download, + Icons.file_upload, + Icons.filter, + Icons.filter_1, + Icons.filter_2, + Icons.filter_3, + Icons.filter_4, + Icons.filter_5, + Icons.filter_6, + Icons.filter_7, + Icons.filter_8, + Icons.filter_9, + Icons.filter_9_plus, + Icons.filter_b_and_w, + Icons.filter_center_focus, + Icons.filter_drama, + Icons.filter_frames, + Icons.filter_hdr, + Icons.filter_list, + Icons.filter_none, + Icons.filter_tilt_shift, + Icons.filter_vintage, + Icons.find_in_page, + Icons.find_replace, + Icons.fingerprint, + Icons.first_page, + Icons.fitness_center, + Icons.flag, + Icons.flare, + Icons.flash_auto, + Icons.flash_off, + Icons.flash_on, + Icons.flight, + Icons.flight_land, + Icons.flight_takeoff, + Icons.flip, + Icons.flip_to_back, + Icons.flip_to_front, + Icons.folder, + Icons.folder_open, + Icons.folder_shared, + Icons.folder_special, + Icons.font_download, + Icons.format_align_center, + Icons.format_align_justify, + Icons.format_align_left, + Icons.format_align_right, + Icons.format_bold, + Icons.format_clear, + Icons.format_color_fill, + Icons.format_color_reset, + Icons.format_color_text, + Icons.format_indent_decrease, + Icons.format_indent_increase, + Icons.format_italic, + Icons.format_line_spacing, + Icons.format_list_bulleted, + Icons.format_list_numbered, + Icons.format_list_numbered_rtl, + Icons.format_paint, + Icons.format_quote, + Icons.format_shapes, + Icons.format_size, + Icons.format_strikethrough, + Icons.format_textdirection_l_to_r, + Icons.format_textdirection_r_to_l, + Icons.format_underlined, + Icons.forum, + Icons.forward, + Icons.forward_5, + Icons.forward_10, + Icons.forward_30, + Icons.four_k, + Icons.free_breakfast, + Icons.fullscreen, + Icons.fullscreen_exit, + Icons.functions, + Icons.g_translate, + Icons.gamepad, + Icons.games, + Icons.gavel, + Icons.gesture, + Icons.get_app, + Icons.gif, + Icons.golf_course, + Icons.gps_fixed, + Icons.gps_not_fixed, + Icons.gps_off, + Icons.grade, + Icons.gradient, + Icons.grain, + Icons.graphic_eq, + Icons.grid_off, + Icons.grid_on, + Icons.group, + Icons.group_add, + Icons.group_work, + Icons.hd, + Icons.hdr_off, + Icons.hdr_on, + Icons.hdr_strong, + Icons.hdr_weak, + Icons.headset, + Icons.headset_mic, + Icons.headset_off, + Icons.healing, + Icons.hearing, + Icons.help, + Icons.help_outline, + Icons.high_quality, + Icons.highlight, + Icons.highlight_off, + Icons.history, + Icons.home, + Icons.hot_tub, + Icons.hotel, + Icons.hourglass_empty, + Icons.hourglass_full, + Icons.http, + Icons.https, + Icons.image, + Icons.image_aspect_ratio, + Icons.import_contacts, + Icons.import_export, + Icons.important_devices, + Icons.inbox, + Icons.indeterminate_check_box, + Icons.info, + Icons.info_outline, + Icons.input, + Icons.insert_chart, + Icons.insert_comment, + Icons.insert_drive_file, + Icons.insert_emoticon, + Icons.insert_invitation, + Icons.insert_link, + Icons.insert_photo, + Icons.invert_colors, + Icons.invert_colors_off, + Icons.iso, + Icons.keyboard, + Icons.keyboard_arrow_down, + Icons.keyboard_arrow_left, + Icons.keyboard_arrow_right, + Icons.keyboard_arrow_up, + Icons.keyboard_backspace, + Icons.keyboard_capslock, + Icons.keyboard_hide, + Icons.keyboard_return, + Icons.keyboard_tab, + Icons.keyboard_voice, + Icons.kitchen, + Icons.label, + Icons.label_important, + Icons.label_outline, + Icons.landscape, + Icons.language, + Icons.laptop, + Icons.laptop_chromebook, + Icons.laptop_mac, + Icons.laptop_windows, + Icons.last_page, + Icons.launch, + Icons.layers, + Icons.layers_clear, + Icons.leak_add, + Icons.leak_remove, + Icons.lens, + Icons.library_add, + Icons.library_books, + Icons.library_music, + Icons.lightbulb_outline, + Icons.line_style, + Icons.line_weight, + Icons.linear_scale, + Icons.link, + Icons.link_off, + Icons.linked_camera, + Icons.list, + Icons.live_help, + Icons.live_tv, + Icons.local_activity, + Icons.local_airport, + Icons.local_atm, + Icons.local_bar, + Icons.local_cafe, + Icons.local_car_wash, + Icons.local_convenience_store, + Icons.local_dining, + Icons.local_drink, + Icons.local_florist, + Icons.local_gas_station, + Icons.local_grocery_store, + Icons.local_hospital, + Icons.local_hotel, + Icons.local_laundry_service, + Icons.local_library, + Icons.local_mall, + Icons.local_movies, + Icons.local_offer, + Icons.local_parking, + Icons.local_pharmacy, + Icons.local_phone, + Icons.local_pizza, + Icons.local_play, + Icons.local_post_office, + Icons.local_printshop, + Icons.local_see, + Icons.local_shipping, + Icons.local_taxi, + Icons.location_city, + Icons.location_disabled, + Icons.location_off, + Icons.location_on, + Icons.location_searching, + Icons.lock, + Icons.lock_open, + Icons.lock_outline, + Icons.looks, + Icons.looks_3, + Icons.looks_4, + Icons.looks_5, + Icons.looks_6, + Icons.looks_one, + Icons.looks_two, + Icons.loop, + Icons.loupe, + Icons.low_priority, + Icons.loyalty, + Icons.mail, + Icons.mail_outline, + Icons.map, + Icons.markunread, + Icons.markunread_mailbox, + Icons.maximize, + Icons.memory, + Icons.menu, + Icons.merge_type, + Icons.message, + Icons.mic, + Icons.mic_none, + Icons.mic_off, + Icons.minimize, + Icons.missed_video_call, + Icons.mms, + Icons.mobile_screen_share, + Icons.mode_comment, + Icons.mode_edit, + Icons.monetization_on, + Icons.money_off, + Icons.monochrome_photos, + Icons.mood, + Icons.mood_bad, + Icons.more, + Icons.more_horiz, + Icons.more_vert, + Icons.motorcycle, + Icons.mouse, + Icons.move_to_inbox, + Icons.movie, + Icons.movie_creation, + Icons.movie_filter, + Icons.multiline_chart, + Icons.music_note, + Icons.music_video, + Icons.my_location, + Icons.nature, + Icons.nature_people, + Icons.navigate_before, + Icons.navigate_next, + Icons.navigation, + Icons.near_me, + Icons.network_cell, + Icons.network_check, + Icons.network_locked, + Icons.network_wifi, + Icons.new_releases, + Icons.next_week, + Icons.nfc, + Icons.no_encryption, + Icons.no_sim, + Icons.not_interested, + Icons.not_listed_location, + Icons.note, + Icons.note_add, + Icons.notification_important, + Icons.notifications, + Icons.notifications_active, + Icons.notifications_none, + Icons.notifications_off, + Icons.notifications_paused, + Icons.offline_bolt, + Icons.offline_pin, + Icons.ondemand_video, + Icons.opacity, + Icons.open_in_browser, + Icons.open_in_new, + Icons.open_with, + Icons.outlined_flag, + Icons.pages, + Icons.pageview, + Icons.palette, + Icons.pan_tool, + Icons.panorama, + Icons.panorama_fish_eye, + Icons.panorama_horizontal, + Icons.panorama_vertical, + Icons.panorama_wide_angle, + Icons.party_mode, + Icons.pause, + Icons.pause_circle_filled, + Icons.pause_circle_outline, + Icons.payment, + Icons.people, + Icons.people_outline, + Icons.perm_camera_mic, + Icons.perm_contact_calendar, + Icons.perm_data_setting, + Icons.perm_device_information, + Icons.perm_identity, + Icons.perm_media, + Icons.perm_phone_msg, + Icons.perm_scan_wifi, + Icons.person, + Icons.person_add, + Icons.person_outline, + Icons.person_pin, + Icons.person_pin_circle, + Icons.personal_video, + Icons.pets, + Icons.phone, + Icons.phone_android, + Icons.phone_bluetooth_speaker, + Icons.phone_forwarded, + Icons.phone_in_talk, + Icons.phone_iphone, + Icons.phone_locked, + Icons.phone_missed, + Icons.phone_paused, + Icons.phonelink, + Icons.phonelink_erase, + Icons.phonelink_lock, + Icons.phonelink_off, + Icons.phonelink_ring, + Icons.phonelink_setup, + Icons.photo, + Icons.photo_album, + Icons.photo_camera, + Icons.photo_filter, + Icons.photo_library, + Icons.photo_size_select_actual, + Icons.photo_size_select_large, + Icons.photo_size_select_small, + Icons.picture_as_pdf, + Icons.picture_in_picture, + Icons.picture_in_picture_alt, + Icons.pie_chart, + Icons.pie_chart_outlined, + Icons.pin_drop, + Icons.place, + Icons.play_arrow, + Icons.play_circle_filled, + Icons.play_circle_outline, + Icons.play_for_work, + Icons.playlist_add, + Icons.playlist_add_check, + Icons.playlist_play, + Icons.plus_one, + Icons.poll, + Icons.polymer, + Icons.pool, + Icons.portable_wifi_off, + Icons.portrait, + Icons.power, + Icons.power_input, + Icons.power_settings_new, + Icons.pregnant_woman, + Icons.present_to_all, + Icons.print, + Icons.priority_high, + Icons.public, + Icons.publish, + Icons.query_builder, + Icons.question_answer, + Icons.queue, + Icons.queue_music, + Icons.queue_play_next, + Icons.radio, + Icons.radio_button_checked, + Icons.radio_button_unchecked, + Icons.rate_review, + Icons.receipt, + Icons.recent_actors, + Icons.record_voice_over, + Icons.redeem, + Icons.redo, + Icons.refresh, + Icons.remove, + Icons.remove_circle, + Icons.remove_circle_outline, + Icons.remove_from_queue, + Icons.remove_red_eye, + Icons.remove_shopping_cart, + Icons.reorder, + Icons.repeat, + Icons.repeat_one, + Icons.replay, + Icons.replay_5, + Icons.replay_10, + Icons.replay_30, + Icons.reply, + Icons.reply_all, + Icons.report, + Icons.report_off, + Icons.report_problem, + Icons.restaurant, + Icons.restaurant_menu, + Icons.restore, + Icons.restore_from_trash, + Icons.restore_page, + Icons.ring_volume, + Icons.room, + Icons.room_service, + Icons.rotate_90_degrees_ccw, + Icons.rotate_left, + Icons.rotate_right, + Icons.rounded_corner, + Icons.router, + Icons.rowing, + Icons.rss_feed, + Icons.rv_hookup, + Icons.satellite, + Icons.save, + Icons.save_alt, + Icons.scanner, + Icons.scatter_plot, + Icons.schedule, + Icons.school, + Icons.score, + Icons.screen_lock_landscape, + Icons.screen_lock_portrait, + Icons.screen_lock_rotation, + Icons.screen_rotation, + Icons.screen_share, + Icons.sd_card, + Icons.sd_storage, + Icons.search, + Icons.security, + Icons.select_all, + Icons.send, + Icons.sentiment_dissatisfied, + Icons.sentiment_neutral, + Icons.sentiment_satisfied, + Icons.sentiment_very_dissatisfied, + Icons.sentiment_very_satisfied, + Icons.settings, + Icons.settings_applications, + Icons.settings_backup_restore, + Icons.settings_bluetooth, + Icons.settings_brightness, + Icons.settings_cell, + Icons.settings_ethernet, + Icons.settings_input_antenna, + Icons.settings_input_component, + Icons.settings_input_composite, + Icons.settings_input_hdmi, + Icons.settings_input_svideo, + Icons.settings_overscan, + Icons.settings_phone, + Icons.settings_power, + Icons.settings_remote, + Icons.settings_system_daydream, + Icons.settings_voice, + Icons.share, + Icons.shop, + Icons.shop_two, + Icons.shopping_basket, + Icons.shopping_cart, + Icons.short_text, + Icons.show_chart, + Icons.shuffle, + Icons.shutter_speed, + Icons.signal_cellular_4_bar, + Icons.signal_cellular_connected_no_internet_4_bar, + Icons.signal_cellular_no_sim, + Icons.signal_cellular_null, + Icons.signal_cellular_off, + Icons.signal_wifi_4_bar, + Icons.signal_wifi_4_bar_lock, + Icons.signal_wifi_off, + Icons.sim_card, + Icons.sim_card_alert, + Icons.skip_next, + Icons.skip_previous, + Icons.slideshow, + Icons.slow_motion_video, + Icons.smartphone, + Icons.smoke_free, + Icons.smoking_rooms, + Icons.sms, + Icons.sms_failed, + Icons.snooze, + Icons.sort, + Icons.sort_by_alpha, + Icons.spa, + Icons.space_bar, + Icons.speaker, + Icons.speaker_group, + Icons.speaker_notes, + Icons.speaker_notes_off, + Icons.speaker_phone, + Icons.spellcheck, + Icons.star, + Icons.star_border, + Icons.star_half, + Icons.stars, + Icons.stay_current_landscape, + Icons.stay_current_portrait, + Icons.stay_primary_landscape, + Icons.stay_primary_portrait, + Icons.stop, + Icons.stop_screen_share, + Icons.storage, + Icons.store, + Icons.store_mall_directory, + Icons.straighten, + Icons.streetview, + Icons.strikethrough_s, + Icons.style, + Icons.subdirectory_arrow_left, + Icons.subdirectory_arrow_right, + Icons.subject, + Icons.subscriptions, + Icons.subtitles, + Icons.subway, + Icons.supervised_user_circle, + Icons.supervisor_account, + Icons.surround_sound, + Icons.swap_calls, + Icons.swap_horiz, + Icons.swap_horizontal_circle, + Icons.swap_vert, + Icons.swap_vertical_circle, + Icons.switch_camera, + Icons.switch_video, + Icons.sync, + Icons.sync_disabled, + Icons.sync_problem, + Icons.system_update, + Icons.system_update_alt, + Icons.tab, + Icons.tab_unselected, + Icons.table_chart, + Icons.tablet, + Icons.tablet_android, + Icons.tablet_mac, + Icons.tag_faces, + Icons.tap_and_play, + Icons.terrain, + Icons.text_fields, + Icons.text_format, + Icons.text_rotate_up, + Icons.text_rotate_vertical, + Icons.text_rotation_angledown, + Icons.text_rotation_angleup, + Icons.text_rotation_down, + Icons.text_rotation_none, + Icons.textsms, + Icons.texture, + Icons.theaters, + Icons.threed_rotation, + Icons.threesixty, + Icons.thumb_down, + Icons.thumb_up, + Icons.thumbs_up_down, + Icons.time_to_leave, + Icons.timelapse, + Icons.timeline, + Icons.timer, + Icons.timer_3, + Icons.timer_10, + Icons.timer_off, + Icons.title, + Icons.toc, + Icons.today, + Icons.toll, + Icons.tonality, + Icons.touch_app, + Icons.toys, + Icons.track_changes, + Icons.traffic, + Icons.train, + Icons.tram, + Icons.transfer_within_a_station, + Icons.transform, + Icons.transit_enterexit, + Icons.translate, + Icons.trending_down, + Icons.trending_flat, + Icons.trending_up, + Icons.trip_origin, + Icons.tune, + Icons.turned_in, + Icons.turned_in_not, + Icons.tv, + Icons.unarchive, + Icons.undo, + Icons.unfold_less, + Icons.unfold_more, + Icons.update, + Icons.usb, + Icons.verified_user, + Icons.vertical_align_bottom, + Icons.vertical_align_center, + Icons.vertical_align_top, + Icons.vibration, + Icons.video_call, + Icons.video_label, + Icons.video_library, + Icons.videocam, + Icons.videocam_off, + Icons.videogame_asset, + Icons.view_agenda, + Icons.view_array, + Icons.view_carousel, + Icons.view_column, + Icons.view_comfy, + Icons.view_compact, + Icons.view_day, + Icons.view_headline, + Icons.view_list, + Icons.view_module, + Icons.view_quilt, + Icons.view_stream, + Icons.view_week, + Icons.vignette, + Icons.visibility, + Icons.visibility_off, + Icons.voice_chat, + Icons.voicemail, + Icons.volume_down, + Icons.volume_mute, + Icons.volume_off, + Icons.volume_up, + Icons.vpn_key, + Icons.vpn_lock, + Icons.wallpaper, + Icons.warning, + Icons.watch, + Icons.watch_later, + Icons.wb_auto, + Icons.wb_cloudy, + Icons.wb_incandescent, + Icons.wb_iridescent, + Icons.wb_sunny, + Icons.wc, + Icons.web, + Icons.web_asset, + Icons.weekend, + Icons.whatshot, + Icons.widgets, + Icons.wifi, + Icons.wifi_lock, + Icons.wifi_tethering, + Icons.work, + Icons.wrap_text, + Icons.youtube_searched_for, + Icons.zoom_in, + Icons.zoom_out, + Icons.zoom_out_map + ]; } class CupertinoIIconNames { - static List names = [CupertinoIcons.add,CupertinoIcons.add_circled,CupertinoIcons.add_circled_solid,CupertinoIcons.back,CupertinoIcons.battery_25_percent,CupertinoIcons.battery_75_percent,CupertinoIcons.battery_charging,CupertinoIcons.battery_empty,CupertinoIcons.battery_full,CupertinoIcons.bluetooth,CupertinoIcons.book,CupertinoIcons.book_solid,CupertinoIcons.bookmark,CupertinoIcons.bookmark_solid,CupertinoIcons.check_mark,CupertinoIcons.check_mark_circled,CupertinoIcons.check_mark_circled_solid,CupertinoIcons.clear,CupertinoIcons.clear_circled,CupertinoIcons.clear_circled_solid,CupertinoIcons.clear_thick,CupertinoIcons.clear_thick_circled,CupertinoIcons.clock,CupertinoIcons.clock_solid,CupertinoIcons.collections,CupertinoIcons.collections_solid,CupertinoIcons.conversation_bubble,CupertinoIcons.create,CupertinoIcons.create_solid,CupertinoIcons.delete,CupertinoIcons.delete_simple,CupertinoIcons.delete_solid,CupertinoIcons.down_arrow,CupertinoIcons.ellipsis,CupertinoIcons.eye,CupertinoIcons.eye_solid,CupertinoIcons.flag,CupertinoIcons.folder,CupertinoIcons.folder_open,CupertinoIcons.folder_solid,CupertinoIcons.forward,CupertinoIcons.fullscreen,CupertinoIcons.fullscreen_exit,CupertinoIcons.gear,CupertinoIcons.gear_big,CupertinoIcons.gear_solid,CupertinoIcons.group,CupertinoIcons.group_solid,CupertinoIcons.home,CupertinoIcons.info,CupertinoIcons.left_chevron,CupertinoIcons.location,CupertinoIcons.location_solid,CupertinoIcons.loop,CupertinoIcons.loop_thick,CupertinoIcons.mail,CupertinoIcons.mail_solid,CupertinoIcons.mic,CupertinoIcons.mic_off,CupertinoIcons.mic_solid,CupertinoIcons.minus_circled,CupertinoIcons.music_note,CupertinoIcons.padlock,CupertinoIcons.padlock_solid,CupertinoIcons.pause,CupertinoIcons.pause_solid,CupertinoIcons.pen,CupertinoIcons.pencil,CupertinoIcons.person,CupertinoIcons.person_add,CupertinoIcons.person_add_solid,CupertinoIcons.person_solid,CupertinoIcons.phone,CupertinoIcons.phone_solid,CupertinoIcons.photo_camera,CupertinoIcons.photo_camera_solid,CupertinoIcons.play_arrow,CupertinoIcons.play_arrow_solid,CupertinoIcons.plus_circled,CupertinoIcons.profile_circled,CupertinoIcons.refresh,CupertinoIcons.refresh_bold,CupertinoIcons.refresh_circled,CupertinoIcons.refresh_circled_solid,CupertinoIcons.refresh_thick,CupertinoIcons.refresh_thin,CupertinoIcons.reply,CupertinoIcons.reply_all,CupertinoIcons.reply_thick_solid,CupertinoIcons.restart,CupertinoIcons.right_chevron,CupertinoIcons.search,CupertinoIcons.settings,CupertinoIcons.settings_solid,CupertinoIcons.share,CupertinoIcons.share_solid,CupertinoIcons.share_up,CupertinoIcons.shopping_cart,CupertinoIcons.shuffle_thick,CupertinoIcons.switch_camera,CupertinoIcons.switch_camera_solid,CupertinoIcons.tag,CupertinoIcons.tag_solid,CupertinoIcons.tags,CupertinoIcons.tags_solid,CupertinoIcons.time,CupertinoIcons.time_solid,CupertinoIcons.up_arrow,CupertinoIcons.video_camera,CupertinoIcons.video_camera_solid,CupertinoIcons.volume_down,CupertinoIcons.volume_mute,CupertinoIcons.volume_off,CupertinoIcons.volume_up]; -} \ No newline at end of file + static List names = [ + CupertinoIcons.add, + CupertinoIcons.add_circled, + CupertinoIcons.add_circled_solid, + CupertinoIcons.back, + CupertinoIcons.battery_25_percent, + CupertinoIcons.battery_75_percent, + CupertinoIcons.battery_charging, + CupertinoIcons.battery_empty, + CupertinoIcons.battery_full, + CupertinoIcons.bluetooth, + CupertinoIcons.book, + CupertinoIcons.book_solid, + CupertinoIcons.bookmark, + CupertinoIcons.bookmark_solid, + CupertinoIcons.check_mark, + CupertinoIcons.check_mark_circled, + CupertinoIcons.check_mark_circled_solid, + CupertinoIcons.clear, + CupertinoIcons.clear_circled, + CupertinoIcons.clear_circled_solid, + CupertinoIcons.clear_thick, + CupertinoIcons.clear_thick_circled, + CupertinoIcons.clock, + CupertinoIcons.clock_solid, + CupertinoIcons.collections, + CupertinoIcons.collections_solid, + CupertinoIcons.conversation_bubble, + CupertinoIcons.create, + CupertinoIcons.create_solid, + CupertinoIcons.delete, + CupertinoIcons.delete_simple, + CupertinoIcons.delete_solid, + CupertinoIcons.down_arrow, + CupertinoIcons.ellipsis, + CupertinoIcons.eye, + CupertinoIcons.eye_solid, + CupertinoIcons.flag, + CupertinoIcons.folder, + CupertinoIcons.folder_open, + CupertinoIcons.folder_solid, + CupertinoIcons.forward, + CupertinoIcons.fullscreen, + CupertinoIcons.fullscreen_exit, + CupertinoIcons.gear, + CupertinoIcons.gear_big, + CupertinoIcons.gear_solid, + CupertinoIcons.group, + CupertinoIcons.group_solid, + CupertinoIcons.home, + CupertinoIcons.info, + CupertinoIcons.left_chevron, + CupertinoIcons.location, + CupertinoIcons.location_solid, + CupertinoIcons.loop, + CupertinoIcons.loop_thick, + CupertinoIcons.mail, + CupertinoIcons.mail_solid, + CupertinoIcons.mic, + CupertinoIcons.mic_off, + CupertinoIcons.mic_solid, + CupertinoIcons.minus_circled, + CupertinoIcons.music_note, + CupertinoIcons.padlock, + CupertinoIcons.padlock_solid, + CupertinoIcons.pause, + CupertinoIcons.pause_solid, + CupertinoIcons.pen, + CupertinoIcons.pencil, + CupertinoIcons.person, + CupertinoIcons.person_add, + CupertinoIcons.person_add_solid, + CupertinoIcons.person_solid, + CupertinoIcons.phone, + CupertinoIcons.phone_solid, + CupertinoIcons.photo_camera, + CupertinoIcons.photo_camera_solid, + CupertinoIcons.play_arrow, + CupertinoIcons.play_arrow_solid, + CupertinoIcons.plus_circled, + CupertinoIcons.profile_circled, + CupertinoIcons.refresh, + CupertinoIcons.refresh_bold, + CupertinoIcons.refresh_circled, + CupertinoIcons.refresh_circled_solid, + CupertinoIcons.refresh_thick, + CupertinoIcons.refresh_thin, + CupertinoIcons.reply, + CupertinoIcons.reply_all, + CupertinoIcons.reply_thick_solid, + CupertinoIcons.restart, + CupertinoIcons.right_chevron, + CupertinoIcons.search, + CupertinoIcons.settings, + CupertinoIcons.settings_solid, + CupertinoIcons.share, + CupertinoIcons.share_solid, + CupertinoIcons.share_up, + CupertinoIcons.shopping_cart, + CupertinoIcons.shuffle_thick, + CupertinoIcons.switch_camera, + CupertinoIcons.switch_camera_solid, + CupertinoIcons.tag, + CupertinoIcons.tag_solid, + CupertinoIcons.tags, + CupertinoIcons.tags_solid, + CupertinoIcons.time, + CupertinoIcons.time_solid, + CupertinoIcons.up_arrow, + CupertinoIcons.video_camera, + CupertinoIcons.video_camera_solid, + CupertinoIcons.volume_down, + CupertinoIcons.volume_mute, + CupertinoIcons.volume_off, + CupertinoIcons.volume_up + ]; +} diff --git a/lib/resources/shared_preferences_keys.dart b/lib/resources/shared_preferences_keys.dart index ad7398ae..940485ea 100644 --- a/lib/resources/shared_preferences_keys.dart +++ b/lib/resources/shared_preferences_keys.dart @@ -1,4 +1,3 @@ - // Created with Android Studio. // User: 三帆 // Date: 31/01/2019 @@ -7,7 +6,6 @@ // target: xxx // - //enum DateType { // Int, // Double, @@ -27,12 +25,12 @@ class SharedPreferencesKeys { /// boolean /// 用于欢迎页面. 只有第一次访问才会显示. 或者手动将这个值设为false static String showWelcome = 'loginWelcone'; - /// json + + /// json /// 用于存放搜索页的搜索数据. /// [{ /// name: 'name' - /// + /// /// }] static String searchHistory = 'searchHistory'; } - diff --git a/lib/resources/widget_name_to_icon.dart b/lib/resources/widget_name_to_icon.dart index 82f2593f..5519b822 100644 --- a/lib/resources/widget_name_to_icon.dart +++ b/lib/resources/widget_name_to_icon.dart @@ -1,165 +1,166 @@ import 'package:flutter/material.dart'; + class WidgetName2Icon { - static Map icons = { + static Map icons = { "Developer": Icons.developer_mode, - "Standard": Icons.pages , - "Element":Icons.explicit, - "Components":Icons.extension, - "Theme":Icons.filter_b_and_w, - "Form":Icons.table_chart, - "Frame":Icons.aspect_ratio, - "Media":Icons.subscriptions, - "Input":Icons.input, - "TextField":Icons.text_fields, - "Checkbox":Icons.check_box, - "CheckboxListTile":Icons.playlist_add_check, - "Button":Icons.aspect_ratio, - "FlatButton":Icons.outlined_flag, - "RaisedButton":Icons.picture_in_picture_alt, - "IconButton":Icons.import_contacts, - "PopupMenuButton":Icons.power_input, - "FloatingActionButton":Icons.flash_off, - "RawMaterialButton":Icons.rowing, - "DropdownButton":Icons.drag_handle, - "OutlineButton":Icons.done_outline, - "Text":Icons.text_format, - "RichText":Icons.text_rotation_angleup, - "Radio":Icons.radio_button_checked, - "RadioListTile":Icons.list, - "Slider":Icons.slideshow, - "SliderTheme":Icons.theaters, - "SliderComponentShape":Icons.format_shapes, - "SliderThemeData":Icons.data_usage, - "Switch":Icons.switch_camera, - "SwitchListTile":Icons.switch_video, - "AnimatedSwitcher":Icons.airplanemode_active, - "Align":Icons.format_align_left, - "Stack":Icons.storage, - "IndexedStack":Icons.star, - "Layout":Icons.layers, - "Row":Icons.recent_actors, - "Column":Icons.cloud_off, - "Container":Icons.edit_location, - "Center":Icons.gesture, - "Box":Icons.hdr_strong, - "ConstrainedBox":Icons.account_box, - "OverflowBox":Icons.email, - "DecoratedBox":Icons.settings_overscan, - "FittedBox":Icons.data_usage, - "LimitedBox":Icons.format_align_justify, - "RenderBox":Icons.error, - "RotateBox":Icons.navigate_next, - "SizedOverflowBox":Icons.undo, - "TextBox":Icons.wallpaper, - "UnconstrainedBox":Icons.account_box, - "Axis":Icons.access_alarm, - "MainAxis":Icons.add_circle, - "CrossAxis":Icons.dehaze, - "FlipAxis":Icons.zoom_out, - "Expanded":Icons.all_out, - "Spacing":Icons.crop_free, - "Padding":Icons.crop, - "SliverPadding":Icons.euro_symbol, - "AnimatedPadding":Icons.zoom_out_map, - "Table":Icons.table_chart, - "Image":Icons.image, - "AssetImage":Icons.image_aspect_ratio, - "DecorationImage":Icons.picture_in_picture, - "DecorationImagePainter":Icons.image, - "ExactAssetImage":Icons.assessment, - "FadeInImage":Icons.flip, - "FileImage":Icons.filter, - "NetworkImage":Icons.network_wifi, - "RawImage":Icons.text_rotation_down, - "PaintImage":Icons.format_paint, - "PrecacheImage":Icons.perm_camera_mic, - "MemoryImage":Icons.memory, - "Icon":Icons.event_available, - "ImageIcon":Icons.image, - "IconTheme":Icons.table_chart, - "IconData":Icons.date_range, - "IconThemeData":Icons.insert_comment, - "Canvas":Icons.edit, - "PainterPath":Icons.gesture, - "CircleProgressBarPainter":Icons.av_timer, - "PainterSketch":Icons.touch_app, - "Material":Icons.android, - "MaterialApp":Icons.android, - "MaterialButton":Icons.speaker, - "MaterialGap":Icons.view_week, - "MaterialSlice":Icons.format_list_numbered_rtl , - "MaterialColor":Icons.color_lens, - "Cupertino":Icons.phone_iphone, - "Scroll":Icons.swap_vertical_circle, - "Tab":Icons.tab, - "Menu":Icons.menu, - "PopupMenuDivider":Icons.remove, - "PopupMenuEntry":Icons.menu, - "CheckedPopupMenuItem":Icons.playlist_add_check, - "DropdownMenuItem":Icons.playlist_play, - "Grid":Icons.grid_on, - "Scaffold":Icons.local_convenience_store, - "Dialog":Icons.add_alert, - "Bar":Icons.border_horizontal, - "Card":Icons.credit_card, - "Panel":Icons.video_label, - "Navigation":Icons.navigation, - "List":Icons.list, - "ScrollView":Icons.move_to_inbox, - "Scrollable":Icons.swap_vertical_circle, - "ScrollbarPainter":Icons.format_paint, - "ScrollMetrics":Icons.camera, - "ScrollPhysics":Icons.control_point_duplicate, - "BoxScrollView":Icons.inbox, - "Chip":Icons.sim_card, - "ChipTheme":Icons.sd_card, - "CustomScrollView":Icons.autorenew, - "NestedScrollView":Icons.panorama_fish_eye, - "ChipThemeData":Icons.sim_card_alert, - "ChoiceChip":Icons.insert_drive_file, - "FilterChip":Icons.note_add, - "InputChip":Icons.restore_page, - "RawChip":Icons.save, - "LinearProgressIndicator":Icons.trending_flat , - "CircularProgressIndicator":Icons.rotate_left , - "ExpansionPanel":Icons.view_stream, - "ExpansionPanelList":Icons.view_headline, - "BottomNavigationBar":Icons.call_to_action, - "ListView":Icons.view_list , - "ListBody":Icons.list , - "AnimatedList":Icons.format_line_spacing , - "SliverAppBar":Icons.content_paste, - "AppBar":Icons.card_membership, - "BottomAppBar":Icons.call_to_action, - "BottomNavigationBarItem":Icons.crop_original, - "FlexibleSpaceBar":Icons.aspect_ratio, - "ButtonBar":Icons.branding_watermark, - "SnackBar":Icons.sms_failed, - "Progress":Icons.sync, - "Pick":Icons.event_note, - "DayPicker":Icons.calendar_today, - "MonthPicker":Icons.date_range, - "YearPicker":Icons.event_busy, - "ShowdatePicker":Icons.event, - "MaterialPageRoute":Icons.album, - "MaterialAccentColor":Icons.brush, - "SnackBarAction":Icons.assessment, - "TabBar":Icons.burst_mode, - "AlertDialog":Icons.sms_failed, - "AboutDialog":Icons.sms, - "SimpleDialog":Icons.message, - "ScaffoldState":Icons.local_bar, - "GridTile":Icons.apps, - "MergeableMaterialItem":Icons.view_list, - "CupertinoApp":Icons.face, - "CupertinoButton":Icons.crop_7_5, - "CupertinoColors":Icons.color_lens, - "CupertinoIcons":Icons.insert_emoticon, - "CupertinoNavigationBar":Icons.payment, - "CupertinoPageRoute":Icons.router, - "CupertinoPageScaffold":Icons.pages, - "CupertinoPicker":Icons.add_alarm, - "CupertinoPopupSurface":Icons.center_focus_weak, + "Standard": Icons.pages, + "Element": Icons.explicit, + "Components": Icons.extension, + "Theme": Icons.filter_b_and_w, + "Form": Icons.table_chart, + "Frame": Icons.aspect_ratio, + "Media": Icons.subscriptions, + "Input": Icons.input, + "TextField": Icons.text_fields, + "Checkbox": Icons.check_box, + "CheckboxListTile": Icons.playlist_add_check, + "Button": Icons.aspect_ratio, + "FlatButton": Icons.outlined_flag, + "RaisedButton": Icons.picture_in_picture_alt, + "IconButton": Icons.import_contacts, + "PopupMenuButton": Icons.power_input, + "FloatingActionButton": Icons.flash_off, + "RawMaterialButton": Icons.rowing, + "DropdownButton": Icons.drag_handle, + "OutlineButton": Icons.done_outline, + "Text": Icons.text_format, + "RichText": Icons.text_rotation_angleup, + "Radio": Icons.radio_button_checked, + "RadioListTile": Icons.list, + "Slider": Icons.slideshow, + "SliderTheme": Icons.theaters, + "SliderComponentShape": Icons.format_shapes, + "SliderThemeData": Icons.data_usage, + "Switch": Icons.switch_camera, + "SwitchListTile": Icons.switch_video, + "AnimatedSwitcher": Icons.airplanemode_active, + "Align": Icons.format_align_left, + "Stack": Icons.storage, + "IndexedStack": Icons.star, + "Layout": Icons.layers, + "Row": Icons.recent_actors, + "Column": Icons.cloud_off, + "Container": Icons.edit_location, + "Center": Icons.gesture, + "Box": Icons.hdr_strong, + "ConstrainedBox": Icons.account_box, + "OverflowBox": Icons.email, + "DecoratedBox": Icons.settings_overscan, + "FittedBox": Icons.data_usage, + "LimitedBox": Icons.format_align_justify, + "RenderBox": Icons.error, + "RotateBox": Icons.navigate_next, + "SizedOverflowBox": Icons.undo, + "TextBox": Icons.wallpaper, + "UnconstrainedBox": Icons.account_box, + "Axis": Icons.access_alarm, + "MainAxis": Icons.add_circle, + "CrossAxis": Icons.dehaze, + "FlipAxis": Icons.zoom_out, + "Expanded": Icons.all_out, + "Spacing": Icons.crop_free, + "Padding": Icons.crop, + "SliverPadding": Icons.euro_symbol, + "AnimatedPadding": Icons.zoom_out_map, + "Table": Icons.table_chart, + "Image": Icons.image, + "AssetImage": Icons.image_aspect_ratio, + "DecorationImage": Icons.picture_in_picture, + "DecorationImagePainter": Icons.image, + "ExactAssetImage": Icons.assessment, + "FadeInImage": Icons.flip, + "FileImage": Icons.filter, + "NetworkImage": Icons.network_wifi, + "RawImage": Icons.text_rotation_down, + "PaintImage": Icons.format_paint, + "PrecacheImage": Icons.perm_camera_mic, + "MemoryImage": Icons.memory, + "Icon": Icons.event_available, + "ImageIcon": Icons.image, + "IconTheme": Icons.table_chart, + "IconData": Icons.date_range, + "IconThemeData": Icons.insert_comment, + "Canvas": Icons.edit, + "PainterPath": Icons.gesture, + "CircleProgressBarPainter": Icons.av_timer, + "PainterSketch": Icons.touch_app, + "Material": Icons.android, + "MaterialApp": Icons.android, + "MaterialButton": Icons.speaker, + "MaterialGap": Icons.view_week, + "MaterialSlice": Icons.format_list_numbered_rtl, + "MaterialColor": Icons.color_lens, + "Cupertino": Icons.phone_iphone, + "Scroll": Icons.swap_vertical_circle, + "Tab": Icons.tab, + "Menu": Icons.menu, + "PopupMenuDivider": Icons.remove, + "PopupMenuEntry": Icons.menu, + "CheckedPopupMenuItem": Icons.playlist_add_check, + "DropdownMenuItem": Icons.playlist_play, + "Grid": Icons.grid_on, + "Scaffold": Icons.local_convenience_store, + "Dialog": Icons.add_alert, + "Bar": Icons.border_horizontal, + "Card": Icons.credit_card, + "Panel": Icons.video_label, + "Navigation": Icons.navigation, + "List": Icons.list, + "ScrollView": Icons.move_to_inbox, + "Scrollable": Icons.swap_vertical_circle, + "ScrollbarPainter": Icons.format_paint, + "ScrollMetrics": Icons.camera, + "ScrollPhysics": Icons.control_point_duplicate, + "BoxScrollView": Icons.inbox, + "Chip": Icons.sim_card, + "ChipTheme": Icons.sd_card, + "CustomScrollView": Icons.autorenew, + "NestedScrollView": Icons.panorama_fish_eye, + "ChipThemeData": Icons.sim_card_alert, + "ChoiceChip": Icons.insert_drive_file, + "FilterChip": Icons.note_add, + "InputChip": Icons.restore_page, + "RawChip": Icons.save, + "LinearProgressIndicator": Icons.trending_flat, + "CircularProgressIndicator": Icons.rotate_left, + "ExpansionPanel": Icons.view_stream, + "ExpansionPanelList": Icons.view_headline, + "BottomNavigationBar": Icons.call_to_action, + "ListView": Icons.view_list, + "ListBody": Icons.list, + "AnimatedList": Icons.format_line_spacing, + "SliverAppBar": Icons.content_paste, + "AppBar": Icons.card_membership, + "BottomAppBar": Icons.call_to_action, + "BottomNavigationBarItem": Icons.crop_original, + "FlexibleSpaceBar": Icons.aspect_ratio, + "ButtonBar": Icons.branding_watermark, + "SnackBar": Icons.sms_failed, + "Progress": Icons.sync, + "Pick": Icons.event_note, + "DayPicker": Icons.calendar_today, + "MonthPicker": Icons.date_range, + "YearPicker": Icons.event_busy, + "ShowdatePicker": Icons.event, + "MaterialPageRoute": Icons.album, + "MaterialAccentColor": Icons.brush, + "SnackBarAction": Icons.assessment, + "TabBar": Icons.burst_mode, + "AlertDialog": Icons.sms_failed, + "AboutDialog": Icons.sms, + "SimpleDialog": Icons.message, + "ScaffoldState": Icons.local_bar, + "GridTile": Icons.apps, + "MergeableMaterialItem": Icons.view_list, + "CupertinoApp": Icons.face, + "CupertinoButton": Icons.crop_7_5, + "CupertinoColors": Icons.color_lens, + "CupertinoIcons": Icons.insert_emoticon, + "CupertinoNavigationBar": Icons.payment, + "CupertinoPageRoute": Icons.router, + "CupertinoPageScaffold": Icons.pages, + "CupertinoPicker": Icons.add_alarm, + "CupertinoPopupSurface": Icons.center_focus_weak, "CupertinoScrollbar": Icons.fullscreen, "CupertinoSlider": Icons.switch_camera, "CupertinoSegmentedControl": Icons.business_center, diff --git a/lib/routers/application.dart b/lib/routers/application.dart index 0724ad89..08144b61 100644 --- a/lib/routers/application.dart +++ b/lib/routers/application.dart @@ -3,10 +3,12 @@ import 'package:fluro/fluro.dart'; import 'package:flutter_go/utils/shared_preferences.dart'; import '../model/widget.dart'; + enum ENV { PRODUCTION, DEV, } + class Application { /// 通过Application设计环境变量 static ENV env = ENV.DEV; @@ -18,20 +20,20 @@ class Application { static bool pageIsOpen = false; static Map github = { - 'widgetsURL':'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/', + 'widgetsURL': + 'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/', //'develop':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/', //'master':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/master/lib/widgets/' }; /// 所有获取配置的唯一入口 Map get config { - if (Application.env == ENV.PRODUCTION) { - return {}; - } - if (Application.env == ENV.DEV) { - return {}; - } + if (Application.env == ENV.PRODUCTION) { return {}; + } + if (Application.env == ENV.DEV) { + return {}; + } + return {}; } - } diff --git a/lib/routers/router_handler.dart b/lib/routers/router_handler.dart index 2e718d40..41a06ae9 100644 --- a/lib/routers/router_handler.dart +++ b/lib/routers/router_handler.dart @@ -21,18 +21,16 @@ var homeHandler = new Handler( ); var collectionFullHandler = new Handler( - handlerFunc: (BuildContext context,Map> params){ - bool hasLogined = params['hasLogin']?.first == 'true'; - return CollectionFullPage(hasLogined: hasLogined); - } -); + handlerFunc: (BuildContext context, Map> params) { + bool hasLogined = params['hasLogin']?.first == 'true'; + return CollectionFullPage(hasLogined: hasLogined); +}); var collectionHandler = new Handler( - handlerFunc: (BuildContext context,Map> params){ - bool hasLogined = params['hasLogin']?.first == 'true'; - return CollectionPage(hasLogined: hasLogined); - } -); + handlerFunc: (BuildContext context, Map> params) { + bool hasLogined = params['hasLogin']?.first == 'true'; + return CollectionPage(hasLogined: hasLogined); +}); var categoryHandler = new Handler( handlerFunc: (BuildContext context, Map> params) { @@ -44,29 +42,28 @@ var categoryHandler = new Handler( var widgetNotFoundHandler = new Handler( handlerFunc: (BuildContext context, Map> params) { - return new WidgetNotFound(); - }); + return new WidgetNotFound(); +}); var loginPageHandler = new Handler( handlerFunc: (BuildContext context, Map> params) { - return LoginPage(); - }); + return LoginPage(); +}); var fullScreenCodeDialog = new Handler( handlerFunc: (BuildContext context, Map> params) { - String path = params['filePath']?.first; - return new FullScreenCodeDialog( - filePath: path, - ); - }); - + String path = params['filePath']?.first; + return new FullScreenCodeDialog( + filePath: path, + ); +}); var githubCodeDialog = new Handler( handlerFunc: (BuildContext context, Map> params) { - String path = params['remotePath']?.first; - return new FullScreenCodeDialog( - remoteFilePath: path, - ); - }); + String path = params['remotePath']?.first; + return new FullScreenCodeDialog( + remoteFilePath: path, + ); +}); var webViewPageHand = new Handler( handlerFunc: (BuildContext context, Map> params) { @@ -75,16 +72,13 @@ var webViewPageHand = new Handler( return new WebViewPage(url, title); }); - var standardPageHandler = new Handler( - handlerFunc: (BuildContext context, Map> params) { - String id = params['id']?.first; - return StandardView(id: id); - } -); - + handlerFunc: (BuildContext context, Map> params) { + String id = params['id']?.first; + return StandardView(id: id); +}); var issuesMessageHandler = new Handler( handlerFunc: (BuildContext context, Map> params) { - return IssuesMessagePage(); - }); + return IssuesMessagePage(); +}); diff --git a/lib/routers/routers.dart b/lib/routers/routers.dart index 32d6b9c2..72169e46 100644 --- a/lib/routers/routers.dart +++ b/lib/routers/routers.dart @@ -1,9 +1,9 @@ - import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:flutter_go/utils/analytics.dart' show analytics; import '../widgets/index.dart'; import './router_handler.dart'; + /// import '../standard_pages/index.dart'; class Routes { static String root = "/"; @@ -13,7 +13,7 @@ class Routes { static String githubCodeView = '/github-code-view'; static String webViewPage = '/web-view-page'; static String loginPage = '/loginpage'; - static String issuesMessage='/issuesMessage'; + static String issuesMessage = '/issuesMessage'; static String collectionPage = '/collection-page'; static String collectionFullPage = '/collection-full-page'; static String standardPage = '/standard-page/:id'; @@ -25,24 +25,24 @@ class Routes { // } // ); router.define(home, handler: homeHandler); - router.define(collectionPage,handler:collectionHandler); - router.define(collectionFullPage,handler:collectionFullHandler); + router.define(collectionPage, handler: collectionHandler); + router.define(collectionFullPage, handler: collectionFullHandler); router.define('/category/:ids', handler: categoryHandler); router.define('/category/error/404', handler: widgetNotFoundHandler); router.define(loginPage, handler: loginPageHandler); - router.define(codeView,handler:fullScreenCodeDialog); - router.define(githubCodeView,handler:githubCodeDialog); - router.define(webViewPage,handler:webViewPageHand); + router.define(codeView, handler: fullScreenCodeDialog); + router.define(githubCodeView, handler: githubCodeDialog); + router.define(webViewPage, handler: webViewPageHand); router.define(issuesMessage, handler: issuesMessageHandler); - router.define(standardPage,handler:standardPageHandler); + router.define(standardPage, handler: standardPageHandler); widgetDemosList.forEach((demo) { - Handler handler = new Handler( - handlerFunc: (BuildContext context, Map> params) { - print('组件路由params=$params widgetsItem=${demo.routerName}'); - analytics.logEvent( - name: 'component', parameters: {'name': demo.routerName }); - return demo.buildRouter(context); - }); + Handler handler = new Handler(handlerFunc: + (BuildContext context, Map> params) { + print('组件路由params=$params widgetsItem=${demo.routerName}'); + analytics + .logEvent(name: 'component', parameters: {'name': demo.routerName}); + return demo.buildRouter(context); + }); String path = demo.routerName; router.define('${path.toLowerCase()}', handler: handler); }); diff --git a/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart index f675dbc6..19aadf0b 100644 --- a/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart @@ -83,5 +83,4 @@ PullToRefresh 是一个刷新列表组件,借助于pull_to_refresh库实现, """; - } diff --git a/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart index 63850c68..955ef81f 100644 --- a/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart @@ -30,7 +30,4 @@ slider 用来选择连续性的或者非连续性的数据. 默认是在一段 ### 实例展示 [demo:e5f958bc_52ae_4241_9c8a_5c9e1f92b096]"""; - - } - \ No newline at end of file diff --git a/lib/standard_pages/index.dart b/lib/standard_pages/index.dart index 199d81f0..12cba175 100644 --- a/lib/standard_pages/index.dart +++ b/lib/standard_pages/index.dart @@ -1,45 +1,77 @@ +import 'PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096; +import 'local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096; +import 'test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096; +import 'standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096; +import 'standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096; +import 'RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart' + as StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096; -import 'PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096; -import 'local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096; -import 'test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096; -import 'standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096; -import 'standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096; -import 'RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096; class StandardPages { Map standardPages; Map getPages() { return { - "0": "0" , - "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096" : StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096.getMd() -, - "5d7178d0_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096.getMd() -, - "84f38e00_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096.getMd() -, - "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096" : StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096.getMd() -, - "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096.getMd() -, - "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096" : StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096.getMd() + "0": "0", + "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096": + StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096 + .getMd(), + "5d7178d0_42ae_4241_9c8a_5c9e1f92b096": + StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096.getMd(), + "84f38e00_42ae_4241_9c8a_5c9e1f92b096": + StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096.getMd(), + "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096": + StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096.getMd(), + "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096": + StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096 + .getMd(), + "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096": + StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096.getMd() }; } + List> getLocalList() { return [ {}, - { "id": "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096", "name": "PullToRefresh", "email": "763551832@qq.com", "author": "chenfeihu"} -, - { "id": "5d7178d0_42ae_4241_9c8a_5c9e1f92b096", "name": "local", "email": "hanxu@qq.com", "author": "hnaxu"} -, - { "id": "84f38e00_42ae_4241_9c8a_5c9e1f92b096", "name": "test", "email": "adsf.com", "author": "abc"} -, - { "id": "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096", "name": "standard", "email": "hanxu317@qq.com", "author": "sanfan"} -, - { "id": "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096", "name": "standard_for_slider", "email": "hanxu@qq.com", "author": "sanfan"} -, - { "id": "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096", "name": "RangeSlider", "email": "hanxu317@qq.com", "author": "hanxu"} + { + "id": "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096", + "name": "PullToRefresh", + "email": "763551832@qq.com", + "author": "chenfeihu" + }, + { + "id": "5d7178d0_42ae_4241_9c8a_5c9e1f92b096", + "name": "local", + "email": "hanxu@qq.com", + "author": "hnaxu" + }, + { + "id": "84f38e00_42ae_4241_9c8a_5c9e1f92b096", + "name": "test", + "email": "adsf.com", + "author": "abc" + }, + { + "id": "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096", + "name": "standard", + "email": "hanxu317@qq.com", + "author": "sanfan" + }, + { + "id": "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096", + "name": "standard_for_slider", + "email": "hanxu@qq.com", + "author": "sanfan" + }, + { + "id": "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096", + "name": "RangeSlider", + "email": "hanxu317@qq.com", + "author": "hanxu" + } ]; } - } - - \ No newline at end of file diff --git a/lib/standard_pages/local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart index 6e506d10..8ff3798f 100644 --- a/lib/standard_pages/local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart @@ -48,5 +48,4 @@ goCLi createDemo ``` [demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096] ```"""; - } diff --git a/lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart index bd222ee8..46d46bd3 100644 --- a/lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart @@ -55,7 +55,4 @@ goCLi createDemo 调用效果: [demo:1a29aa8e_32ae_4241_9c8a_5c9e1f92b096]"""; - - } - \ No newline at end of file diff --git a/lib/standard_pages/standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart index be0e2607..58a2066f 100644 --- a/lib/standard_pages/standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart @@ -50,7 +50,4 @@ goCLi createDemo ``` [demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096] ```"""; - - } - \ No newline at end of file diff --git a/lib/standard_pages/test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart b/lib/standard_pages/test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart index 6e506d10..8ff3798f 100644 --- a/lib/standard_pages/test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart +++ b/lib/standard_pages/test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart @@ -48,5 +48,4 @@ goCLi createDemo ``` [demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096] ```"""; - } diff --git a/lib/utils/data_utils.dart b/lib/utils/data_utils.dart index 921f95ff..f609d73e 100644 --- a/lib/utils/data_utils.dart +++ b/lib/utils/data_utils.dart @@ -5,6 +5,7 @@ import 'package:flutter_go/model/collection.dart'; import 'package:flutter_go/model/version.dart'; import 'package:flutter_go/model/widget.dart'; import 'package:package_info/package_info.dart'; + /// import 'package:flutter_go/model/responseData.dart'; import './net_utils.dart'; @@ -190,7 +191,9 @@ class DataUtils { "name": json['name'], "cnName": json['name'], "routerName": routerName, - "catId": json['parentId'].runtimeType == String ? int.parse(json['parentId']) : json['parentId'] + "catId": json['parentId'].runtimeType == String + ? int.parse(json['parentId']) + : json['parentId'] }; list.add(WidgetPoint.fromJSON(tempMap)); } diff --git a/lib/utils/example_code_parser.dart b/lib/utils/example_code_parser.dart index 7b09b532..eab2a0c9 100644 --- a/lib/utils/example_code_parser.dart +++ b/lib/utils/example_code_parser.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2019-01-14 11:42:36 +/// @Author: 一凨 +/// @Date: 2019-01-14 11:42:36 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-14 16:53:11 @@ -11,7 +11,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/routers/application.dart'; - Map _exampleCode; String _code; @@ -23,12 +22,14 @@ void _launchURL(String url) async { } } -Future getExampleCode(context,String filePath, AssetBundle bundle) async { - if (_exampleCode == null) await _parseExampleCode(context,filePath, bundle); +Future getExampleCode( + context, String filePath, AssetBundle bundle) async { + if (_exampleCode == null) await _parseExampleCode(context, filePath, bundle); return _code; } -Future _parseExampleCode(context,String filePath, AssetBundle bundle) async { +Future _parseExampleCode( + context, String filePath, AssetBundle bundle) async { String code; try { code = await bundle.loadString('lib/widgets/$filePath'); diff --git a/lib/utils/high_light_code.dart b/lib/utils/high_light_code.dart index 1ac0fdcd..5e1a7f3b 100644 --- a/lib/utils/high_light_code.dart +++ b/lib/utils/high_light_code.dart @@ -9,16 +9,15 @@ import 'package:string_scanner/string_scanner.dart'; /// DartSyntaxHighlighter(style).format(source) class SyntaxHighlighterStyle { - SyntaxHighlighterStyle({ - this.baseStyle, - this.numberStyle, - this.commentStyle, - this.keywordStyle, - this.stringStyle, - this.punctuationStyle, - this.classStyle, - this.constantStyle - }); + SyntaxHighlighterStyle( + {this.baseStyle, + this.numberStyle, + this.commentStyle, + this.keywordStyle, + this.stringStyle, + this.punctuationStyle, + this.classStyle, + this.constantStyle}); static SyntaxHighlighterStyle lightThemeStyle() { return SyntaxHighlighterStyle( @@ -29,8 +28,7 @@ class SyntaxHighlighterStyle { stringStyle: const TextStyle(color: Color(0xFF43A047)), punctuationStyle: const TextStyle(color: Color(0xFF000000)), classStyle: const TextStyle(color: Color(0xFF512DA8)), - constantStyle: const TextStyle(color: Color(0xFF795548)) - ); + constantStyle: const TextStyle(color: Color(0xFF795548))); } static SyntaxHighlighterStyle darkThemeStyle() { @@ -42,8 +40,7 @@ class SyntaxHighlighterStyle { stringStyle: const TextStyle(color: Color(0xFF009688)), punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)), classStyle: const TextStyle(color: Color(0xFF009688)), - constantStyle: const TextStyle(color: Color(0xFF795548)) - ); + constantStyle: const TextStyle(color: Color(0xFF795548))); } final TextStyle baseStyle; @@ -56,7 +53,8 @@ class SyntaxHighlighterStyle { final TextStyle constantStyle; } -abstract class Highlighter { // ignore: one_member_abstracts +abstract class Highlighter { + // ignore: one_member_abstracts TextSpan format(String src); } @@ -69,17 +67,66 @@ class DartSyntaxHighlighter extends Highlighter { SyntaxHighlighterStyle _style; static const List _keywords = [ - 'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch', - 'class', 'const', 'continue', 'default', 'deferred', 'do', 'dynamic', 'else', - 'enum', 'export', 'external', 'extends', 'factory', 'false', 'final', - 'finally', 'for', 'get', 'if', 'implements', 'import', 'in', 'is', 'library', - 'new', 'null', 'operator', 'part', 'rethrow', 'return', 'set', 'static', - 'super', 'switch', 'sync', 'this', 'throw', 'true', 'try', 'typedef', 'var', - 'void', 'while', 'with', 'yield' + 'abstract', + 'as', + 'assert', + 'async', + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'default', + 'deferred', + 'do', + 'dynamic', + 'else', + 'enum', + 'export', + 'external', + 'extends', + 'factory', + 'false', + 'final', + 'finally', + 'for', + 'get', + 'if', + 'implements', + 'import', + 'in', + 'is', + 'library', + 'new', + 'null', + 'operator', + 'part', + 'rethrow', + 'return', + 'set', + 'static', + 'super', + 'switch', + 'sync', + 'this', + 'throw', + 'true', + 'try', + 'typedef', + 'var', + 'void', + 'while', + 'with', + 'yield' ]; static const List _builtInTypes = [ - 'int', 'double', 'num', 'bool' + 'int', + 'double', + 'num', + 'bool' ]; String _src; @@ -99,15 +146,18 @@ class DartSyntaxHighlighter extends Highlighter { for (_HighlightSpan span in _spans) { if (currentPosition != span.start) - formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start))); + formattedText + .add(TextSpan(text: _src.substring(currentPosition, span.start))); - formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src))); + formattedText.add(TextSpan( + style: span.textStyle(_style), text: span.textForSpan(_src))); currentPosition = span.end; } if (currentPosition != _src.length) - formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length))); + formattedText + .add(TextSpan(text: _src.substring(currentPosition, _src.length))); return TextSpan(style: _style.baseStyle, children: formattedText); } else { @@ -125,11 +175,8 @@ class DartSyntaxHighlighter extends Highlighter { // Block comments if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { - _spans.add(_HighlightSpan( - _HighlightType.comment, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.comment, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } @@ -146,115 +193,81 @@ class DartSyntaxHighlighter extends Highlighter { endComment = _src.length; } - _spans.add(_HighlightSpan( - _HighlightType.comment, - startComment, - endComment - )); + _spans.add( + _HighlightSpan(_HighlightType.comment, startComment, endComment)); - if (eof) - break; + if (eof) break; continue; } // Raw r"String" if (_scanner.scan(RegExp(r'r".*"'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Raw r'String' if (_scanner.scan(RegExp(r"r'.*'"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Multiline """String""" if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Multiline '''String''' if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // "String" if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // 'String' if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Double if (_scanner.scan(RegExp(r'\d+\.\d+'))) { - _spans.add(_HighlightSpan( - _HighlightType.number, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.number, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Integer if (_scanner.scan(RegExp(r'\d+'))) { - _spans.add(_HighlightSpan( - _HighlightType.number, - _scanner.lastMatch.start, - _scanner.lastMatch.end) - ); + _spans.add(_HighlightSpan(_HighlightType.number, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Punctuation if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { - _spans.add(_HighlightSpan( - _HighlightType.punctuation, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.punctuation, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Meta data if (_scanner.scan(RegExp(r'@\w+'))) { - _spans.add(_HighlightSpan( - _HighlightType.keyword, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.keyword, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } @@ -263,8 +276,7 @@ class DartSyntaxHighlighter extends Highlighter { _HighlightType type; String word = _scanner.lastMatch[0]; - if (word.startsWith('_')) - word = word.substring(1); + if (word.startsWith('_')) word = word.substring(1); if (_keywords.contains(word)) type = _HighlightType.keyword; @@ -272,15 +284,14 @@ class DartSyntaxHighlighter extends Highlighter { type = _HighlightType.keyword; else if (_firstLetterIsUpperCase(word)) type = _HighlightType.klass; - else if (word.length >= 2 && word.startsWith('k') && _firstLetterIsUpperCase(word.substring(1))) + else if (word.length >= 2 && + word.startsWith('k') && + _firstLetterIsUpperCase(word.substring(1))) type = _HighlightType.constant; if (type != null) { _spans.add(_HighlightSpan( - type, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + type, _scanner.lastMatch.start, _scanner.lastMatch.end)); } } @@ -298,12 +309,10 @@ class DartSyntaxHighlighter extends Highlighter { void _simplify() { for (int i = _spans.length - 2; i >= 0; i -= 1) { - if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) { - _spans[i] = _HighlightSpan( - _spans[i].type, - _spans[i].start, - _spans[i + 1].end - ); + if (_spans[i].type == _spans[i + 1].type && + _spans[i].end == _spans[i + 1].start) { + _spans[i] = + _HighlightSpan(_spans[i].type, _spans[i].start, _spans[i + 1].end); _spans.removeAt(i + 1); } } diff --git a/lib/utils/provider.dart b/lib/utils/provider.dart index 89003886..ac1b43a9 100644 --- a/lib/utils/provider.dart +++ b/lib/utils/provider.dart @@ -32,9 +32,10 @@ class Provider { if (db == null) { return Future.value([]); } - List tables = await db.rawQuery('SELECT name FROM sqlite_master WHERE type = "table"'); + List tables = await db + .rawQuery('SELECT name FROM sqlite_master WHERE type = "table"'); List targetList = []; - tables.forEach((item) { + tables.forEach((item) { targetList.add(item['name']); }); return targetList; @@ -46,13 +47,12 @@ class Provider { List tables = await getTables(); - for(int i = 0; i < expectTables.length; i++) { + for (int i = 0; i < expectTables.length; i++) { if (!tables.contains(expectTables[i])) { return false; } } - return true; - + return true; } //初始化数据库 @@ -89,5 +89,4 @@ class Provider { print("Opening existing database"); } } - } diff --git a/lib/utils/shared_preferences.dart b/lib/utils/shared_preferences.dart index c7351a66..9a71a954 100644 --- a/lib/utils/shared_preferences.dart +++ b/lib/utils/shared_preferences.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:shared_preferences/shared_preferences.dart'; @@ -14,14 +13,13 @@ class SpUtil { static SharedPreferences _spf; - SpUtil._(); Future _init() async { _spf = await SharedPreferences.getInstance(); } - static Future getInstance() async { + static Future getInstance() async { if (_instance == null) { _instance = new SpUtil._(); } @@ -37,6 +35,7 @@ class SpUtil { } return false; } + // 判断是否存在数据 bool hasKey(String key) { Set keys = getKeys(); @@ -107,8 +106,6 @@ class SpUtil { return _spf.get(key); } - - Future remove(String key) { if (_beforeCheck()) return null; return _spf.remove(key); diff --git a/lib/utils/sql.dart b/lib/utils/sql.dart index d932415b..3ab98660 100644 --- a/lib/utils/sql.dart +++ b/lib/utils/sql.dart @@ -1,14 +1,12 @@ - - import 'package:sqflite/sqflite.dart'; import './provider.dart'; -class BaseModel{ +class BaseModel { Database db; final String table = ''; var query; - BaseModel(this.db){ + BaseModel(this.db) { query = db.query; } } @@ -20,18 +18,21 @@ class Sql extends BaseModel { super(Provider.db); // sdf - Future get() async{ + Future get() async { return await this.query(tableName); } - String getTableName () { + + String getTableName() { return tableName; } - Future delete(String value,String key) async{ - return await this.db.delete(tableName,where:'$key = ?',whereArgs:[value]); + Future delete(String value, String key) async { + return await this + .db + .delete(tableName, where: '$key = ?', whereArgs: [value]); } - Future deleteAll() async{ + Future deleteAll() async { return await this.db.delete(tableName); } @@ -44,7 +45,7 @@ class Sql extends BaseModel { int index = 0; conditions.forEach((key, value) { if (value == null) { - return ; + return; } if (value.runtimeType == String) { stringConditions = '$stringConditions $key = "$value"'; @@ -53,7 +54,7 @@ class Sql extends BaseModel { stringConditions = '$stringConditions $key = $value'; } - if (index >= 0 && index < conditions.length -1) { + if (index >= 0 && index < conditions.length - 1) { stringConditions = '$stringConditions and'; } index++; @@ -61,18 +62,21 @@ class Sql extends BaseModel { // print("this is string condition for sql > $stringConditions"); return await this.query(tableName, where: stringConditions); } + Future> insert(Map json) async { var id = await this.db.insert(tableName, json); json['id'] = id; return json; } + /// /// 搜索 /// @param Object condition /// @mods [And, Or] default is Or /// search({'name': "hanxu', 'id': 1}; /// - Future search({Map conditions, String mods = 'Or'}) async { + Future search( + {Map conditions, String mods = 'Or'}) async { if (conditions == null || conditions.isEmpty) { return this.get(); } @@ -80,7 +84,7 @@ class Sql extends BaseModel { int index = 0; conditions.forEach((key, value) { if (value == null) { - return ; + return; } if (value.runtimeType == String) { @@ -90,7 +94,7 @@ class Sql extends BaseModel { stringConditions = '$stringConditions $key = "%$value%"'; } - if (index >= 0 && index < conditions.length -1) { + if (index >= 0 && index < conditions.length - 1) { stringConditions = '$stringConditions $mods'; } index++; @@ -98,4 +102,4 @@ class Sql extends BaseModel { return await this.query(tableName, where: stringConditions); } -} \ No newline at end of file +} diff --git a/lib/utils/style.dart b/lib/utils/style.dart index 31d9bb8d..a991c3c5 100644 --- a/lib/utils/style.dart +++ b/lib/utils/style.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; //颜色配置 -class AppColor{ +class AppColor { static const int white = 0xFFFFFFFF; static const int mainTextColor = 0xFF121917; static const int subTextColor = 0xff959595; } //文本设置 -class AppText{ +class AppText { static const middleSize = 16.0; static const middleText = TextStyle( @@ -21,9 +21,9 @@ class AppText{ fontSize: middleSize, ); } + class WidgetDemoColor { static const int fontColor = 0xFF607173; static const int iconColor = 0xFF607173; static const int borderColor = 0xFFEFEFEF; - } diff --git a/lib/utils/syntax_highlighter.dart b/lib/utils/syntax_highlighter.dart index 1b36f07c..3b0971f1 100644 --- a/lib/utils/syntax_highlighter.dart +++ b/lib/utils/syntax_highlighter.dart @@ -1,47 +1,44 @@ -/// @Author: 一凨 -/// @Date: 2019-01-14 11:42:39 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2019-01-14 11:42:39 +/// @Author: 一凨 +/// @Date: 2019-01-14 11:42:39 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-14 11:42:39 import 'package:flutter/material.dart'; import 'package:string_scanner/string_scanner.dart'; class SyntaxHighlighterStyle { - SyntaxHighlighterStyle({ - this.baseStyle, - this.numberStyle, - this.commentStyle, - this.keywordStyle, - this.stringStyle, - this.punctuationStyle, - this.classStyle, - this.constantStyle - }); + SyntaxHighlighterStyle( + {this.baseStyle, + this.numberStyle, + this.commentStyle, + this.keywordStyle, + this.stringStyle, + this.punctuationStyle, + this.classStyle, + this.constantStyle}); static SyntaxHighlighterStyle lightThemeStyle() { return SyntaxHighlighterStyle( - baseStyle: const TextStyle(color: Color(0xFF000000)), - numberStyle: const TextStyle(color: Color(0xFF1565C0)), - commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), - keywordStyle: const TextStyle(color: Color(0xFF9C27B0)), - stringStyle: const TextStyle(color: Color(0xFF43A047)), - punctuationStyle: const TextStyle(color: Color(0xFF000000)), - classStyle: const TextStyle(color: Color(0xFF512DA8)), - constantStyle: const TextStyle(color: Color(0xFF795548)) - ); + baseStyle: const TextStyle(color: Color(0xFF000000)), + numberStyle: const TextStyle(color: Color(0xFF1565C0)), + commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), + keywordStyle: const TextStyle(color: Color(0xFF9C27B0)), + stringStyle: const TextStyle(color: Color(0xFF43A047)), + punctuationStyle: const TextStyle(color: Color(0xFF000000)), + classStyle: const TextStyle(color: Color(0xFF512DA8)), + constantStyle: const TextStyle(color: Color(0xFF795548))); } static SyntaxHighlighterStyle darkThemeStyle() { return SyntaxHighlighterStyle( - baseStyle: const TextStyle(color: Color(0xFFFFFFFF)), - numberStyle: const TextStyle(color: Color(0xFF1565C0)), - commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), - keywordStyle: const TextStyle(color: Color(0xFF80CBC4)), - stringStyle: const TextStyle(color: Color(0xFF009688)), - punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)), - classStyle: const TextStyle(color: Color(0xFF009688)), - constantStyle: const TextStyle(color: Color(0xFF795548)) - ); + baseStyle: const TextStyle(color: Color(0xFFFFFFFF)), + numberStyle: const TextStyle(color: Color(0xFF1565C0)), + commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), + keywordStyle: const TextStyle(color: Color(0xFF80CBC4)), + stringStyle: const TextStyle(color: Color(0xFF009688)), + punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)), + classStyle: const TextStyle(color: Color(0xFF009688)), + constantStyle: const TextStyle(color: Color(0xFF795548))); } final TextStyle baseStyle; @@ -54,7 +51,8 @@ class SyntaxHighlighterStyle { final TextStyle constantStyle; } -abstract class SyntaxHighlighter { // ignore: one_member_abstracts +abstract class SyntaxHighlighter { + // ignore: one_member_abstracts TextSpan format(String src); } @@ -67,17 +65,66 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { SyntaxHighlighterStyle _style; static const List _keywords = [ - 'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch', - 'class', 'const', 'continue', 'default', 'deferred', 'do', 'dynamic', 'else', - 'enum', 'export', 'external', 'extends', 'factory', 'false', 'final', - 'finally', 'for', 'get', 'if', 'implements', 'import', 'in', 'is', 'library', - 'new', 'null', 'operator', 'part', 'rethrow', 'return', 'set', 'static', - 'super', 'switch', 'sync', 'this', 'throw', 'true', 'try', 'typedef', 'var', - 'void', 'while', 'with', 'yield' + 'abstract', + 'as', + 'assert', + 'async', + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'default', + 'deferred', + 'do', + 'dynamic', + 'else', + 'enum', + 'export', + 'external', + 'extends', + 'factory', + 'false', + 'final', + 'finally', + 'for', + 'get', + 'if', + 'implements', + 'import', + 'in', + 'is', + 'library', + 'new', + 'null', + 'operator', + 'part', + 'rethrow', + 'return', + 'set', + 'static', + 'super', + 'switch', + 'sync', + 'this', + 'throw', + 'true', + 'try', + 'typedef', + 'var', + 'void', + 'while', + 'with', + 'yield' ]; static const List _builtInTypes = [ - 'int', 'double', 'num', 'bool' + 'int', + 'double', + 'num', + 'bool' ]; String _src; @@ -97,15 +144,18 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { for (_HighlightSpan span in _spans) { if (currentPosition != span.start) - formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start))); + formattedText + .add(TextSpan(text: _src.substring(currentPosition, span.start))); - formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src))); + formattedText.add(TextSpan( + style: span.textStyle(_style), text: span.textForSpan(_src))); currentPosition = span.end; } if (currentPosition != _src.length) - formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length))); + formattedText + .add(TextSpan(text: _src.substring(currentPosition, _src.length))); return TextSpan(style: _style.baseStyle, children: formattedText); } else { @@ -123,11 +173,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { // Block comments if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { - _spans.add(_HighlightSpan( - _HighlightType.comment, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.comment, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } @@ -144,115 +191,81 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { endComment = _src.length; } - _spans.add(_HighlightSpan( - _HighlightType.comment, - startComment, - endComment - )); + _spans.add( + _HighlightSpan(_HighlightType.comment, startComment, endComment)); - if (eof) - break; + if (eof) break; continue; } // Raw r"String" if (_scanner.scan(RegExp(r'r".*"'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Raw r'String' if (_scanner.scan(RegExp(r"r'.*'"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Multiline """String""" if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Multiline '''String''' if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // "String" if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // 'String' if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { - _spans.add(_HighlightSpan( - _HighlightType.string, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.string, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Double if (_scanner.scan(RegExp(r'\d+\.\d+'))) { - _spans.add(_HighlightSpan( - _HighlightType.number, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.number, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Integer if (_scanner.scan(RegExp(r'\d+'))) { - _spans.add(_HighlightSpan( - _HighlightType.number, - _scanner.lastMatch.start, - _scanner.lastMatch.end) - ); + _spans.add(_HighlightSpan(_HighlightType.number, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Punctuation if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { - _spans.add(_HighlightSpan( - _HighlightType.punctuation, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.punctuation, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Meta data if (_scanner.scan(RegExp(r'@\w+'))) { - _spans.add(_HighlightSpan( - _HighlightType.keyword, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + _spans.add(_HighlightSpan(_HighlightType.keyword, + _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } @@ -261,8 +274,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { _HighlightType type; String word = _scanner.lastMatch[0]; - if (word.startsWith('_')) - word = word.substring(1); + if (word.startsWith('_')) word = word.substring(1); if (_keywords.contains(word)) type = _HighlightType.keyword; @@ -270,15 +282,14 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { type = _HighlightType.keyword; else if (_firstLetterIsUpperCase(word)) type = _HighlightType.klass; - else if (word.length >= 2 && word.startsWith('k') && _firstLetterIsUpperCase(word.substring(1))) + else if (word.length >= 2 && + word.startsWith('k') && + _firstLetterIsUpperCase(word.substring(1))) type = _HighlightType.constant; if (type != null) { _spans.add(_HighlightSpan( - type, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); + type, _scanner.lastMatch.start, _scanner.lastMatch.end)); } } @@ -296,12 +307,10 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { void _simplify() { for (int i = _spans.length - 2; i >= 0; i -= 1) { - if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) { - _spans[i] = _HighlightSpan( - _spans[i].type, - _spans[i].start, - _spans[i + 1].end - ); + if (_spans[i].type == _spans[i + 1].type && + _spans[i].end == _spans[i + 1].start) { + _spans[i] = + _HighlightSpan(_spans[i].type, _spans[i].start, _spans[i + 1].end); _spans.removeAt(i + 1); } } diff --git a/lib/views/collection_page/collection_full_page.dart b/lib/views/collection_page/collection_full_page.dart index ada616eb..b0f8c5de 100644 --- a/lib/views/collection_page/collection_full_page.dart +++ b/lib/views/collection_page/collection_full_page.dart @@ -58,7 +58,6 @@ class _CollectionFullPageState extends State { } Widget _renderList(context, index) { - if (index == 0) { return Container( height: 40.0, @@ -115,8 +114,7 @@ class _CollectionFullPageState extends State { trailing: Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0), onTap: () { - Application.router.navigateTo( - context, targetRouter.toLowerCase(), + Application.router.navigateTo(context, targetRouter.toLowerCase(), transition: TransitionType.inFromRight); }, ), diff --git a/lib/views/collection_page/collection_page.dart b/lib/views/collection_page/collection_page.dart index 75d6e309..ca00291b 100644 --- a/lib/views/collection_page/collection_page.dart +++ b/lib/views/collection_page/collection_page.dart @@ -11,6 +11,7 @@ import 'package:flutter_go/routers/application.dart'; import 'package:flutter_go/routers/routers.dart'; import 'package:flutter_go/event/event_bus.dart'; import 'package:flutter_go/event/event_model.dart'; + /// import 'package:flutter_go/utils/data_utils.dart'; class CollectionPage extends StatefulWidget { @@ -26,6 +27,7 @@ class _CollectionPageState extends State { final eventBus = new EventBus(); ApplicationEvent.event = eventBus; } + /// CollectionControlModel _collectionControl = new CollectionControlModel(); List _collectionList = []; ScrollController _scrollController = new ScrollController(); diff --git a/lib/views/first_page/drawer_page.dart b/lib/views/first_page/drawer_page.dart index f0fc1be0..1b1c4f82 100644 --- a/lib/views/first_page/drawer_page.dart +++ b/lib/views/first_page/drawer_page.dart @@ -209,7 +209,6 @@ class _DrawerPageState extends State { } else { //No description provided. Application.router.navigateTo(context, '${Routes.loginPage}'); - } }, ), diff --git a/lib/views/first_page/first_page.dart b/lib/views/first_page/first_page.dart index 38840ba1..e1d01544 100644 --- a/lib/views/first_page/first_page.dart +++ b/lib/views/first_page/first_page.dart @@ -17,7 +17,8 @@ class FirstPage extends StatefulWidget { FirstPageState createState() => new FirstPageState(); } -class FirstPageState extends State with AutomaticKeepAliveClientMixin{ +class FirstPageState extends State + with AutomaticKeepAliveClientMixin { Future _prefs = SharedPreferences.getInstance(); Future _unKnow; GlobalKey key; @@ -25,7 +26,6 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin @override bool get wantKeepAlive => true; - @override void initState() { super.initState(); @@ -39,8 +39,10 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin /// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹 _unKnow.then((bool value) { - new Future.delayed(const Duration(seconds: 1),(){ - if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) { + new Future.delayed(const Duration(seconds: 1), () { + if (!value && + key.currentState is DisclaimerMsgState && + key.currentState.showAlertDialog is Function) { key.currentState.showAlertDialog(context); } }); @@ -48,26 +50,24 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin } } - Future getIndexListData([Map params]) async { /// const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; - const juejin_flutter = 'https://fluttergo.pub:9527/juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; + const juejin_flutter = + 'https://fluttergo.pub:9527/juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; var pageIndex = (params is Map) ? params['pageIndex'] : 0; - final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'}; + final _param = {'page': pageIndex, 'pageSize': 20, 'sort': 'rankIndex'}; var responseList = []; - var pageTotal = 0; + var pageTotal = 0; - try{ + try { var response = await NetUtils.get(juejin_flutter, _param); responseList = response['d']['entrylist']; pageTotal = response['d']['total']; if (!(pageTotal is int) || pageTotal <= 0) { pageTotal = 0; } - }catch(e){ - - } + } catch (e) {} pageIndex += 1; List resultList = new List(); for (int i = 0; i < responseList.length; i++) { @@ -78,44 +78,50 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin // No specified type, handles all } } - Map result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex}; + Map result = { + "list": resultList, + 'total': pageTotal, + 'pageIndex': pageIndex + }; return result; } /// 每个item的样式 - Widget makeCard(index,item){ + Widget makeCard(index, item) { var myTitle = '${item.title}'; var myUsername = '${'👲'}: ${item.username} '; var codeUrl = '${item.detailUrl}'; - return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,); + return new ListViewItem( + itemUrl: codeUrl, + itemTitle: myTitle, + data: myUsername, + ); } - headerView(){ - return - Column( - children: [ - Stack( + headerView() { + return Column( + children: [ + Stack( //alignment: const FractionalOffset(0.9, 0.1),//方法一 - children: [ - Pagination(), - Positioned(//方法二 - top: 10.0, - left: 0.0, - child: DisclaimerMsg(key:key,pWidget:this) - ), - ]), - SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)), - SizedBox(height: 10), - ], - ); - + children: [ + Pagination(), + Positioned( + //方法二 + top: 10.0, + left: 0.0, + child: DisclaimerMsg(key: key, pWidget: this)), + ]), + SizedBox( + height: 1, child: Container(color: Theme.of(context).primaryColor)), + SizedBox(height: 10), + ], + ); } @override Widget build(BuildContext context) { super.build(context); - return new Column( - children: [ + return new Column(children: [ // new Stack( // //alignment: const FractionalOffset(0.9, 0.1),//方法一 // children: [ @@ -127,14 +133,9 @@ class FirstPageState extends State with AutomaticKeepAliveClientMixin // ), // ]), // SizedBox(height: 2, child:Container(color: Theme.of(context).primaryColor)), - new Expanded( - //child: new List(), - child: listComp.ListRefresh(getIndexListData,makeCard,headerView) - ) - ] - - ); + new Expanded( + //child: new List(), + child: listComp.ListRefresh(getIndexListData, makeCard, headerView)) + ]); } } - - diff --git a/lib/views/first_page/first_page_item.dart b/lib/views/first_page/first_page_item.dart index bef10315..bdd5da10 100644 --- a/lib/views/first_page/first_page_item.dart +++ b/lib/views/first_page/first_page_item.dart @@ -20,18 +20,18 @@ class FirstPageItem { FirstPageItem( {this.hot, - this.tag, - this.username, - this.collectionCount, - this.createdTime, - this.commentCount, - this.title, - this.detailUrl, - this.isCollection}); + this.tag, + this.username, + this.collectionCount, + this.createdTime, + this.commentCount, + this.title, + this.detailUrl, + this.isCollection}); factory FirstPageItem.fromJson(Map json) { String _tag = ''; - if(json['tags'].length>0){ + if (json['tags'].length > 0) { _tag = '${json['tags'][0]['title']}/'; } return FirstPageItem( @@ -43,7 +43,7 @@ class FirstPageItem { createdTime: Util.getTimeDuration(json['createdAt']), title: json['title'], detailUrl: json['originalUrl'], - isCollection: json['type'] , + isCollection: json['type'], ); } -} \ No newline at end of file +} diff --git a/lib/views/first_page/main_page.dart b/lib/views/first_page/main_page.dart index c48fbe0d..b97dc255 100644 --- a/lib/views/first_page/main_page.dart +++ b/lib/views/first_page/main_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_go/views/first_page/drawer_page.dart'; import './first_page.dart'; + /// import './sub_page.dart'; import './main_app_bar.dart'; import './search_page.dart'; @@ -16,13 +17,14 @@ class _Page { final String labelId; final int labelIndex; - _Page(this.labelId,this.labelIndex); + _Page(this.labelId, this.labelIndex); } final List<_Page> _allPages = <_Page>[ _Page('热门资讯', 1), _Page('FG-官网', 2), _Page('FG-web版', 3), + ///_Page('项目4'), ]; @@ -36,11 +38,13 @@ class MainPage extends StatelessWidget { _tabController = DefaultTabController( length: _allPages.length, child: Scaffold( - appBar: MyAppBar( + appBar: MyAppBar( leading: Container( - child: ClipOval( + child: ClipOval( child: Image.network( - userInfo.id == 0?'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658':userInfo.avatarPic, + userInfo.id == 0 + ? 'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658' + : userInfo.avatarPic, scale: 15.0, ), )), @@ -48,16 +52,14 @@ class MainPage extends StatelessWidget { title: TabLayout(), actions: [ IconButton( - icon: Icon(Icons.search), + icon: Icon(Icons.search), onPressed: () { pushPage(context, SearchPage(), pageName: "SearchPage"); }) ], ), drawer: Drawer( - child: DrawerPage( - userInfo: userInfo - ), + child: DrawerPage(userInfo: userInfo), ), body: TabBarViewLayout(), )); @@ -74,26 +76,26 @@ class TabLayout extends StatelessWidget { @override Widget build(BuildContext context) { _tabBar = TabBar( - isScrollable: true, - //labelPadding: EdgeInsets.all(12.0), - labelPadding: EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0), - indicatorSize: TabBarIndicatorSize.label, - tabs: _allPages.map((_Page page) => Tab(text: page.labelId)).toList(), - onTap: (index) { - if (index == 1) { - DefaultTabController.of(context).animateTo(0); - Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go 官方网站')}&url=${Uri.encodeComponent('https://flutter-go.pub')}'); - } else if (index == 2) { - + isScrollable: true, + //labelPadding: EdgeInsets.all(12.0), + labelPadding: EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0), + indicatorSize: TabBarIndicatorSize.label, + tabs: _allPages.map((_Page page) => Tab(text: page.labelId)).toList(), + onTap: (index) { + if (index == 1) { + DefaultTabController.of(context).animateTo(0); + Application.router.navigateTo(context, + '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go 官方网站')}&url=${Uri.encodeComponent('https://flutter-go.pub')}'); + } else if (index == 2) { // new Future.delayed(const Duration(seconds: 1),(){ // showAlertDialog(Application.globalContext); // }); - DefaultTabController.of(context).animateTo(0); - Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go web版(H5)')}&url=${Uri.encodeComponent('https://flutter-go.pub/flutter_go_web')}'); - } - } - ); + DefaultTabController.of(context).animateTo(0); + Application.router.navigateTo(context, + '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go web版(H5)')}&url=${Uri.encodeComponent('https://flutter-go.pub/flutter_go_web')}'); + } + }); return _tabBar; } } @@ -116,7 +118,7 @@ class TabBarViewLayout extends StatelessWidget { print("TabBarViewLayout build......."); return TabBarView( children: _allPages.map((_Page page) { - return buildTabView(context, page); - }).toList()); + return buildTabView(context, page); + }).toList()); } } diff --git a/lib/views/first_page/search_page.dart b/lib/views/first_page/search_page.dart index 042bae8a..4a70e461 100644 --- a/lib/views/first_page/search_page.dart +++ b/lib/views/first_page/search_page.dart @@ -8,7 +8,7 @@ import 'package:flutter_go/blocs/industry_event.dart'; import 'package:flutter_go/routers/application.dart'; import 'package:flutter_go/routers/routers.dart'; -final _industryPage = Industry.IndustryPage(itemTitle: (state){ +final _industryPage = Industry.IndustryPage(itemTitle: (state) { return ListView.builder( itemBuilder: (BuildContext context, int index) { return ListTile( @@ -27,7 +27,8 @@ final _industryPage = Industry.IndustryPage(itemTitle: (state){ print(state.res[index].source); final itemTitle = state.res[index].title; final itemUrl = state.res[index].source; - Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}'); + Application.router.navigateTo(context, + '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}'); }, ); }, @@ -44,9 +45,8 @@ class SearchPage extends StatelessWidget { /// print('suggestion::${Industry.suggestion}'); return Scaffold( appBar: PreferredSize( - preferredSize: Size(double.infinity, 52), // is the height - child: AppBar(title: searchBarPage) - ), + preferredSize: Size(double.infinity, 52), // is the height + child: AppBar(title: searchBarPage)), //body: ProgressView(), body: _industryPage, floatingActionButton: FloatingActionButton( @@ -54,7 +54,9 @@ class SearchPage extends StatelessWidget { onPressed: () { //print('searchBarPage=====>${controller.text}'); //print('searchBarPage=====>${that.getResultsDebounced}'); - if(that is _SearchBarPageState && that.getResultsDebounced is Function && controller.text is String ) { + if (that is _SearchBarPageState && + that.getResultsDebounced is Function && + controller.text is String) { that.getResultsDebounced(controller.text); } }, @@ -67,11 +69,11 @@ class SearchPage extends StatelessWidget { class ProgressView extends StatelessWidget { @override Widget build(BuildContext context) { - return Center( - child: SizedBox( + return Center( + child: SizedBox( width: 24.0, height: 24.0, - child: CircularProgressIndicator( + child: CircularProgressIndicator( strokeWidth: 2.0, ), ), @@ -79,15 +81,15 @@ class ProgressView extends StatelessWidget { } } -class SearchBarPage extends StatefulWidget{ +class SearchBarPage extends StatefulWidget { @override - State createState() => _SearchBarPageState(); + State createState() => _SearchBarPageState(); } - final TextEditingController controller = TextEditingController(); var that; var loading; + class _SearchBarPageState extends State { @override void initState() { @@ -99,9 +101,10 @@ class _SearchBarPageState extends State { Timer _resultsTimer; String oldKey; + /// 防抖函数 Future getResultsDebounced(String text) async { - if(oldKey == text){ + if (oldKey == text) { print('请求内容重复'); return; } @@ -114,15 +117,14 @@ class _SearchBarPageState extends State { } _resultsTimer = new Timer(new Duration(milliseconds: 400), () async { loading = true; - if(mounted){ + if (mounted) { suggestion.dispatch(SuggestionFetch(query: text)); } oldKey = text; }); } - - void onSearchTextChanged(String text){ + void onSearchTextChanged(String text) { print('onSearchTextChanged:$text'); //suggestion.dispatch(SuggestionFetch(query: text)); getResultsDebounced(text); @@ -136,56 +138,58 @@ class _SearchBarPageState extends State { super.dispose(); } - Widget build(BuildContext context) { return Container( - color: Theme.of(context).primaryColor, - //color: Colors.amber, - child: Padding( - //padding: EdgeInsets.only(top: MediaQueryData.fromWindow(window).padding.top,), - padding: EdgeInsets.all(0.0), - child: Container( - //height: 162.0, - child: Padding( - padding: const EdgeInsets.all(6.0), - child: Card( - child: Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox(width: 5.0,), - Icon(Icons.search, color: Colors.grey,size: 18.0,), - Expanded( - child: Container( - alignment: Alignment.center, - child: TextField( - controller: controller, - decoration: InputDecoration( - contentPadding: EdgeInsets.only(top: 0.0), - hintText: '全网搜索 Flutter 相关知识库', - hintStyle:TextStyle(fontSize: 12.0), - border: InputBorder.none - ), - onChanged: onSearchTextChanged, - ), - ), - ), - IconButton( - icon: Icon(Icons.cancel), - color: Colors.grey, - iconSize: 18.0, - onPressed: () { - controller.clear(); - // onSearchTextChanged(''); - }, - ), - ], + color: Theme.of(context).primaryColor, + //color: Colors.amber, + child: Padding( + //padding: EdgeInsets.only(top: MediaQueryData.fromWindow(window).padding.top,), + padding: EdgeInsets.all(0.0), + child: Container( + //height: 162.0, + child: Padding( + padding: const EdgeInsets.all(6.0), + child: Card( + child: Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + width: 5.0, + ), + Icon( + Icons.search, + color: Colors.grey, + size: 18.0, + ), + Expanded( + child: Container( + alignment: Alignment.center, + child: TextField( + controller: controller, + decoration: InputDecoration( + contentPadding: EdgeInsets.only(top: 0.0), + hintText: '全网搜索 Flutter 相关知识库', + hintStyle: TextStyle(fontSize: 12.0), + border: InputBorder.none), + onChanged: onSearchTextChanged, + ), ), - ) - ) - ), - ), + ), + IconButton( + icon: Icon(Icons.cancel), + color: Colors.grey, + iconSize: 18.0, + onPressed: () { + controller.clear(); + // onSearchTextChanged(''); + }, + ), + ], + ), + ))), ), - ); + ), + ); } -} \ No newline at end of file +} diff --git a/lib/views/first_page/sub_page.dart b/lib/views/first_page/sub_page.dart index 22325f97..45b7de72 100644 --- a/lib/views/first_page/sub_page.dart +++ b/lib/views/first_page/sub_page.dart @@ -17,7 +17,7 @@ class SubPage extends StatefulWidget { SubPageState createState() => SubPageState(); } -class SubPageState extends State with AutomaticKeepAliveClientMixin{ +class SubPageState extends State with AutomaticKeepAliveClientMixin { Future _prefs = SharedPreferences.getInstance(); Future _unKnow; GlobalKey key; @@ -25,47 +25,46 @@ class SubPageState extends State with AutomaticKeepAliveClientMixin{ @override bool get wantKeepAlive => true; - - @override + @override void initState() { super.initState(); if (key == null) { - key = GlobalKey(); - // key = const Key('__RIKEY1__'); + key = GlobalKey(); + // key = const Key('__RIKEY1__'); //获取sharePre - _unKnow = _prefs.then((SharedPreferences prefs) { - return (prefs.getBool('disclaimer::Boolean') ?? false); - }); + _unKnow = _prefs.then((SharedPreferences prefs) { + return (prefs.getBool('disclaimer::Boolean') ?? false); + }); /// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹 _unKnow.then((bool value) { - new Future.delayed(const Duration(seconds: 1),(){ - if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) { - key.currentState.showAlertDialog(context); - } - }); + new Future.delayed(const Duration(seconds: 1), () { + if (!value && + key.currentState is DisclaimerMsgState && + key.currentState.showAlertDialog is Function) { + key.currentState.showAlertDialog(context); + } + }); }); } } - Future getIndexListData([Map params]) async { - const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; + const juejin_flutter = + 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438'; var pageIndex = (params is Map) ? params['pageIndex'] : 0; - final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'}; + final _param = {'page': pageIndex, 'pageSize': 20, 'sort': 'rankIndex'}; var responseList = []; - var pageTotal = 0; + var pageTotal = 0; - try{ + try { var response = await NetUtils.get(juejin_flutter, _param); responseList = response['d']['entrylist']; pageTotal = response['d']['total']; if (!(pageTotal is int) || pageTotal <= 0) { pageTotal = 0; } - }catch(e){ - - } + } catch (e) {} pageIndex += 1; List resultList = new List(); for (int i = 0; i < responseList.length; i++) { @@ -76,50 +75,50 @@ class SubPageState extends State with AutomaticKeepAliveClientMixin{ // No specified type, handles all } } - Map result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex}; + Map result = { + "list": resultList, + 'total': pageTotal, + 'pageIndex': pageIndex + }; return result; } - Widget makeCard(index,item){ - + Widget makeCard(index, item) { var myTitle = '${item.title}'; var myUsername = '${'👲'}: ${item.username} '; var codeUrl = '${item.detailUrl}'; - return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,); + return new ListViewItem( + itemUrl: codeUrl, + itemTitle: myTitle, + data: myUsername, + ); } - headerView(){ - return - Column( - children: [ + headerView() { + return Column( + children: [ Stack( - //alignment: const FractionalOffset(0.9, 0.1),//方法一 - children: [ - Pagination(), - Positioned(//方法二 - top: 10.0, - left: 0.0, - child: DisclaimerMsg(key:key,pWidget:this) - ), - ]), - SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)), + //alignment: const FractionalOffset(0.9, 0.1),//方法一 + children: [ + Pagination(), + Positioned( + //方法二 + top: 10.0, + left: 0.0, + child: DisclaimerMsg(key: key, pWidget: this)), + ]), + SizedBox( + height: 1, child: Container(color: Theme.of(context).primaryColor)), SizedBox(height: 10), - ], - ); - + ], + ); } @override Widget build(BuildContext context) { super.build(context); - return new Column( - children: [ - new Expanded( - child: listComp.ListRefresh(getIndexListData,makeCard) - ) - ] - ); + return new Column(children: [ + new Expanded(child: listComp.ListRefresh(getIndexListData, makeCard)) + ]); } } - - diff --git a/lib/views/fourth_page/page_dragger.dart b/lib/views/fourth_page/page_dragger.dart index e36b8282..1e1c1e61 100644 --- a/lib/views/fourth_page/page_dragger.dart +++ b/lib/views/fourth_page/page_dragger.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'dart:ui'; @@ -7,13 +6,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/views/fourth_page/pager_indicator.dart'; class PageDragger extends StatefulWidget { - final canDragLeftToRight; final canDragRightToLeft; final StreamController slideUpdateStream; - PageDragger({ this.canDragLeftToRight, this.canDragRightToLeft, @@ -25,14 +22,13 @@ class PageDragger extends StatefulWidget { } class _PageDraggerState extends State { - static const FULL_TRANSTITION_PX = 300.0; Offset dragStart; SlideDirection slideDirection; double slidePercent = 0.0; - onDragStart(DragStartDetails details){ + onDragStart(DragStartDetails details) { dragStart = details.globalPosition; } @@ -49,28 +45,22 @@ class _PageDraggerState extends State { slideDirection = SlideDirection.none; } - if (slideDirection != SlideDirection.none){ - slidePercent = (dx / FULL_TRANSTITION_PX).abs().clamp(0.0, 1.0); + if (slideDirection != SlideDirection.none) { + slidePercent = (dx / FULL_TRANSTITION_PX).abs().clamp(0.0, 1.0); } else { slidePercent = 0.0; } widget.slideUpdateStream.add( - new SlideUpdate( - UpdateType.dragging, - slideDirection, - slidePercent - )); + new SlideUpdate(UpdateType.dragging, slideDirection, slidePercent)); } } - onDragEnd(DragEndDetails details){ - widget.slideUpdateStream.add( - new SlideUpdate( + onDragEnd(DragEndDetails details) { + widget.slideUpdateStream.add(new SlideUpdate( UpdateType.doneDragging, SlideDirection.none, 0.0, - ) - ); + )); dragStart = null; } @@ -78,15 +68,14 @@ class _PageDraggerState extends State { @override Widget build(BuildContext context) { return GestureDetector( - onHorizontalDragStart: onDragStart , - onHorizontalDragUpdate: onDragUpdate , - onHorizontalDragEnd: onDragEnd , + onHorizontalDragStart: onDragStart, + onHorizontalDragUpdate: onDragUpdate, + onHorizontalDragEnd: onDragEnd, ); } } -class AnimatedPageDragger{ - +class AnimatedPageDragger { static const PERCENT_PER_MILLISECOND = 0.005; final slideDirection; @@ -95,85 +84,67 @@ class AnimatedPageDragger{ AnimationController completionAnimationController; AnimatedPageDragger({ - this.slideDirection, - this.transitionGoal, - slidePercent, - StreamController slideUpdateStream, - TickerProvider vsync, + this.slideDirection, + this.transitionGoal, + slidePercent, + StreamController slideUpdateStream, + TickerProvider vsync, }) { final startSlidePercent = slidePercent; var endSlidePercent; var duration; - if ( transitionGoal == TransitionGoal.open){ + if (transitionGoal == TransitionGoal.open) { endSlidePercent = 1.0; final slideRemaining = 1.0 - slidePercent; duration = new Duration( - milliseconds: (slideRemaining / PERCENT_PER_MILLISECOND).round() - ); - + milliseconds: (slideRemaining / PERCENT_PER_MILLISECOND).round()); } else { endSlidePercent = 0.0; duration = new Duration( - milliseconds: (slidePercent / PERCENT_PER_MILLISECOND).round() - ); + milliseconds: (slidePercent / PERCENT_PER_MILLISECOND).round()); } - completionAnimationController = new AnimationController( - duration: duration, - vsync: vsync - ) - ..addListener((){ - slidePercent = lerpDouble( - startSlidePercent, - endSlidePercent, - completionAnimationController.value - ); - - slideUpdateStream.add( - new SlideUpdate( - UpdateType.animating, - slideDirection, - slidePercent, - ) - ); - - }) - - ..addStatusListener((AnimationStatus status){ - - if(status == AnimationStatus.completed){ - slideUpdateStream.add( - new SlideUpdate( - UpdateType.doneAnimating, - slideDirection, - endSlidePercent, - ) - ); - } - - }); + completionAnimationController = + new AnimationController(duration: duration, vsync: vsync) + ..addListener(() { + slidePercent = lerpDouble(startSlidePercent, endSlidePercent, + completionAnimationController.value); + slideUpdateStream.add(new SlideUpdate( + UpdateType.animating, + slideDirection, + slidePercent, + )); + }) + ..addStatusListener((AnimationStatus status) { + if (status == AnimationStatus.completed) { + slideUpdateStream.add(new SlideUpdate( + UpdateType.doneAnimating, + slideDirection, + endSlidePercent, + )); + } + }); } - run(){ + run() { completionAnimationController.forward(from: 0.0); } - dispose(){ + dispose() { completionAnimationController.dispose(); } - } -enum TransitionGoal{ +enum TransitionGoal { open, close, } -enum UpdateType{ +enum UpdateType { dragging, doneDragging, animating, @@ -185,9 +156,5 @@ class SlideUpdate { final direction; final slidePercent; - SlideUpdate( - this.updateType, - this.direction, - this.slidePercent - ); + SlideUpdate(this.updateType, this.direction, this.slidePercent); } diff --git a/lib/views/fourth_page/page_reveal.dart b/lib/views/fourth_page/page_reveal.dart index 4cd5a48a..ded05eeb 100644 --- a/lib/views/fourth_page/page_reveal.dart +++ b/lib/views/fourth_page/page_reveal.dart @@ -3,14 +3,10 @@ import 'dart:math'; import 'package:flutter/material.dart'; class PageReveal extends StatelessWidget { - final double revealPercent; final Widget child; - PageReveal({ - this.revealPercent, - this.child - }); + PageReveal({this.revealPercent, this.child}); @override Widget build(BuildContext context) { @@ -21,18 +17,13 @@ class PageReveal extends StatelessWidget { } } -class CircleRevealClipper extends CustomClipper{ - +class CircleRevealClipper extends CustomClipper { final double revealPercent; - - CircleRevealClipper( - this.revealPercent - ); + CircleRevealClipper(this.revealPercent); @override Rect getClip(Size size) { - final epicenter = new Offset(size.width / 2, size.height * 0.9); double theta = atan(epicenter.dy / epicenter.dx); @@ -41,12 +32,12 @@ class CircleRevealClipper extends CustomClipper{ final radius = distanceToCorner * revealPercent; final diameter = 2 * radius; - return new Rect.fromLTWH(epicenter.dx - radius, epicenter.dy - radius, diameter, diameter); + return new Rect.fromLTWH( + epicenter.dx - radius, epicenter.dy - radius, diameter, diameter); } @override bool shouldReclip(CustomClipper oldClipper) { return true; } - -} \ No newline at end of file +} diff --git a/lib/views/fourth_page/pager_indicator.dart b/lib/views/fourth_page/pager_indicator.dart index c3aa7438..b077cc49 100644 --- a/lib/views/fourth_page/pager_indicator.dart +++ b/lib/views/fourth_page/pager_indicator.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/views/fourth_page/pages.dart'; class PagerIndicator extends StatelessWidget { - final PagerIndicatorViewModel viewModel; PagerIndicator({ @@ -14,47 +13,49 @@ class PagerIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - List bubbles = []; - for(var i = 0; i < viewModel.pages.length; ++i ){ + for (var i = 0; i < viewModel.pages.length; ++i) { final page = viewModel.pages[i]; var percentActive; - if(i == viewModel.activeIndex){ + if (i == viewModel.activeIndex) { percentActive = 1.0 - viewModel.slidePercent; - } else if (i == viewModel.activeIndex - 1 && viewModel.slideDirection == SlideDirection.leftToRight){ + } else if (i == viewModel.activeIndex - 1 && + viewModel.slideDirection == SlideDirection.leftToRight) { percentActive = viewModel.slidePercent; - } else if (i == viewModel.activeIndex + 1 && viewModel.slideDirection == SlideDirection.rightToLeft){ + } else if (i == viewModel.activeIndex + 1 && + viewModel.slideDirection == SlideDirection.rightToLeft) { percentActive = viewModel.slidePercent; - }else { + } else { percentActive = 0.0; } - bool isHollow = i > viewModel.activeIndex || (i == viewModel.activeIndex && viewModel.slideDirection == SlideDirection.leftToRight); - - + bool isHollow = i > viewModel.activeIndex || + (i == viewModel.activeIndex && + viewModel.slideDirection == SlideDirection.leftToRight); bubbles.add( - new PageBubble( + new PageBubble( viewModel: new PageBubbleViewModel( - page.iconAssetPath, - page.color, - isHollow, - percentActive, + page.iconAssetPath, + page.color, + isHollow, + percentActive, ), ), ); } - final bubbleWidth = 55.0 ; - final baseTranslation = ((viewModel.pages.length * bubbleWidth) / 2) - (bubbleWidth / 2) ; + final bubbleWidth = 55.0; + final baseTranslation = + ((viewModel.pages.length * bubbleWidth) / 2) - (bubbleWidth / 2); var translation = baseTranslation - (viewModel.activeIndex * bubbleWidth); - if (viewModel.slideDirection == SlideDirection.leftToRight){ - translation = bubbleWidth * viewModel.slidePercent + translation; - }else if (viewModel.slideDirection == SlideDirection.rightToLeft){ - translation = bubbleWidth * viewModel.slidePercent - translation; + if (viewModel.slideDirection == SlideDirection.leftToRight) { + translation = bubbleWidth * viewModel.slidePercent + translation; + } else if (viewModel.slideDirection == SlideDirection.rightToLeft) { + translation = bubbleWidth * viewModel.slidePercent - translation; } return new Column( @@ -72,37 +73,26 @@ class PagerIndicator extends StatelessWidget { } } -enum SlideDirection{ +enum SlideDirection { leftToRight, rightToLeft, none, } - -class PagerIndicatorViewModel{ +class PagerIndicatorViewModel { final List pages; final int activeIndex; final SlideDirection slideDirection; final double slidePercent; PagerIndicatorViewModel( - this.pages, - this.activeIndex, - this.slideDirection, - this.slidePercent - ); - - + this.pages, this.activeIndex, this.slideDirection, this.slidePercent); } class PageBubble extends StatelessWidget { - final PageBubbleViewModel viewModel; - - PageBubble({ - this.viewModel - }); + PageBubble({this.viewModel}); @override Widget build(BuildContext context) { @@ -111,16 +101,18 @@ class PageBubble extends StatelessWidget { height: 65.0, child: new Center( child: new Container( - width: lerpDouble(20.0,45.0,viewModel.activePercent), - height: lerpDouble(20.0,45.0,viewModel.activePercent), + width: lerpDouble(20.0, 45.0, viewModel.activePercent), + height: lerpDouble(20.0, 45.0, viewModel.activePercent), decoration: new BoxDecoration( shape: BoxShape.circle, color: viewModel.isHollow - ? const Color(0x88FFFFFF).withAlpha(0x88 * viewModel.activePercent.round()) + ? const Color(0x88FFFFFF) + .withAlpha(0x88 * viewModel.activePercent.round()) : const Color(0x88FFFFFF), border: new Border.all( color: viewModel.isHollow - ? const Color(0x88FFFFFF).withAlpha((0x88 * (1.0 - viewModel.activePercent)).round()) + ? const Color(0x88FFFFFF).withAlpha( + (0x88 * (1.0 - viewModel.activePercent)).round()) : Colors.transparent, width: 3.0, ), @@ -138,20 +130,16 @@ class PageBubble extends StatelessWidget { } } - class PageBubbleViewModel { final String iconAssetPath; final Color color; final bool isHollow; final double activePercent; - PageBubbleViewModel ( - this.iconAssetPath, - this.color, - this.isHollow, - this.activePercent, - ); - - + PageBubbleViewModel( + this.iconAssetPath, + this.color, + this.isHollow, + this.activePercent, + ); } - diff --git a/lib/views/fourth_page/pages.dart b/lib/views/fourth_page/pages.dart index 5d088e07..4d2c2c6d 100644 --- a/lib/views/fourth_page/pages.dart +++ b/lib/views/fourth_page/pages.dart @@ -58,7 +58,8 @@ class Page extends StatelessWidget { elevation: 10.0, color: Colors.black26, // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.horizontal(left: Radius.circular(20.0))), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.horizontal(left: Radius.circular(20.0))), //如果不手动设置icon和text颜色,则默认使用foregroundColor颜色 icon: Icon(iconName, color: Colors.white, size: 14.0), label: Text( @@ -76,6 +77,7 @@ class Page extends StatelessWidget { children: [ Container( width: double.infinity, + /// height:MediaQuery.of(context).size.height-200.0, color: viewModel.color, padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), @@ -86,15 +88,13 @@ class Page extends StatelessWidget { layout(context), ], ), - ) - ), + )), Positioned( right: -5.0, top: 2.0, - child: creatButton(context, 'GitHub', Icons.arrow_forward, 'goGithub') - ), - ] - ); + child: creatButton( + context, 'GitHub', Icons.arrow_forward, 'goGithub')), + ]); } Column layout(BuildContext context) { diff --git a/lib/views/home.dart b/lib/views/home.dart index f8e6815f..4865161f 100644 --- a/lib/views/home.dart +++ b/lib/views/home.dart @@ -6,27 +6,30 @@ /// target: app首页 import 'package:flutter/material.dart'; + /// import 'package:flutter/rendering.dart'; import 'package:flutter_go/utils/data_utils.dart'; import 'package:flutter_go/utils/shared_preferences.dart'; + /// import 'package:flutter_go/views/first_page/first_page.dart'; import 'package:flutter_go/views/first_page/main_page.dart'; import 'package:fluro/fluro.dart'; import 'package:flutter_go/views/user_page/user_page.dart'; import 'package:flutter_go/views/widget_page/widget_page.dart'; import 'package:flutter_go/views/welcome_page/fourth_page.dart'; + /// import 'package:flutter_go/views/collection_page/collection_page.dart'; import 'package:flutter_go/routers/application.dart'; + /// import 'package:flutter_go/utils/provider.dart'; import 'package:flutter_go/model/widget.dart'; + /// import 'package:flutter_go/widgets/index.dart'; import 'package:flutter_go/components/search_input.dart'; import 'package:flutter_go/model/search_history.dart'; import 'package:flutter_go/resources/widget_name_to_icon.dart'; import 'package:flutter_go/model/user_info.dart'; - - class AppPage extends StatefulWidget { final UserInformation userInfo; @@ -62,10 +65,11 @@ class _MyHomePageState extends State print('widget.userInfo ${widget.userInfo}'); initSearchHistory(); - if(Application.pageIsOpen == true){// 是否展开业界动态 + if (Application.pageIsOpen == true) { + // 是否展开业界动态 tabData.insert(0, {'text': '业界动态', 'icon': Icon(Icons.language)}); _list - //..add(FirstPage()) + //..add(FirstPage()) ..add(MainPage(userInfo: widget.userInfo)); } appBarTitle = tabData[0]['text']; @@ -78,10 +82,10 @@ class _MyHomePageState extends State ), )); } - _list - ..add(WidgetPage()) - ..add(FourthPage()) - ..add(UserPage(userInfo: widget.userInfo)); + _list + ..add(WidgetPage()) + ..add(FourthPage()) + ..add(UserPage(userInfo: widget.userInfo)); } @override @@ -99,8 +103,8 @@ class _MyHomePageState extends State void onWidgetTap(WidgetPoint widgetPoint, BuildContext context) { String targetName = widgetPoint.name; String targetRouter = widgetPoint.routerName; - searchHistoryList.add( - SearchHistory(name: targetName, targetRouter: targetRouter)); + searchHistoryList + .add(SearchHistory(name: targetName, targetRouter: targetRouter)); print("searchHistoryList1 ${searchHistoryList.toString()}"); Application.router.navigateTo(context, targetRouter.toLowerCase(), transition: TransitionType.inFromRight); @@ -131,7 +135,7 @@ class _MyHomePageState extends State renderAppBar(BuildContext context, Widget widget, int index) { if (index == 1 && Application.pageIsOpen == true) { return AppBar(title: buildSearchInput(context)); - }else if(index == 0 && Application.pageIsOpen == false){ + } else if (index == 0 && Application.pageIsOpen == false) { return AppBar(title: buildSearchInput(context)); } } diff --git a/lib/views/issuse_message_page/issuse_message_page.dart b/lib/views/issuse_message_page/issuse_message_page.dart index 0bfef825..a4c94814 100644 --- a/lib/views/issuse_message_page/issuse_message_page.dart +++ b/lib/views/issuse_message_page/issuse_message_page.dart @@ -6,8 +6,6 @@ import 'package:flutter_go/utils/data_utils.dart'; import 'package:notus/convert.dart'; import 'package:fluttertoast/fluttertoast.dart'; - - class IssuesMessagePage extends StatefulWidget { @override _IssuesMessagePageState createState() => _IssuesMessagePageState(); @@ -48,15 +46,17 @@ class _IssuesMessagePageState extends State { if (_title.trim().isEmpty) { _show('标题不能为空'); } else { - String mk = (_delta==null)?'No description provided.':notusMarkdown.encode(_delta); - DataUtils.feedback({'title': _title, "body": mk},context).then((result) { + String mk = (_delta == null) + ? 'No description provided.' + : notusMarkdown.encode(_delta); + DataUtils.feedback({'title': _title, "body": mk}, context).then((result) { _show('提交成功'); Navigator.maybePop(context); }); } } - _show(String msgs){ + _show(String msgs) { Fluttertoast.showToast( msg: msgs, toastLength: Toast.LENGTH_SHORT, @@ -68,20 +68,19 @@ class _IssuesMessagePageState extends State { } Widget buildLoading() { - return Opacity( - opacity: .5, - child: Container( - width: MediaQuery.of(context).size.width * 0.85, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(8.0)), - color: Colors.black, - ), - child: SpinKitPouringHourglass(color: Colors.white), + return Opacity( + opacity: .5, + child: Container( + width: MediaQuery.of(context).size.width * 0.85, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(8.0)), + color: Colors.black, ), - ); + child: SpinKitPouringHourglass(color: Colors.white), + ), + ); } - @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/views/login_page/login_page.dart b/lib/views/login_page/login_page.dart index a24d6625..0d7d24ad 100644 --- a/lib/views/login_page/login_page.dart +++ b/lib/views/login_page/login_page.dart @@ -256,15 +256,15 @@ class _LoginPageState extends State { MaterialPageRoute(builder: (context) => AppPage(userResult)), (route) => route == null); } - }else if(userResult.runtimeType == String){ + } else if (userResult.runtimeType == String) { Fluttertoast.showToast( - msg: userResult, - toastLength: Toast.LENGTH_SHORT, - gravity: ToastGravity.CENTER, - timeInSecForIos: 1, - backgroundColor: Theme.of(context).primaryColor, - textColor: Colors.white, - fontSize: 16.0); + msg: userResult, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIos: 1, + backgroundColor: Theme.of(context).primaryColor, + textColor: Colors.white, + fontSize: 16.0); } }).catchError((errorMsg) { setState(() { @@ -388,7 +388,9 @@ class _LoginPageState extends State { decoration: TextDecoration.underline), ), onPressed: () { - Application.router.navigateTo(context, Routes.home, clearStack: true); + Application.router.navigateTo( + context, Routes.home, + clearStack: true); }, ) ], diff --git a/lib/views/standard_demo_page/index.dart b/lib/views/standard_demo_page/index.dart index 20264f9d..6f26efd1 100644 --- a/lib/views/standard_demo_page/index.dart +++ b/lib/views/standard_demo_page/index.dart @@ -19,12 +19,12 @@ import 'package:flutter_go/routers/routers.dart'; import 'package:flutter_go/utils/net_utils.dart'; import 'package:flutter_go/components/loading.dart'; -const githubHost = 'https://raw.githubusercontent.com/alibaba/flutter-go/master'; +const githubHost = + 'https://raw.githubusercontent.com/alibaba/flutter-go/master'; const githubUrl = '$githubHost/lib/standard_pages/'; const PagesUrl = '$githubHost/lib/standard_pages/.pages.json'; const DemosUrl = '$githubHost/lib/page_demo_package/.demo.json'; - // ONLINE || LOCAL ENV env = Application.env; @@ -54,9 +54,11 @@ class _StandardView extends State { // } /// 本地调用的获取文章属性的基本信息 Future localGetPagesAttrsInfo() async { - String jsonString = await DefaultAssetBundle.of(context).loadString('lib/standard_pages/.pages.json'); + String jsonString = await DefaultAssetBundle.of(context) + .loadString('lib/standard_pages/.pages.json'); List jsonList = json.decode(jsonString); - Map pageDetail = jsonList.firstWhere((item) => item['id'] == widget.id, orElse: null); + Map pageDetail = + jsonList.firstWhere((item) => item['id'] == widget.id, orElse: null); if (pageDetail != null) { setState(() { @@ -69,12 +71,12 @@ class _StandardView extends State { /// 从本地获取基本文章信息 String localGetPagesMarkdown() { - String pageId = widget.id; Map pagesList = standardPage.getPages(); // print('pagesList[pageId]>>> ${pagesList[pageId]}'); return pagesList[pageId]; } + Future getContentOnline() async { this.setState(() { isLoading = true; @@ -82,8 +84,6 @@ class _StandardView extends State { List response = jsonDecode(await NetUtils.get(PagesUrl)); - - Map targetPage = response.firstWhere((page) => page['id'] == widget.id); if (targetPage == null) { setState(() { @@ -97,13 +97,18 @@ class _StandardView extends State { email = targetPage['email']; }); - String pageName = targetPage['name'] + "_" +targetPage['author']+ "_" +targetPage['id']; + String pageName = targetPage['name'] + + "_" + + targetPage['author'] + + "_" + + targetPage['id']; String pageContent = await NetUtils.get(githubUrl + pageName + "/index.md"); setState(() { isLoading = false; }); return Future(() => pageContent); } + /// 获取当面界面的相关信息. 需要区分环境 /// 本地环境下, 从本地获取 standard_pages的目录中互殴 /// 线上环境. 从github的api中获取 @@ -124,6 +129,7 @@ class _StandardView extends State { } return Future(() => conent); } + void seeSourceCode(id) async { List response; try { @@ -132,16 +138,18 @@ class _StandardView extends State { return alertDialog(msg: '请检查网络链接', title: '提示'); } - Map demoDetail = response.firstWhere((item) => item['id'] == id, orElse: null); + Map demoDetail = + response.firstWhere((item) => item['id'] == id, orElse: null); if (demoDetail == null) { return null; } - String remoteSouceCode = '$githubHost/lib/page_demo_package/${demoDetail['name']}_${demoDetail['author']}_${demoDetail['id']}/src/index.dart'; - Application.router.navigateTo(context, - '${Routes.githubCodeView}?remotePath=${Uri.encodeComponent(remoteSouceCode)}'); - + String remoteSouceCode = + '$githubHost/lib/page_demo_package/${demoDetail['name']}_${demoDetail['author']}_${demoDetail['id']}/src/index.dart'; + Application.router.navigateTo(context, + '${Routes.githubCodeView}?remotePath=${Uri.encodeComponent(remoteSouceCode)}'); } + Widget buildFootInfo() { if (!isLoading) { return Container( @@ -159,8 +167,6 @@ class _StandardView extends State { } Widget buildMarkdown() { - - if (markdownDesc == null) { return null; } else { @@ -172,7 +178,7 @@ class _StandardView extends State { return MarkdownBody( data: markdownDesc, - syntaxHighlighter:new mdCopy.HighLight(), + syntaxHighlighter: new mdCopy.HighLight(), demoBuilder: (Map attrs) { List demo = demoObjects[attrs['id']]; if (demo == null) { @@ -193,28 +199,29 @@ class _StandardView extends State { onTap: () { seeSourceCode(attrs['id']); }, - child: Text("查看源码", style: TextStyle(color: Theme.of(context).primaryColor)), + child: Text("查看源码", + style: TextStyle(color: Theme.of(context).primaryColor)), ) ], - ) ; + ); } }); } + alertDialog({String msg, String title}) { showDialog( context: context, barrierDismissible: true, builder: (BuildContext context) { return new AlertDialog( - title: new Text(title), - content: new SingleChildScrollView( - child: new ListBody( - children: [ - new Text(msg), - ], - ), - ) - ); + title: new Text(title), + content: new SingleChildScrollView( + child: new ListBody( + children: [ + new Text(msg), + ], + ), + )); }, ); } diff --git a/lib/views/welcome_page/index.dart b/lib/views/welcome_page/index.dart index 36576bcb..6360373d 100644 --- a/lib/views/welcome_page/index.dart +++ b/lib/views/welcome_page/index.dart @@ -20,12 +20,8 @@ class WelcomePage extends StatefulWidget { } class _WelcomePageState extends State { - @override Widget build(BuildContext context) { - return new Container( - color: Colors.white, - child: FourthPage() - ); + return new Container(color: Colors.white, child: FourthPage()); } } diff --git a/lib/views/widget_page/widget_page.dart b/lib/views/widget_page/widget_page.dart index 5df042cb..6bc118ee 100644 --- a/lib/views/widget_page/widget_page.dart +++ b/lib/views/widget_page/widget_page.dart @@ -1,5 +1,5 @@ -/// Author: 一凨 -/// Date: 2019-01-11 14:39:48 +/// Author: 一凨 +/// Date: 2019-01-11 14:39:48 /// Last Modified by: 一凨 /// Last Modified time: 2019-01-11 14:40:09 @@ -9,36 +9,27 @@ import 'package:flutter_go/components/cate_card.dart'; import 'package:flutter_go/routers/application.dart'; - class WidgetPage extends StatefulWidget { - - - - @override SecondPageState createState() => new SecondPageState(); } -class SecondPageState extends State with AutomaticKeepAliveClientMixin{ - +class SecondPageState extends State + with AutomaticKeepAliveClientMixin { SecondPageState() : super(); TextEditingController controller; String active = 'test'; String data = '无'; - + @override + bool get wantKeepAlive => true; @override - bool get wantKeepAlive => true; - - @override - void initState() { + void initState() { super.initState(); } - - Widget buildGrid() { // 存放最后的widget List tiles = []; @@ -58,5 +49,4 @@ class SecondPageState extends State with AutomaticKeepAliveClientMix child: this.buildGrid(), ); } - } diff --git a/lib/widgets/404.dart b/lib/widgets/404.dart index 52149ac3..49a0e9c2 100644 --- a/lib/widgets/404.dart +++ b/lib/widgets/404.dart @@ -1,15 +1,12 @@ import 'package:flutter/material.dart'; class WidgetNotFound extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text("widget not found"), - ), - body: Container( - child: Text("widget not found") - ) - ); - } + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("widget not found"), + ), + body: Container(child: Text("widget not found"))); + } } diff --git a/lib/widgets/components/Bar/AppBar/demo.dart b/lib/widgets/components/Bar/AppBar/demo.dart index a2eb5bd0..8c580a9d 100644 --- a/lib/widgets/components/Bar/AppBar/demo.dart +++ b/lib/widgets/components/Bar/AppBar/demo.dart @@ -18,15 +18,17 @@ class AppBarLessDefaultComplex extends StatefulWidget { } // AppBar 默认的实例,有状态 -class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixin { +class _AppBarLessDefaultComplex extends State + with SingleTickerProviderStateMixin { ScrollController _scrollViewController; TabController _tabController; @override void initState() { super.initState(); - _scrollViewController = ScrollController(); - _tabController = TabController(vsync: this, length: 6);// 和下面的 TabBar.tabs 数量对应 + _scrollViewController = ScrollController(); + _tabController = + TabController(vsync: this, length: 6); // 和下面的 TabBar.tabs 数量对应 } @override @@ -41,48 +43,49 @@ class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixi // 如果省略了 leading ,但 AppBar 在带有 Drawer 的 Scaffold 中,则会插入一个 button 以打开 Drawer。 // 否则,如果最近的 Navigator 具有任何先前的 router ,则会插入BackButton。 // 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。 - return SizedBox( + return SizedBox( height: 500, - child: AppBar( // 大量配置属性参考 SliverAppBar 示例 - title: Text('title'), - leading: Icon(Icons.home), + child: AppBar( + // 大量配置属性参考 SliverAppBar 示例 + title: Text('title'), + leading: Icon(Icons.home), backgroundColor: Colors.amber[500], centerTitle: true, actions: [ - IconButton( - icon: Icon(Icons.add_alarm), + IconButton( + icon: Icon(Icons.add_alarm), tooltip: 'Add Alarm', onPressed: () { // do nothing }), - PopupMenuButton( + PopupMenuButton( itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: "price", child: Text('Sort by price')), - PopupMenuItem( - value: "time", child: Text('Sort by time')), - ], + PopupMenuItem( + value: "price", child: Text('Sort by price')), + PopupMenuItem( + value: "time", child: Text('Sort by time')), + ], onSelected: (String action) { switch (action) { case "price": - // do nothing + // do nothing break; case "time": - // do nothing + // do nothing break; } }) ], - bottom: TabBar( + bottom: TabBar( isScrollable: true, controller: _tabController, tabs: [ - Tab(text: "Tabs 1"), - Tab(text: "Tabs 2"), - Tab(text: "Tabs 3"), - Tab(text: "Tabs 4"), - Tab(text: "Tabs 5"), - Tab(text: "Tabs 6"), + Tab(text: "Tabs 1"), + Tab(text: "Tabs 2"), + Tab(text: "Tabs 3"), + Tab(text: "Tabs 4"), + Tab(text: "Tabs 5"), + Tab(text: "Tabs 6"), ], ), ), @@ -90,40 +93,37 @@ class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixi } } - // AppBar 默认的实例,无状态 class AppBarLessDefaultSimple extends StatelessWidget { final widget; final parent; - const AppBarLessDefaultSimple([this.widget, this.parent]) - : super(); + const AppBarLessDefaultSimple([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { - return SizedBox( - height: 200, - child:AppBar( - title: Text('My Fancy Dress'), - actions: [ - IconButton( - icon: Icon(Icons.playlist_play), - tooltip: 'Air it', - onPressed: ()=>{}, - ), - IconButton( - icon: Icon(Icons.playlist_add), - tooltip: 'Restitch it', - onPressed: ()=>{}, - ), - IconButton( - icon: Icon(Icons.playlist_add_check), - tooltip: 'Repair it', - onPressed: ()=>{}, - ), - ], - ) - ); + return SizedBox( + height: 200, + child: AppBar( + title: Text('My Fancy Dress'), + actions: [ + IconButton( + icon: Icon(Icons.playlist_play), + tooltip: 'Air it', + onPressed: () => {}, + ), + IconButton( + icon: Icon(Icons.playlist_add), + tooltip: 'Restitch it', + onPressed: () => {}, + ), + IconButton( + icon: Icon(Icons.playlist_add_check), + tooltip: 'Repair it', + onPressed: () => {}, + ), + ], + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/AppBar/index.dart b/lib/widgets/components/Bar/AppBar/index.dart index dac6d0b6..abc6199e 100644 --- a/lib/widgets/components/Bar/AppBar/index.dart +++ b/lib/widgets/components/Bar/AppBar/index.dart @@ -10,23 +10,19 @@ import 'package:flutter/material.dart'; import './demo.dart' as AppBarDemo; import 'package:flutter_go/components/widget_demo.dart'; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > AppBar “应用栏” - 应用栏由工具栏组成,或者是工具栏和其他 widget 组合形成,例如 TabBar和FlexibleSpaceBar; - 应用栏通常用于 Scaffold.appBar 属性,该属性将应用栏放置在屏幕顶部的固定高度小部件中; - 对于可滚动的应用栏,请参阅SliverAppBar,它将AppBar嵌入 sliver 中以便在CustomScrollView中使用; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > AppBar - AppBar 在底部上方显示工具栏 widget,前导 leading ,标题 title 和操作 actions; """; -const String _Text2 = -"""### **进阶用法** +const String _Text2 = """### **进阶用法** > AppBar - 一个完整的 AppBar 的例子, 增加 PopupMenuButton,TabBar 的示例子; - 所述底部通常用于一个的 TabBar; diff --git a/lib/widgets/components/Bar/BottomAppBar/demo.dart b/lib/widgets/components/Bar/BottomAppBar/demo.dart index 5473e0da..48ace2c8 100644 --- a/lib/widgets/components/Bar/BottomAppBar/demo.dart +++ b/lib/widgets/components/Bar/BottomAppBar/demo.dart @@ -12,31 +12,39 @@ class AppBarLessDefaultSimple extends StatelessWidget { final widget; final parent; - const AppBarLessDefaultSimple([this.widget, this.parent]) - : super(); + const AppBarLessDefaultSimple([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { - return SizedBox( - height: 100, - child: Scaffold( - //appBar: AppBar(title: const Text('Bottom App Bar')), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, - floatingActionButton: FloatingActionButton( - child: const Icon(Icons.add), onPressed: () {},), + return SizedBox( + height: 100, + child: Scaffold( + //appBar: AppBar(title: const Text('Bottom App Bar')), + floatingActionButtonLocation: + FloatingActionButtonLocation.centerDocked, + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.add), + onPressed: () {}, + ), bottomNavigationBar: BottomAppBar( shape: CircularNotchedRectangle(), - notchMargin: 10.0,// FloatingActionButton和BottomAppBar 之间的差距 - color:Colors.pink, + notchMargin: 10.0, // FloatingActionButton和BottomAppBar 之间的差距 + color: Colors.pink, child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - IconButton(icon: Icon(Icons.menu), onPressed: () {},), - IconButton(icon: Icon(Icons.search), onPressed: () {},), + IconButton( + icon: Icon(Icons.menu), + onPressed: () {}, + ), + IconButton( + icon: Icon(Icons.search), + onPressed: () {}, + ), ], ), ), - ) - ); -}} \ No newline at end of file + )); + } +} diff --git a/lib/widgets/components/Bar/BottomAppBar/index.dart b/lib/widgets/components/Bar/BottomAppBar/index.dart index 132e2ef1..962695d2 100644 --- a/lib/widgets/components/Bar/BottomAppBar/index.dart +++ b/lib/widgets/components/Bar/BottomAppBar/index.dart @@ -11,19 +11,15 @@ import 'package:flutter/material.dart'; import './demo.dart' as BottomAppBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > BottomAppBar “底部应用栏” - 一个通常与 Scaffold.bottomNavigationBar 一起使用的容器,可以在顶部有一个凹口,为重叠的FloatingActionButton腾出空间; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 通常与 Scaffold 和 FloatingActionButton 一起使用; """; - class Demo extends StatefulWidget { static const String routeName = '/components//Bar/BottomAppBar'; @@ -38,7 +34,8 @@ class _DemoState extends State { title: 'BottomAppBar', codeUrl: 'components/Bar/BottomAppBar/demo.dart', contentList: allDomes(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/BottomAppBar-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/BottomAppBar-class.html', ); } } @@ -56,6 +53,3 @@ List allDomes(BuildContext context, _DemoState that) { SizedBox(height: 20.0), // 间距 ]; } - - - diff --git a/lib/widgets/components/Bar/ButtonBar/demo.dart b/lib/widgets/components/Bar/ButtonBar/demo.dart index fb78c633..e4a0d11f 100644 --- a/lib/widgets/components/Bar/ButtonBar/demo.dart +++ b/lib/widgets/components/Bar/ButtonBar/demo.dart @@ -20,8 +20,8 @@ class _ButtonBarFullDefault extends State { @override Widget build(BuildContext context) { return ButtonBar( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -30,37 +30,61 @@ class ButtonBarLessDefault extends StatelessWidget { final widget; final parent; - const ButtonBarLessDefault([this.widget, this.parent]) - : super(); + const ButtonBarLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.symmetric(vertical: 0.0), + margin: EdgeInsets.symmetric(vertical: 0.0), height: 100.0, - child: Scrollbar(child:ListView( - scrollDirection: Axis.horizontal, // 水平listView - children: [ + child: Scrollbar( + child: ListView(scrollDirection: Axis.horizontal, // 水平listView + children: [ ButtonBar( - alignment: MainAxisAlignment.spaceAround, //布局方向,默认MainAxisAlignment.end + alignment: MainAxisAlignment + .spaceAround, //布局方向,默认MainAxisAlignment.end mainAxisSize: MainAxisSize.max, //主轴大小,默认MainAxisSize.max - children: [ // Button集合 - RaisedButton(child: Text('ButtonBar1'),color: Colors.red,onPressed: ()=>{},), - RaisedButton(child: Text('ButtonBar2'),color: Colors.red,onPressed: ()=>{},), - RaisedButton(child: Text('ButtonBar3'),color: Colors.red,onPressed: ()=>{},), + children: [ + // Button集合 + RaisedButton( + child: Text('ButtonBar1'), + color: Colors.red, + onPressed: () => {}, + ), + RaisedButton( + child: Text('ButtonBar2'), + color: Colors.red, + onPressed: () => {}, + ), + RaisedButton( + child: Text('ButtonBar3'), + color: Colors.red, + onPressed: () => {}, + ), ], ), ButtonBar( alignment: MainAxisAlignment.end, //布局方向,默认MainAxisAlignment.end mainAxisSize: MainAxisSize.min, //主轴大小,默认MainAxisSize.max - children: [ // Button集合 - RaisedButton(child: Text('ButtonBar1'),color: Colors.yellow,onPressed: ()=>{},), - RaisedButton(child: Text('ButtonBar2'),color: Colors.yellow,onPressed: ()=>{},), - RaisedButton(child: Text('ButtonBar3'),color: Colors.yellow,onPressed: ()=>{},), + children: [ + // Button集合 + RaisedButton( + child: Text('ButtonBar1'), + color: Colors.yellow, + onPressed: () => {}, + ), + RaisedButton( + child: Text('ButtonBar2'), + color: Colors.yellow, + onPressed: () => {}, + ), + RaisedButton( + child: Text('ButtonBar3'), + color: Colors.yellow, + onPressed: () => {}, + ), ], ) - ] - ) - )); + ]))); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/ButtonBar/index.dart b/lib/widgets/components/Bar/ButtonBar/index.dart index 5078804c..fb55c737 100644 --- a/lib/widgets/components/Bar/ButtonBar/index.dart +++ b/lib/widgets/components/Bar/ButtonBar/index.dart @@ -11,22 +11,18 @@ import 'package:flutter/material.dart'; import './demo.dart' as ButtonBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > ButtonBar “末端对齐的按钮容器” - 横排的Button布局 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 根据当前 ButtonTheme 中的填充水平放置 button - 子 button 在布置行与 MainAxisAlignment.end; - 当 Directionality为TextDirection.ltr 时,按钮栏的子项右对齐,最后一个子项成为最右边的子项; - 当 Directionality TextDirection.rtl 时,子项被左对齐,最后一个子项成为最左边的子项; """; - class Demo extends StatefulWidget { static const String routeName = '/components/Bar/ButtonBar'; @@ -58,4 +54,3 @@ List allDomes(BuildContext context, _DemoState that) { ButtonBarDemo.ButtonBarLessDefault() ]; } - diff --git a/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart b/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart index 078a25b3..bee24fa3 100644 --- a/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart +++ b/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart @@ -4,28 +4,24 @@ /// Time: 下午10:38 /// email: zhu.yan@alibaba-inc.com /// target: FlexibleSpaceBar 的示例 - + import 'package:flutter_go/components/widget_demo.dart'; import 'package:flutter/material.dart'; import './demo.dart' as FlexibleSpaceBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > FlexibleSpaceBar “扩展和折叠的应用栏” - AppBar 的一部分,可以扩展和折叠; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 最常用于 SliverAppBar.flexibleSpace 字段 - 灵活的空格键随着应用滚动而扩展和收缩,以便 AppBar 从应用程序的顶部到达应用程序滚动内容的顶部; - 要调整 AppBar 大小,必须将其包装在 FlexibleSpaceBar.createSettings 返回的 widget 中 ,以将大小调整信息传递给 FlexibleSpaceBar; """; - class Demo extends StatefulWidget { static const String routeName = '/components/Bar/FlexibleSpaceBar'; @@ -40,7 +36,8 @@ class _DemoState extends State { title: 'FlexibleSpaceBar', codeUrl: 'components/Bar/FlexibleSpaceBar/demo.dart', contentList: allDomes(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/FlexibleSpaceBar-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/FlexibleSpaceBar-class.html', ); } } @@ -58,4 +55,3 @@ List allDomes(BuildContext context, _DemoState that) { SizedBox(height: 20.0), // 间距 ]; } - diff --git a/lib/widgets/components/Bar/SliverAppBar/demo.dart b/lib/widgets/components/Bar/SliverAppBar/demo.dart index dec30849..1689e769 100644 --- a/lib/widgets/components/Bar/SliverAppBar/demo.dart +++ b/lib/widgets/components/Bar/SliverAppBar/demo.dart @@ -20,8 +20,8 @@ class _SliverAppBarFullDefault extends State { @override Widget build(BuildContext context) { return SliverAppBar( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -36,9 +36,9 @@ class SliverAppBarLessDefault extends StatelessWidget { @override Widget build(BuildContext context) { for (int i = 0; i < 20; i++) { - listData.add( ListItem("我是测试标题$i", Icons.cake)); + listData.add(ListItem("我是测试标题$i", Icons.cake)); } - return SizedBox( + return SizedBox( height: 500.0, child: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { @@ -56,15 +56,16 @@ class SliverAppBarLessDefault extends StatelessWidget { //iconTheme, // 图标主题,App bar 上图标的颜色、透明度、和尺寸信息。默认值为 ThemeData.primaryIconTheme //textTheme, //文字主题, App bar 上的文字样式。默认值为 ThemeData.primaryTextTheme //centerTitle, //标题是否居中, 标题是否居中显示,默认值根据不同的操作系统,显示方式不一样 - primary: true, //是否预留高度 - forceElevated:false, - automaticallyImplyLeading:true, + primary: true, //是否预留高度 + forceElevated: false, + automaticallyImplyLeading: true, titleSpacing: NavigationToolbar.kMiddleSpacing, - snap:false, //与floating结合使用 - expandedHeight: 200.0,//展开高度 - floating: false,//是否随着滑动隐藏标题 - pinned: true,//是否固定在顶部 - flexibleSpace: FlexibleSpaceBar( //可以展开区域,通常是一个FlexibleSpaceBar + snap: false, //与floating结合使用 + expandedHeight: 200.0, //展开高度 + floating: false, //是否随着滑动隐藏标题 + pinned: true, //是否固定在顶部 + flexibleSpace: FlexibleSpaceBar( + //可以展开区域,通常是一个FlexibleSpaceBar centerTitle: true, title: Text("我是一个帅气的标题", style: TextStyle( @@ -78,30 +79,30 @@ class SliverAppBarLessDefault extends StatelessWidget { fit: BoxFit.fill, )), ), - // SliverPersistentHeader( - // delegate: _SliverAppBarDelegate( - // TabBar( - // controller: TabController(length: 2, vsync: this), - // labelColor: Colors.black87, - // unselectedLabelColor: Colors.grey, - // tabs: [ - // Tab(icon: Icon(Icons.security), text: "security"), - // Tab(icon: Icon(Icons.cake), text: "cake"), - // ], - // ), - // )) + // SliverPersistentHeader( + // delegate: _SliverAppBarDelegate( + // TabBar( + // controller: TabController(length: 2, vsync: this), + // labelColor: Colors.black87, + // unselectedLabelColor: Colors.grey, + // tabs: [ + // Tab(icon: Icon(Icons.security), text: "security"), + // Tab(icon: Icon(Icons.cake), text: "cake"), + // ], + // ), + // )) ]; - }, - body: Center( - child: ListView.builder( - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return ListItemWidget(listData[index]); }, - itemCount: listData.length, - ), - ), - )); + body: Center( + child: ListView.builder( + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return ListItemWidget(listData[index]); + }, + itemCount: listData.length, + ), + ), + )); } } @@ -119,13 +120,12 @@ class ListItemWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return InkWell( - child: ListTile( - leading: Icon(listItem.iconData), - title: Text(listItem.title), + return InkWell( + child: ListTile( + leading: Icon(listItem.iconData), + title: Text(listItem.title), ), onTap: () {}, ); } } - diff --git a/lib/widgets/components/Bar/SliverAppBar/index.dart b/lib/widgets/components/Bar/SliverAppBar/index.dart index 9ca28d7f..9a70c5f8 100644 --- a/lib/widgets/components/Bar/SliverAppBar/index.dart +++ b/lib/widgets/components/Bar/SliverAppBar/index.dart @@ -11,15 +11,12 @@ import 'package:flutter/material.dart'; import './demo.dart' as SliverAppBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > SliverAppBar “应用栏” - 它类似于Android中的toolbar; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 虽然基本相同,构造方法也是非常的简单,但是却不能直接使用它,由官方文档可以看到通常结合 ScrollView 来使用它; - AppBar 和 SliverAppBar 都是继承StatefulWidget 类,都代表 Toobar; - 二者的区别在于 AppBar 位置的固定的应用最上面的;而 SliverAppBar 是可以跟随内容滚动的; @@ -57,4 +54,3 @@ List allDomes(BuildContext context, _DemoState that) { SliverAppBarDemo.SliverAppBarLessDefault() ]; } - diff --git a/lib/widgets/components/Bar/SnackBar/demo.dart b/lib/widgets/components/Bar/SnackBar/demo.dart index 0f463371..90f9c73a 100644 --- a/lib/widgets/components/Bar/SnackBar/demo.dart +++ b/lib/widgets/components/Bar/SnackBar/demo.dart @@ -12,48 +12,47 @@ class SnackBarLessDefault extends StatelessWidget { final widget; final parent; - const SnackBarLessDefault([this.widget, this.parent]) - : super(); + const SnackBarLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { // 当BuildContext在Scaffold之前时,调用Scaffold.of(context)会报错。这时可以通过Builder Widget来解决 - return Center( - child: Column( - children: [ - GestureDetector( - onTap: () { - final snackBar = SnackBar( - content: Text('这是一个SnackBar, 右侧有SnackBarAction'), - backgroundColor:Colors.red, - action: SnackBarAction( // 提示信息上添加一个撤消的按钮 - textColor:Colors.black, - label: '撤消', - onPressed: () { - // Some code to undo the change! - }, - ), - duration:Duration(minutes: 1),// 持续时间 - //animation, - ); - Scaffold.of(context).showSnackBar(snackBar); - }, - child: Text('显示SnackBar'), - ), - GestureDetector( - onTap: () { - final snackBar = SnackBar( - content: Text('右侧无SnackBarAction'), - backgroundColor:Colors.red, - duration:Duration(minutes: 1),// 持续时间 - //animation, - ); - Scaffold.of(context).showSnackBar(snackBar); - }, - child: Text('显示无SnackBarAction的SnackBar'), - ), - ], - ) - ); + return Center( + child: Column( + children: [ + GestureDetector( + onTap: () { + final snackBar = SnackBar( + content: Text('这是一个SnackBar, 右侧有SnackBarAction'), + backgroundColor: Colors.red, + action: SnackBarAction( + // 提示信息上添加一个撤消的按钮 + textColor: Colors.black, + label: '撤消', + onPressed: () { + // Some code to undo the change! + }, + ), + duration: Duration(minutes: 1), // 持续时间 + //animation, + ); + Scaffold.of(context).showSnackBar(snackBar); + }, + child: Text('显示SnackBar'), + ), + GestureDetector( + onTap: () { + final snackBar = SnackBar( + content: Text('右侧无SnackBarAction'), + backgroundColor: Colors.red, + duration: Duration(minutes: 1), // 持续时间 + //animation, + ); + Scaffold.of(context).showSnackBar(snackBar); + }, + child: Text('显示无SnackBarAction的SnackBar'), + ), + ], + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/SnackBar/index.dart b/lib/widgets/components/Bar/SnackBar/index.dart index e476237b..f4d91ef0 100644 --- a/lib/widgets/components/Bar/SnackBar/index.dart +++ b/lib/widgets/components/Bar/SnackBar/index.dart @@ -9,21 +9,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as SnackBarDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > SnackBar “屏幕底部消息” - 带有可选操作的轻量级消息,短暂显示在屏幕底部 - SnackBar是用户操作后,显示提示信息的一个控件,类似Toast,会自动隐藏; """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > Scaffold.of(context).showSnackBar(),传递描述消息的 SnackBar 实例; - 要控制SnackBar保持可见的时间,请指定持续时间。 """; - class Demo extends StatefulWidget { static const String routeName = '/components//Bar/SnackBar'; @@ -55,4 +51,4 @@ List allDomes(BuildContext context, _DemoState that) { SnackBarDemo.SnackBarLessDefault(), SizedBox(height: 20.0), // 间距 ]; -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/SnackBarAction/demo.dart b/lib/widgets/components/Bar/SnackBarAction/demo.dart index 9db5b0a6..fe432316 100644 --- a/lib/widgets/components/Bar/SnackBarAction/demo.dart +++ b/lib/widgets/components/Bar/SnackBarAction/demo.dart @@ -13,44 +13,42 @@ class SnackBarActionDemo extends StatefulWidget { class _Demo extends State { Widget build(BuildContext context) { - return Center( - child: Column( - children: [ - new RaisedButton( - onPressed: () { - final snackBar = new SnackBar( - content: new Text('这是一个SnackBar, 右侧有SnackBarAction, 3秒后消失'), - backgroundColor:Color(0xffc91b3a), - action: SnackBarAction( // 提示信息上添加一个撤消的按钮 - textColor:Colors.white, - label: '撤消', - onPressed: () { - // Some code to undo the change! - }, - ), - duration:Duration(seconds: 3),// 持续时间 - //animation, - ); - Scaffold.of(context).showSnackBar(snackBar); - }, - - child: Text('点我显示有action的SnackBar'), - ), - new RaisedButton( - onPressed: () async { - final snackBar = new SnackBar( - content: new Text('右侧无SnackBarAction, 3秒后消失'), - backgroundColor:Color(0xffc91b3a), - duration:Duration(seconds: 3),// 持续时间 - //animation, - ); - Scaffold.of(context).showSnackBar(snackBar); - }, - child: Text('点我显示无SnackBarAction的SnackBar'), - ), - ], - ) - ); + return Center( + child: Column( + children: [ + new RaisedButton( + onPressed: () { + final snackBar = new SnackBar( + content: new Text('这是一个SnackBar, 右侧有SnackBarAction, 3秒后消失'), + backgroundColor: Color(0xffc91b3a), + action: SnackBarAction( + // 提示信息上添加一个撤消的按钮 + textColor: Colors.white, + label: '撤消', + onPressed: () { + // Some code to undo the change! + }, + ), + duration: Duration(seconds: 3), // 持续时间 + //animation, + ); + Scaffold.of(context).showSnackBar(snackBar); + }, + child: Text('点我显示有action的SnackBar'), + ), + new RaisedButton( + onPressed: () async { + final snackBar = new SnackBar( + content: new Text('右侧无SnackBarAction, 3秒后消失'), + backgroundColor: Color(0xffc91b3a), + duration: Duration(seconds: 3), // 持续时间 + //animation, + ); + Scaffold.of(context).showSnackBar(snackBar); + }, + child: Text('点我显示无SnackBarAction的SnackBar'), + ), + ], + )); } - } diff --git a/lib/widgets/components/Bar/SnackBarAction/index.dart b/lib/widgets/components/Bar/SnackBarAction/index.dart index 7920ea7c..158b27e1 100644 --- a/lib/widgets/components/Bar/SnackBarAction/index.dart +++ b/lib/widgets/components/Bar/SnackBarAction/index.dart @@ -22,7 +22,6 @@ const String _Text0 = """ """; - class Demo extends StatefulWidget { static const String routeName = '/components/Bar/SnackBarAction'; @@ -40,7 +39,8 @@ class _DemoState extends State { _Text0, SnackBarDemo.SnackBarActionDemo(), ], - docUrl: 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html', ); } } diff --git a/lib/widgets/components/Bar/TabBar/demo.dart b/lib/widgets/components/Bar/TabBar/demo.dart index 6b706862..3e41c004 100644 --- a/lib/widgets/components/Bar/TabBar/demo.dart +++ b/lib/widgets/components/Bar/TabBar/demo.dart @@ -22,8 +22,9 @@ class _TabBarDemo extends State with SingleTickerProviderStateMixin { @override void initState() { super.initState(); - _scrollViewController = ScrollController(); - _tabController = TabController(vsync: this, length: 6);// 和下面的 TabBar.tabs 数量对应 + _scrollViewController = ScrollController(); + _tabController = + TabController(vsync: this, length: 6); // 和下面的 TabBar.tabs 数量对应 } @override @@ -38,36 +39,35 @@ class _TabBarDemo extends State with SingleTickerProviderStateMixin { // 如果省略了 leading ,但 AppBar 在带有 Drawer 的 Scaffold 中,则会插入一个 button 以打开 Drawer。 // 否则,如果最近的 Navigator 具有任何先前的 router ,则会插入BackButton。 // 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。 - return SizedBox( - height: 500, - child: Scaffold( - appBar: AppBar( // 大量配置属性参考 SliverAppBar 示例 - title: Text('TabBar'), - leading: Icon(Icons.home), - backgroundColor: Colors.amber[1000], - bottom: TabBar( - isScrollable: true, - controller: _tabController, - tabs: [ - Tab(text: "Tabs 1"), - Tab(text: "Tabs 2"), - Tab(text: "Tabs 3"), - Tab(text: "Tabs 4"), - Tab(text: "Tabs 5"), - Tab(text: "Tabs 6"), - ], + return SizedBox( + height: 500, + child: Scaffold( + appBar: AppBar( + // 大量配置属性参考 SliverAppBar 示例 + title: Text('TabBar'), + leading: Icon(Icons.home), + backgroundColor: Colors.amber[1000], + bottom: TabBar( + isScrollable: true, + controller: _tabController, + tabs: [ + Tab(text: "Tabs 1"), + Tab(text: "Tabs 2"), + Tab(text: "Tabs 3"), + Tab(text: "Tabs 4"), + Tab(text: "Tabs 5"), + Tab(text: "Tabs 6"), + ], + ), ), - ), - body: TabBarView(controller: _tabController, children: [ - Text('TabsView 1'), - Text('TabsView 2'), - Text('TabsView 3'), - Text('TabsView 4'), - Text('TabsView 5'), - Text('TabsView 6'), - ]), - ) - - ); + body: TabBarView(controller: _tabController, children: [ + Text('TabsView 1'), + Text('TabsView 2'), + Text('TabsView 3'), + Text('TabsView 4'), + Text('TabsView 5'), + Text('TabsView 6'), + ]), + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Bar/TabBar/index.dart b/lib/widgets/components/Bar/TabBar/index.dart index f4c16731..c17e6edb 100644 --- a/lib/widgets/components/Bar/TabBar/index.dart +++ b/lib/widgets/components/Bar/TabBar/index.dart @@ -43,7 +43,6 @@ const String _Text0 = """ - controller TabController对象 """; - class Demo extends StatefulWidget { static const String routeName = '/components/Bar/TabBar'; @@ -57,11 +56,9 @@ class _DemoState extends State { return WidgetDemo( title: 'TabBar', codeUrl: 'components/Bar/TabBar/demo.dart', - contentList: [ - _Text0, - TabBarDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html', + contentList: [_Text0, TabBarDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html', ); } } diff --git a/lib/widgets/components/Bar/index.dart b/lib/widgets/components/Bar/index.dart index b93f7f68..f428d19c 100644 --- a/lib/widgets/components/Bar/index.dart +++ b/lib/widgets/components/Bar/index.dart @@ -17,8 +17,6 @@ import 'SnackBar/index.dart' as SnackBar; import 'SnackBarAction/index.dart' as SnackBarAction; import 'TabBar/index.dart' as TabBar; - - List widgetPoints = [ WidgetPoint( name: 'AppBar', diff --git a/lib/widgets/components/Card/Card/demo.dart b/lib/widgets/components/Card/Card/demo.dart index 3a1d4269..6a26af21 100644 --- a/lib/widgets/components/Card/Card/demo.dart +++ b/lib/widgets/components/Card/Card/demo.dart @@ -7,7 +7,6 @@ import 'package:flutter/material.dart'; - /// Checkbox 默认Card的实例 class CardFullDefault extends StatefulWidget { const CardFullDefault() : super(); @@ -16,14 +15,13 @@ class CardFullDefault extends StatefulWidget { State createState() => _CardFullDefault(); } - /// Card 默认的实例,有状态 class _CardFullDefault extends State { @override Widget build(BuildContext context) { return Card( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -32,41 +30,48 @@ class CardLessDefault extends StatelessWidget { final widget; final parent; - const CardLessDefault([this.widget, this.parent]) - : super(); + const CardLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { return Card( - clipBehavior:Clip.antiAlias,// 根据设置裁剪内容 - color:Colors.green, // 卡片背景颜色 - elevation:20.0, // 卡片的z坐标,控制卡片下面的阴影大小 - margin:EdgeInsets.all(20.0), + clipBehavior: Clip.antiAlias, // 根据设置裁剪内容 + color: Colors.green, // 卡片背景颜色 + elevation: 20.0, // 卡片的z坐标,控制卡片下面的阴影大小 + margin: EdgeInsets.all(20.0), // margin: EdgeInsetsDirectional.only(bottom: 30.0, top: 30.0, start: 30.0),// 边距 - semanticContainer:true, // 表示单个语义容器,还是false表示单个语义节点的集合,接受单个child,但该child可以是Row,Column或其他包含子级列表的widget + semanticContainer: + true, // 表示单个语义容器,还是false表示单个语义节点的集合,接受单个child,但该child可以是Row,Column或其他包含子级列表的widget // shape: Border.all( // color: Colors.indigo, width: 1.0, style: BorderStyle.solid), // 卡片材质的形状,以及边框 - shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), // 圆角 + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0)), // 圆角 //borderRadius: BorderRadius.all(Radius.circular(8.0)), - child: Column( //card里面的子控件 + child: Column( + //card里面的子控件 mainAxisSize: MainAxisSize.min, children: [ const ListTile( leading: Icon(Icons.access_time), - title: Text('The Enchanted Nightingale',style: TextStyle(color: Colors.white, fontSize: 40.0)), - subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.',style: TextStyle(color: Colors.yellow, fontSize: 16.0)), - contentPadding: EdgeInsets.all(20.0),// item 内容内边距 + title: Text('The Enchanted Nightingale', + style: TextStyle(color: Colors.white, fontSize: 40.0)), + subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.', + style: TextStyle(color: Colors.yellow, fontSize: 16.0)), + contentPadding: EdgeInsets.all(20.0), // item 内容内边距 ), - ButtonTheme.bar( // make buttons use the appropriate styles for cards + ButtonTheme.bar( + // make buttons use the appropriate styles for cards child: ButtonBar( children: [ FlatButton( - child: const Text('BUY TICKETS',style: TextStyle(color: Colors.black, fontSize: 14.0)), - onPressed: () { }, + child: const Text('BUY TICKETS', + style: TextStyle(color: Colors.black, fontSize: 14.0)), + onPressed: () {}, ), FlatButton( - child: const Text('LISTEN',style: TextStyle(color: Colors.black, fontSize: 14.0)), - onPressed: () { }, + child: const Text('LISTEN', + style: TextStyle(color: Colors.black, fontSize: 14.0)), + onPressed: () {}, ), ], ), @@ -75,4 +80,4 @@ class CardLessDefault extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Card/Card/index.dart b/lib/widgets/components/Card/Card/index.dart index be83fe19..c29092cf 100644 --- a/lib/widgets/components/Card/Card/index.dart +++ b/lib/widgets/components/Card/Card/index.dart @@ -10,19 +10,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as CardDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > Card “卡片” - 卡片用于表示一些相关信息,例如相册,地理位置,用餐,联系方式等 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 此示例显示了创建卡片窗口组件,其中显示了相册信息和两个操作 """; - class Demo extends StatefulWidget { static const String routeName = '/components/Card/Card'; @@ -42,7 +38,6 @@ class _DemoState extends State { } } - /// 所有的 Card widget /// context: 运行上下文 /// that: 指向有状态的 StatefulWidget @@ -55,4 +50,3 @@ List allDomes(BuildContext context, _DemoState that) { CardDemo.CardLessDefault() ]; } - diff --git a/lib/widgets/components/Chip/Chip/demo.dart b/lib/widgets/components/Chip/Chip/demo.dart index 3ba411cb..b76e5e53 100644 --- a/lib/widgets/components/Chip/Chip/demo.dart +++ b/lib/widgets/components/Chip/Chip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 11:40:57 +/// @Date: 2018-12-18 11:40:57 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-14 16:50:43 diff --git a/lib/widgets/components/Chip/Chip/index.dart b/lib/widgets/components/Chip/Chip/index.dart index 709e5fac..6e0f9109 100644 --- a/lib/widgets/components/Chip/Chip/index.dart +++ b/lib/widgets/components/Chip/Chip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 11:40:57 +/// @Date: 2018-12-18 11:40:57 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 15:13:23 @@ -31,11 +31,10 @@ class _DemoState extends State { contentList: [ content0, content1, - ChipDemo(), + ChipDemo(), ], codeUrl: 'components/Chip/Chip/demo.dart', - docUrl: - 'https://docs.flutter.io/flutter/material/Chip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/Chip-class.html', title: 'Chip'); } } diff --git a/lib/widgets/components/Chip/ChipTheme/demo.dart b/lib/widgets/components/Chip/ChipTheme/demo.dart index a764a58d..8a0650a7 100644 --- a/lib/widgets/components/Chip/ChipTheme/demo.dart +++ b/lib/widgets/components/Chip/ChipTheme/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 15:14:10 +/// @Date: 2018-12-18 15:14:10 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 19:15:25 @@ -15,9 +15,11 @@ class _ChipThemeDemoState extends State { @override Widget build(BuildContext context) { return ChipTheme( - data: ChipTheme.of(context).copyWith(backgroundColor:Colors.red.shade800 ), + data: + ChipTheme.of(context).copyWith(backgroundColor: Colors.red.shade800), child: ChoiceChip( - padding: EdgeInsets.only(left: 100.0,right: 100.0,top: 10.0,bottom: 10.0), + padding: + EdgeInsets.only(left: 100.0, right: 100.0, top: 10.0, bottom: 10.0), label: Text('down'), labelStyle: TextStyle(color: Colors.white), onSelected: (bool value) { @@ -31,29 +33,28 @@ class _ChipThemeDemoState extends State { } } - // Widget build(BuildContext context) { - - // return Container( - // child: ChipTheme( - // data: ChipThemeData( - // backgroundColor: Colors.red.shade500, - // //描述颜色对比度(暗,亮,设置固定值) - // brightness : Brightness.dark, - // deleteIconColor: Colors.red.shade200, - // //背景颜色,表示它被禁用 - // disabledColor: Colors.grey.shade50, - // labelPadding: EdgeInsets.all(10.0), - // labelStyle: TextStyle(fontSize: 15.0,fontStyle: FontStyle.italic), - // padding: EdgeInsets.all(2.0), - // //用于另一种chip widget 标签样式 - // secondaryLabelStyle: TextStyle(fontSize: 20.0,fontStyle: FontStyle.normal), - // selectedColor: Colors.yellow, - // //表示已经选中度颜色 - // secondarySelectedColor: Colors.black - // // shape: - // ), - // ), - // ); +// Widget build(BuildContext context) { - - // } +// return Container( +// child: ChipTheme( +// data: ChipThemeData( +// backgroundColor: Colors.red.shade500, +// //描述颜色对比度(暗,亮,设置固定值) +// brightness : Brightness.dark, +// deleteIconColor: Colors.red.shade200, +// //背景颜色,表示它被禁用 +// disabledColor: Colors.grey.shade50, +// labelPadding: EdgeInsets.all(10.0), +// labelStyle: TextStyle(fontSize: 15.0,fontStyle: FontStyle.italic), +// padding: EdgeInsets.all(2.0), +// //用于另一种chip widget 标签样式 +// secondaryLabelStyle: TextStyle(fontSize: 20.0,fontStyle: FontStyle.normal), +// selectedColor: Colors.yellow, +// //表示已经选中度颜色 +// secondarySelectedColor: Colors.black +// // shape: +// ), +// ), +// ); + +// } diff --git a/lib/widgets/components/Chip/ChipTheme/index.dart b/lib/widgets/components/Chip/ChipTheme/index.dart index cc0814f7..7fca797d 100644 --- a/lib/widgets/components/Chip/ChipTheme/index.dart +++ b/lib/widgets/components/Chip/ChipTheme/index.dart @@ -1,7 +1,7 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 15:14:03 +/// @Date: 2018-12-18 15:14:03 /// @Last Modified by: xiaojia.dxj -/// @Last Modified time: 2018-12-18 15:14:03 +/// @Last Modified time: 2018-12-18 15:14:03 import 'package:flutter/material.dart'; @@ -32,11 +32,10 @@ class _DemoState extends State { contentList: [ content0, content1, - ChipThemeDemo(), + ChipThemeDemo(), ], codeUrl: 'components/Chip/ChipTheme/demo.dart', - docUrl: - 'https://docs.flutter.io/flutter/material/ChipTheme-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/ChipTheme-class.html', title: 'ChipTheme'); } } diff --git a/lib/widgets/components/Chip/ChipThemeData/demo.dart b/lib/widgets/components/Chip/ChipThemeData/demo.dart index 9cb2021d..b7a2c4a2 100644 --- a/lib/widgets/components/Chip/ChipThemeData/demo.dart +++ b/lib/widgets/components/Chip/ChipThemeData/demo.dart @@ -1,8 +1,8 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 15:14:10 +/// @Date: 2018-12-18 15:14:10 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 19:39:41 - + import 'package:flutter/material.dart'; class ChipThemeDemo extends StatefulWidget { @@ -16,11 +16,13 @@ class _ChipThemeDemoState extends State { Widget build(BuildContext context) { return ChipTheme( data: ChipThemeData.fromDefaults( - // brightness: Brightness.dark, - labelStyle: TextStyle(fontSize: 15.0), - primaryColor: Colors.red,secondaryColor: Colors.red.shade800), + // brightness: Brightness.dark, + labelStyle: TextStyle(fontSize: 15.0), + primaryColor: Colors.red, + secondaryColor: Colors.red.shade800), child: ChoiceChip( - padding: EdgeInsets.only(left: 100.0,right: 100.0,top: 10.0,bottom: 10.0), + padding: + EdgeInsets.only(left: 100.0, right: 100.0, top: 10.0, bottom: 10.0), label: Text('down'), onSelected: (bool value) { setState(() { @@ -32,6 +34,3 @@ class _ChipThemeDemoState extends State { ); } } - - - diff --git a/lib/widgets/components/Chip/ChipThemeData/index.dart b/lib/widgets/components/Chip/ChipThemeData/index.dart index 86c9690c..3fac0f2b 100644 --- a/lib/widgets/components/Chip/ChipThemeData/index.dart +++ b/lib/widgets/components/Chip/ChipThemeData/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-18 15:14:03 +/// @Date: 2018-12-18 15:14:03 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 17:38:56 @@ -32,7 +32,7 @@ class _DemoState extends State { contentList: [ content0, content1, - ChipThemeDemo(), + ChipThemeDemo(), ], codeUrl: 'components/Chip/ChipThemeData/demo.dart', docUrl: diff --git a/lib/widgets/components/Chip/ChoiceChip/demo.dart b/lib/widgets/components/Chip/ChoiceChip/demo.dart index 3aabd30f..24da893a 100644 --- a/lib/widgets/components/Chip/ChoiceChip/demo.dart +++ b/lib/widgets/components/Chip/ChoiceChip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-19 15:13:24 +/// @Date: 2018-12-19 15:13:24 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-20 19:32:10 @@ -10,41 +10,38 @@ class ChoiceChipDemo extends StatefulWidget { } class _ChoiceChipDemoState extends State { - String _selected = ''; - - List _sub=[ - 'java','web','android' -]; + String _selected = ''; - Iterable get actorWidgets sync*{ - for(String choiceSub in _sub){ + List _sub = ['java', 'web', 'android']; + + Iterable get actorWidgets sync* { + for (String choiceSub in _sub) { yield Padding( - padding:EdgeInsets.all(15.0) , - child: ChoiceChip( - // avatar: Icon(Icons.access_alarm,size: 20.0,color: Colors.white,), - //未选定的时候背景 - backgroundColor:Colors.red, - //被禁用得时候背景 - disabledColor: Colors.blue, - label: Text(choiceSub), - labelStyle: TextStyle(fontWeight: FontWeight.w200,fontSize: 15.0), - labelPadding: EdgeInsets.only(left: 20.0,right: 20.0), + padding: EdgeInsets.all(15.0), + child: ChoiceChip( + // avatar: Icon(Icons.access_alarm,size: 20.0,color: Colors.white,), + //未选定的时候背景 + backgroundColor: Colors.red, + //被禁用得时候背景 + disabledColor: Colors.blue, + label: Text(choiceSub), + labelStyle: TextStyle(fontWeight: FontWeight.w200, fontSize: 15.0), + labelPadding: EdgeInsets.only(left: 20.0, right: 20.0), - materialTapTargetSize: MaterialTapTargetSize.padded, - onSelected: (bool value) { - setState(() { - _selected = value ? choiceSub : 'Colors.red'; - }); - }, - selected: _selected == choiceSub,) - ); - + materialTapTargetSize: MaterialTapTargetSize.padded, + onSelected: (bool value) { + setState(() { + _selected = value ? choiceSub : 'Colors.red'; + }); + }, + selected: _selected == choiceSub, + )); } } - @override + @override Widget build(BuildContext context) { - return Column( + return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Wrap( @@ -52,9 +49,5 @@ class _ChoiceChipDemoState extends State { ), ], ); - } } - - - diff --git a/lib/widgets/components/Chip/ChoiceChip/index.dart b/lib/widgets/components/Chip/ChoiceChip/index.dart index fcc53af4..72ee7881 100644 --- a/lib/widgets/components/Chip/ChoiceChip/index.dart +++ b/lib/widgets/components/Chip/ChoiceChip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-19 15:13:29 +/// @Date: 2018-12-19 15:13:29 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 10:22:57 @@ -30,10 +30,11 @@ class _DemoState extends State { contentList: [ content0, content1, - ChoiceChipDemo(), + ChoiceChipDemo(), ], codeUrl: 'components/Chip/ChoiceChip/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/ChoiceChip-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/ChoiceChip-class.html', title: 'ChoiceChip'); } } diff --git a/lib/widgets/components/Chip/FilterChip/demo.dart b/lib/widgets/components/Chip/FilterChip/demo.dart index ccac842a..9d07305c 100644 --- a/lib/widgets/components/Chip/FilterChip/demo.dart +++ b/lib/widgets/components/Chip/FilterChip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 10:19:46 +/// @Date: 2018-12-20 10:19:46 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-20 14:09:31 @@ -9,46 +9,44 @@ class FilterChipDemo extends StatefulWidget { _FilterChipDemoState createState() => _FilterChipDemoState(); } -class ActorFilerEntry{ +class ActorFilerEntry { final String name; final String initials; - const ActorFilerEntry(this.name,this.initials); + const ActorFilerEntry(this.name, this.initials); } - class _FilterChipDemoState extends State { - final List _list=[ + final List _list = [ const ActorFilerEntry('android', 'ad'), const ActorFilerEntry('java', 'ja'), const ActorFilerEntry('php', 'ph'), const ActorFilerEntry('web', 'wb'), ]; - List _filters=[]; - Iterable get actorWidgets sync*{ - for(ActorFilerEntry actor in _list){ + List _filters = []; + Iterable get actorWidgets sync* { + for (ActorFilerEntry actor in _list) { yield Padding( padding: const EdgeInsets.all(4.0), child: FilterChip( // avatar: CircleAvatar(child: Text(actor.initials),), label: Text(actor.name), selected: _filters.contains(actor.name), - onSelected: (bool value){ + onSelected: (bool value) { setState(() { - if(value){ - _filters.add(actor.name); - }else{ - _filters.retainWhere((String name){ - return name==actor.name; - }); - } - }); + if (value) { + _filters.add(actor.name); + } else { + _filters.retainWhere((String name) { + return name == actor.name; + }); + } + }); }, ), ); } } - @override Widget build(BuildContext context) { @@ -63,6 +61,3 @@ class _FilterChipDemoState extends State { ); } } - - - diff --git a/lib/widgets/components/Chip/FilterChip/index.dart b/lib/widgets/components/Chip/FilterChip/index.dart index eb069e7f..367e71cc 100644 --- a/lib/widgets/components/Chip/FilterChip/index.dart +++ b/lib/widgets/components/Chip/FilterChip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 10:19:55 +/// @Date: 2018-12-20 10:19:55 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 10:25:22 diff --git a/lib/widgets/components/Chip/InputChip/demo.dart b/lib/widgets/components/Chip/InputChip/demo.dart index 04739e70..3bbe3adf 100644 --- a/lib/widgets/components/Chip/InputChip/demo.dart +++ b/lib/widgets/components/Chip/InputChip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 13:32:22 +/// @Date: 2018-12-20 13:32:22 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:31:12 @@ -9,66 +9,56 @@ class FilterChipDemo extends StatefulWidget { _FilterChipDemoState createState() => _FilterChipDemoState(); } -class InputEntry{ +class InputEntry { final String name; final String initials; - const InputEntry(this.name,this.initials); - + const InputEntry(this.name, this.initials); } - -class _FilterChipDemoState extends State { -final List _lists=[ +class _FilterChipDemoState extends State { + final List _lists = [ const InputEntry('android', 'A'), const InputEntry('java', 'J'), const InputEntry('php', 'P'), const InputEntry('web', 'W'), -]; + ]; -List _inputLists=[]; -Iterable get inputWidget sync*{ - for(InputEntry value in _lists){ - _inputLists.add(value); - yield Padding( - padding: const EdgeInsets.all(4.0), - child: InputChip( - avatar: CircleAvatar( - backgroundColor: Colors.redAccent.shade400, - child: Text(value.initials), + List _inputLists = []; + Iterable get inputWidget sync* { + for (InputEntry value in _lists) { + _inputLists.add(value); + yield Padding( + padding: const EdgeInsets.all(4.0), + child: InputChip( + avatar: CircleAvatar( + backgroundColor: Colors.redAccent.shade400, + child: Text(value.initials), + ), + label: Text(value.name), + onDeleted: () { + setState(() { + _lists.remove(value); + }); + }, ), - label: Text(value.name), - onDeleted: (){ - setState(() { - _lists.remove(value); - }); - - }, - - ), - ); + ); + } } -} @override Widget build(BuildContext context) { return Column( children: [ - Wrap( + Wrap( children: inputWidget.toList(), ), - // InputChip( - // label: Text('刷新'), - // onSelected: (bool value){ - - // }, - // ) + // InputChip( + // label: Text('刷新'), + // onSelected: (bool value){ + + // }, + // ) ], - - - ); } } - - - diff --git a/lib/widgets/components/Chip/InputChip/index.dart b/lib/widgets/components/Chip/InputChip/index.dart index f7d0a84b..4919ad95 100644 --- a/lib/widgets/components/Chip/InputChip/index.dart +++ b/lib/widgets/components/Chip/InputChip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 13:32:15 +/// @Date: 2018-12-20 13:32:15 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 10:42:05 @@ -36,7 +36,7 @@ class _DemoState extends State { FilterChipDemo(), ], codeUrl: 'components/Chip/FilterChip/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/InputChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/InputChip-class.html', title: 'InputChip'); } } diff --git a/lib/widgets/components/Chip/RawChip/demo.dart b/lib/widgets/components/Chip/RawChip/demo.dart index f6d37f3b..40437c2b 100644 --- a/lib/widgets/components/Chip/RawChip/demo.dart +++ b/lib/widgets/components/Chip/RawChip/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 20:30:36 +/// @Date: 2018-12-20 20:30:36 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:23:21 @@ -9,56 +9,49 @@ class FilterChipDemo extends StatefulWidget { _FilterChipDemoState createState() => _FilterChipDemoState(); } -class InputEntry{ +class InputEntry { final String name; final String initials; - const InputEntry(this.name,this.initials); + const InputEntry(this.name, this.initials); } - -class _FilterChipDemoState extends State { -final List _lists=[ +class _FilterChipDemoState extends State { + final List _lists = [ const InputEntry('android', 'A'), const InputEntry('java', 'J'), const InputEntry('php', 'P'), const InputEntry('web', 'W'), -]; + ]; -Iterable get _rawChipWidget sync*{ - for(InputEntry value in _lists){ - yield Padding( - padding: const EdgeInsets.all(4.0), - child: RawChip( - avatar: CircleAvatar( - backgroundColor: Colors.redAccent.shade400, - child: Text(value.initials), + Iterable get _rawChipWidget sync* { + for (InputEntry value in _lists) { + yield Padding( + padding: const EdgeInsets.all(4.0), + child: RawChip( + avatar: CircleAvatar( + backgroundColor: Colors.redAccent.shade400, + child: Text(value.initials), + ), + label: Text(value.name), + onDeleted: () { + // _inputs.add(value.name); + setState(() { + _lists.remove(value); + }); + }, ), - label: Text(value.name), - onDeleted: (){ - // _inputs.add(value.name); - setState(() { - _lists.remove(value); - - }); - }, - - ), - ); + ); + } } -} @override Widget build(BuildContext context) { return Column( children: [ - Wrap( + Wrap( children: _rawChipWidget.toList(), ), - ], ); } } - - - diff --git a/lib/widgets/components/Chip/RawChip/index.dart b/lib/widgets/components/Chip/RawChip/index.dart index c57c49ca..d38bea13 100644 --- a/lib/widgets/components/Chip/RawChip/index.dart +++ b/lib/widgets/components/Chip/RawChip/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 20:30:41 +/// @Date: 2018-12-20 20:30:41 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:35:51 @@ -40,7 +40,7 @@ class _DemoState extends State { FilterChipDemo(), ], codeUrl: 'components/Chip/RawChip/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RawChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/RawChip-class.html', title: 'RawChip'); } } diff --git a/lib/widgets/components/Dialog/AboutDialog/demo.dart b/lib/widgets/components/Dialog/AboutDialog/demo.dart index 5f980907..cd53dae2 100644 --- a/lib/widgets/components/Dialog/AboutDialog/demo.dart +++ b/lib/widgets/components/Dialog/AboutDialog/demo.dart @@ -12,26 +12,23 @@ class AboutDialogDemo extends StatefulWidget { } class _Demo extends State { - void showAlertDialog(BuildContext context) { showDialog( context: context, - builder: (_) => AboutDialog( - applicationName: '名称', - applicationIcon: Icon(Icons.ac_unit), - applicationVersion: 'V1.0', - children: [ - Text('我是一个关于的dialog') - ] - )); + builder: (_) => AboutDialog( + applicationName: '名称', + applicationIcon: Icon(Icons.ac_unit), + applicationVersion: 'V1.0', + children: [Text('我是一个关于的dialog')])); } + Widget build(BuildContext context) { - return RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + return RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding - child: Text( + child: Text( 'show aboutDialog', - style: TextStyle( + style: TextStyle( fontSize: 18.0, //textsize color: Colors.white, // textcolor ), @@ -42,6 +39,6 @@ class _Demo extends State { splashColor: Colors.blueGrey, onPressed: () { showAlertDialog(context); - }); + }); } } diff --git a/lib/widgets/components/Dialog/AboutDialog/index.dart b/lib/widgets/components/Dialog/AboutDialog/index.dart index 718b582b..77d0cc82 100644 --- a/lib/widgets/components/Dialog/AboutDialog/index.dart +++ b/lib/widgets/components/Dialog/AboutDialog/index.dart @@ -23,7 +23,6 @@ const String _Text0 = """ """; - class Demo extends StatefulWidget { static const String routeName = '/components/Dialog/AboutDialog'; @@ -37,10 +36,7 @@ class _DemoState extends State { return WidgetDemo( title: 'AboutDialog', codeUrl: 'components/Dialog/AboutDialog/demo.dart', - contentList: [ - _Text0, - AboutDialogDemo() - ], + contentList: [_Text0, AboutDialogDemo()], docUrl: 'https://docs.flutter.io/flutter/material/AboutDialog-class.html', ); } diff --git a/lib/widgets/components/Dialog/AlertDialog/demo.dart b/lib/widgets/components/Dialog/AlertDialog/demo.dart index 616aa135..f765c549 100644 --- a/lib/widgets/components/Dialog/AlertDialog/demo.dart +++ b/lib/widgets/components/Dialog/AlertDialog/demo.dart @@ -7,8 +7,7 @@ import 'package:flutter/material.dart'; -class AlertDialogDemo extends StatelessWidget{ - +class AlertDialogDemo extends StatelessWidget { void showAlertDialog(BuildContext context) { showDialog( context: context, @@ -98,7 +97,6 @@ class AlertDialogDemo extends StatelessWidget{ Text('too long~~~'), Text('too long~~~'), Text('too long~~~'), - ], ), ), @@ -114,13 +112,14 @@ class AlertDialogDemo extends StatelessWidget{ }, ); } + Widget build(BuildContext context) { - return RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + return RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding - child: Text( + child: Text( '点我显示 AlertDialog', - style: TextStyle( + style: TextStyle( fontSize: 18.0, //textsize color: Colors.white, // textcolor ), @@ -131,7 +130,6 @@ class AlertDialogDemo extends StatelessWidget{ splashColor: Colors.blueGrey, onPressed: () { showAlertDialog(context); - }); + }); } } - diff --git a/lib/widgets/components/Dialog/AlertDialog/index.dart b/lib/widgets/components/Dialog/AlertDialog/index.dart index a067842c..f4d00295 100644 --- a/lib/widgets/components/Dialog/AlertDialog/index.dart +++ b/lib/widgets/components/Dialog/AlertDialog/index.dart @@ -22,7 +22,6 @@ const String _Text0 = """ - 当需要给用户提供多个选项的供选择时,请使用SimpleDialog """; - class Demo extends StatefulWidget { static const String routeName = '/components/Dialog/AlertDialog'; @@ -36,10 +35,7 @@ class _DemoState extends State { return WidgetDemo( title: 'AlertDialog', codeUrl: 'components/Dialog/AlertDialog/demo.dart', - contentList: [ - _Text0, - AlertDialogDemo() - ], + contentList: [_Text0, AlertDialogDemo()], docUrl: 'https://docs.flutter.io/flutter/material/AlertDialog-class.html', ); } diff --git a/lib/widgets/components/Dialog/Dialog/demo.dart b/lib/widgets/components/Dialog/Dialog/demo.dart index 31d1385c..328f35d4 100644 --- a/lib/widgets/components/Dialog/Dialog/demo.dart +++ b/lib/widgets/components/Dialog/Dialog/demo.dart @@ -12,39 +12,38 @@ class DialogDemo extends StatefulWidget { } class _Demo extends State { - void showAlertDialog(BuildContext context) { showDialog( context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { return Dialog( - child: Container( - height: 100, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text('我是一个dialog'), - RaisedButton( - child: Text('取消'), - onPressed: () { - Navigator.of(context).pop(); - }, - ) - ], - ), - ) - ); + child: Container( + height: 100, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text('我是一个dialog'), + RaisedButton( + child: Text('取消'), + onPressed: () { + Navigator.of(context).pop(); + }, + ) + ], + ), + )); }, ); } + Widget build(BuildContext context) { - return RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + return RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding - child: Text( + child: Text( '点我显示 Dialog', - style: TextStyle( + style: TextStyle( fontSize: 18.0, //textsize color: Colors.white, // textcolor ), @@ -59,7 +58,6 @@ class _Demo extends State { } } - class DialogMoreDemo extends StatefulWidget { _DialogMoreDemo createState() => _DialogMoreDemo(); } @@ -68,11 +66,10 @@ class _DialogMoreDemo extends State { int value = 0; void showCommonDialog(BuildContext context) { showDialog( - context: context, - barrierDismissible: false, // user must tap button! - builder: (context) { - return StatefulBuilder( - builder: (context, state) { + context: context, + barrierDismissible: false, // user must tap button! + builder: (context) { + return StatefulBuilder(builder: (context, state) { return Dialog( child: Container( height: 150, @@ -86,47 +83,43 @@ class _DialogMoreDemo extends State { value += 1; }); }, - child: Text("我是一个Dialog, 点我更新value: $value"), + child: Text("我是一个Dialog, 点我更新value: $value"), ), RaisedButton( onPressed: () { - Navigator.of(context).pop(); + Navigator.of(context).pop(); }, - child: Text("取消"), + child: Text("取消"), ) ], ), ), - ); - } - ); - } - ); + }); + }); } + Widget build(BuildContext context) { - return Column( + return Column( children: [ - RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), - //padding - child: Text( - '点我显示Dialog', - style: TextStyle( - fontSize: 18.0, //textsize - color: Colors.white, // textcolor - ), - ), - color: Theme.of(context).accentColor, - elevation: 4.0, - //shadow - splashColor: Colors.blueGrey, - onPressed: () { - showCommonDialog(context); - } - ) + RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + //padding + child: Text( + '点我显示Dialog', + style: TextStyle( + fontSize: 18.0, //textsize + color: Colors.white, // textcolor + ), + ), + color: Theme.of(context).accentColor, + elevation: 4.0, + //shadow + splashColor: Colors.blueGrey, + onPressed: () { + showCommonDialog(context); + }) ], ); } } - diff --git a/lib/widgets/components/Dialog/Dialog/index.dart b/lib/widgets/components/Dialog/Dialog/index.dart index 8df84a94..4bd90c0f 100644 --- a/lib/widgets/components/Dialog/Dialog/index.dart +++ b/lib/widgets/components/Dialog/Dialog/index.dart @@ -30,7 +30,6 @@ const String _Text1 = """ 注意事项: 当前弹出的dialog并非是一个单纯的组件, 而是一个新路由界面, 如果我想通过操作dialog中的内容, 直接使用setState触发的是原界面中的状态 """; - class Demo extends StatefulWidget { static const String routeName = '/components/Dialog/Dialog'; @@ -44,12 +43,7 @@ class _DemoState extends State { return WidgetDemo( title: 'Dialog', codeUrl: 'components/Dialog/Dialog/demo.dart', - contentList: [ - _Text0, - DialogDemo(), - _Text1, - DialogMoreDemo() - ], + contentList: [_Text0, DialogDemo(), _Text1, DialogMoreDemo()], docUrl: 'https://docs.flutter.io/flutter/material/Dialog-class.html', ); } diff --git a/lib/widgets/components/Dialog/SimpleDialog/demo.dart b/lib/widgets/components/Dialog/SimpleDialog/demo.dart index 58f41ad1..5bfcd91f 100644 --- a/lib/widgets/components/Dialog/SimpleDialog/demo.dart +++ b/lib/widgets/components/Dialog/SimpleDialog/demo.dart @@ -12,22 +12,21 @@ class SimpleDialogDemo extends StatefulWidget { } class _Demo extends State { - void showAlertDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { - return SimpleDialog( - title: Text('选择'), + return SimpleDialog( + title: Text('选择'), children: [ - SimpleDialogOption( - child: Text('选项 1'), + SimpleDialogOption( + child: Text('选项 1'), onPressed: () { Navigator.of(context).pop(); }, ), - SimpleDialogOption( - child: Text('选项 2'), + SimpleDialogOption( + child: Text('选项 2'), onPressed: () { Navigator.of(context).pop(); }, @@ -37,13 +36,14 @@ class _Demo extends State { }, ); } + Widget build(BuildContext context) { - return RaisedButton( - padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), + return RaisedButton( + padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0), //padding - child: Text( + child: Text( 'show SimpleDialog', - style: TextStyle( + style: TextStyle( fontSize: 18.0, //textsize color: Colors.white, // textcolor ), @@ -54,7 +54,6 @@ class _Demo extends State { splashColor: Colors.blueGrey, onPressed: () { showAlertDialog(context); - }); + }); } - } diff --git a/lib/widgets/components/Dialog/SimpleDialog/index.dart b/lib/widgets/components/Dialog/SimpleDialog/index.dart index 44a94023..9014fd57 100644 --- a/lib/widgets/components/Dialog/SimpleDialog/index.dart +++ b/lib/widgets/components/Dialog/SimpleDialog/index.dart @@ -25,7 +25,6 @@ const String _Text0 = """ """; - class Demo extends StatefulWidget { static const String routeName = '/components/Dialog/SimpleDialog'; @@ -39,11 +38,9 @@ class _DemoState extends State { return WidgetDemo( title: 'SimpleDialog', codeUrl: 'components/Dialog/SimpleDialog/demo.dart', - contentList: [ - _Text0, - SimpleDialogDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/SimpleDialog-class.html', + contentList: [_Text0, SimpleDialogDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/SimpleDialog-class.html', ); } } diff --git a/lib/widgets/components/Grid/GridPaper/demo.dart b/lib/widgets/components/Grid/GridPaper/demo.dart index 129f9324..57e91191 100644 --- a/lib/widgets/components/Grid/GridPaper/demo.dart +++ b/lib/widgets/components/Grid/GridPaper/demo.dart @@ -12,48 +12,86 @@ class GridPaperDemo extends StatefulWidget { } class _Demo extends State { - - Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: GridView.count( + height: 400, + color: Color(0xffc91b3a), + child: GridView.count( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: 1.3, - children: [ - GridTile( - header: GridTileBar( - title: Text('title'), - subtitle: Text('subtitle'), - leading: Icon(Icons.add), - trailing: Text("trailing"), + children: [ + GridTile( + header: GridTileBar( + title: Text('title'), + subtitle: Text('subtitle'), + leading: Icon(Icons.add), + trailing: Text("trailing"), + ), + child: Container(), ), - child: Container(), - - ), - GridPaper( - color: Colors.red, - child: Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ], - ) - ); + GridPaper( + color: Colors.red, + child: Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + )); } } diff --git a/lib/widgets/components/Grid/GridPaper/index.dart b/lib/widgets/components/Grid/GridPaper/index.dart index abc6eabc..8ec33d4d 100644 --- a/lib/widgets/components/Grid/GridPaper/index.dart +++ b/lib/widgets/components/Grid/GridPaper/index.dart @@ -16,8 +16,6 @@ const String _Text0 = """ """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/GridPaper'; diff --git a/lib/widgets/components/Grid/GridTile/demo.dart b/lib/widgets/components/Grid/GridTile/demo.dart index 06e3fcec..4a16c0fc 100644 --- a/lib/widgets/components/Grid/GridTile/demo.dart +++ b/lib/widgets/components/Grid/GridTile/demo.dart @@ -14,40 +14,87 @@ class GridTileDemo extends StatefulWidget { class _Demo extends State { Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: GridView.count( + height: 400, + color: Color(0xffc91b3a), + child: GridView.count( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: 1.3, - children: [ - GridTile( - header: Text("GridTile header", style: TextStyle(color: Colors.white)), - child: Container( - padding: EdgeInsets.fromLTRB(0, 30, 0, 0), - child: Text("GridTile child", style: TextStyle(color: Colors.white)), + children: [ + GridTile( + header: Text("GridTile header", + style: TextStyle(color: Colors.white)), + child: Container( + padding: EdgeInsets.fromLTRB(0, 30, 0, 0), + child: Text("GridTile child", + style: TextStyle(color: Colors.white)), + ), + footer: Text("GridTile footer", + style: TextStyle(color: Colors.white)), ), - footer: Text("GridTile footer", style: TextStyle(color: Colors.white)), - ), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ], - ) - ); + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + )); } } diff --git a/lib/widgets/components/Grid/GridTile/index.dart b/lib/widgets/components/Grid/GridTile/index.dart index 1f4f809f..d605c9f5 100644 --- a/lib/widgets/components/Grid/GridTile/index.dart +++ b/lib/widgets/components/Grid/GridTile/index.dart @@ -22,8 +22,6 @@ const String _Text0 = """ 如下实例中, 第一个是item便是GridTile组件构成. 包含header, body, footer; """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/GridTile'; diff --git a/lib/widgets/components/Grid/GridTileBar/demo.dart b/lib/widgets/components/Grid/GridTileBar/demo.dart index 22628299..a67c30fe 100644 --- a/lib/widgets/components/Grid/GridTileBar/demo.dart +++ b/lib/widgets/components/Grid/GridTileBar/demo.dart @@ -14,42 +14,85 @@ class GridTileDemo extends StatefulWidget { class _Demo extends State { Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: GridView.count( + height: 400, + color: Color(0xffc91b3a), + child: GridView.count( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: 1.3, - children: [ - GridTile( - header: GridTileBar( - title: Text('title'), - subtitle: Text('subtitle'), - leading: Icon(Icons.add), - trailing: Text("trailing"), + children: [ + GridTile( + header: GridTileBar( + title: Text('title'), + subtitle: Text('subtitle'), + leading: Icon(Icons.add), + trailing: Text("trailing"), + ), + child: Container(), ), - child: Container(), - - ), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ], - ) - ); + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + )); } } diff --git a/lib/widgets/components/Grid/GridTileBar/index.dart b/lib/widgets/components/Grid/GridTileBar/index.dart index 3579656b..b6e223f4 100644 --- a/lib/widgets/components/Grid/GridTileBar/index.dart +++ b/lib/widgets/components/Grid/GridTileBar/index.dart @@ -26,8 +26,6 @@ const String _Text0 = """ - trailing GridTileBar右侧的widgett, 通常我们用来做交互操作类的组件 """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/GridTileBar'; diff --git a/lib/widgets/components/Grid/GridView/demo.dart b/lib/widgets/components/Grid/GridView/demo.dart index 6246c433..b39e6746 100644 --- a/lib/widgets/components/Grid/GridView/demo.dart +++ b/lib/widgets/components/Grid/GridView/demo.dart @@ -12,50 +12,91 @@ class GridTileDemo extends StatefulWidget { } class _Demo extends State { - Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: GridView.count( + height: 400, + color: Color(0xffc91b3a), + child: GridView.count( crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: 1.3, - children: [ - GridTile( - header: GridTileBar( - title: Text('title'), - subtitle: Text('subtitle'), - leading: Icon(Icons.add), - trailing: Text("trailing"), + children: [ + GridTile( + header: GridTileBar( + title: Text('title'), + subtitle: Text('subtitle'), + leading: Icon(Icons.add), + trailing: Text("trailing"), + ), + child: Container(), ), - child: Container(), - - ), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ], - ) - ); + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + )); } } - class GridViewDemo extends StatelessWidget { @override Widget build(BuildContext context) { @@ -64,24 +105,46 @@ class GridViewDemo extends StatelessWidget { color: Color(0xffc91b3a), child: GridView( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - ///列数 - crossAxisCount: 3, - ///列间距 - mainAxisSpacing: 10.0, - ///横轴距离 - crossAxisSpacing: 4.0, - ///缩放比例 - childAspectRatio: 1.3,), - padding: const EdgeInsets.only(left: 10,right: 10,top: 10), + ///列数 + crossAxisCount: 3, + + ///列间距 + mainAxisSpacing: 10.0, + + ///横轴距离 + crossAxisSpacing: 4.0, + + ///缩放比例 + childAspectRatio: 1.3, + ), + padding: const EdgeInsets.only(left: 10, right: 10, top: 10), children: [ - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - Image.network('https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', scale: 1, fit: BoxFit.cover), - ],), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + Image.network( + 'https://flutter.io/assets/homepage/news-2-599aefd56e8aa903ded69500ef4102cdd8f988dab8d9e4d570de18bdb702ffd4.png', + scale: 1, + fit: BoxFit.cover), + ], + ), ); } - -} \ No newline at end of file +} diff --git a/lib/widgets/components/Grid/GridView/index.dart b/lib/widgets/components/Grid/GridView/index.dart index d00925e9..9e6e6813 100644 --- a/lib/widgets/components/Grid/GridView/index.dart +++ b/lib/widgets/components/Grid/GridView/index.dart @@ -49,15 +49,13 @@ const String _Text0 = """ - GridView.extent """; -const Text1=""" +const Text1 = """ ### > SliverGridDelegateWithFixedCrossAxisCount gridDelegate: SliverGridDelegateWithFixedCrossAxisCount,实现网格 """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/GridView'; diff --git a/lib/widgets/components/Grid/SliverGrid/demo.dart b/lib/widgets/components/Grid/SliverGrid/demo.dart index f8bfb19a..8701849d 100644 --- a/lib/widgets/components/Grid/SliverGrid/demo.dart +++ b/lib/widgets/components/Grid/SliverGrid/demo.dart @@ -12,23 +12,22 @@ class SliverGridDemo extends StatefulWidget { } class _Demo extends State { - Widget showCustomScrollView() { - return CustomScrollView( + return CustomScrollView( slivers: [ - SliverGrid( - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + SliverGrid( + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200.0, mainAxisSpacing: 10.0, crossAxisSpacing: 10.0, childAspectRatio: 4.0, ), - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { - return Container( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return Container( alignment: Alignment.center, color: Colors.cyan[100 * (index % 5)], - child: Text('grid item $index'), + child: Text('grid item $index'), ); }, childCount: 20, @@ -52,9 +51,6 @@ class _Demo extends State { Widget build(BuildContext context) { return Container( - height: 400, - color: Color(0xffc91b3a), - child: showCustomScrollView() - ); + height: 400, color: Color(0xffc91b3a), child: showCustomScrollView()); } } diff --git a/lib/widgets/components/Grid/SliverGrid/index.dart b/lib/widgets/components/Grid/SliverGrid/index.dart index c3a50dcf..e4c4a80f 100644 --- a/lib/widgets/components/Grid/SliverGrid/index.dart +++ b/lib/widgets/components/Grid/SliverGrid/index.dart @@ -26,8 +26,6 @@ const String _Text0 = """ """; - - class Demo extends StatefulWidget { static const String routeName = '/components/Grid/SliverGrid'; diff --git a/lib/widgets/components/List/AnimatedList/demo.dart b/lib/widgets/components/List/AnimatedList/demo.dart index a4c328f3..d7aab282 100644 --- a/lib/widgets/components/List/AnimatedList/demo.dart +++ b/lib/widgets/components/List/AnimatedList/demo.dart @@ -10,10 +10,9 @@ class AnimatedListFullDefault extends StatefulWidget { _AnimatedListFullDefault createState() => _AnimatedListFullDefault(); } - /// AnimatedList 默认的实例,有状态 class _AnimatedListFullDefault extends State { - final GlobalKey _listKey = GlobalKey(); + final GlobalKey _listKey = GlobalKey(); ListModel _list; int _selectedItem; int _nextItem; // The next item inserted when the user presses the '+' button. @@ -24,7 +23,7 @@ class _AnimatedListFullDefault extends State { if (widget.parent is State) { widget.parent.animatedList = this; // 修改父级的对象引用 } - _list = ListModel( + _list = ListModel( listKey: _listKey, initialItems: [0, 1, 2], removedItemBuilder: _buildRemovedItem, @@ -33,7 +32,8 @@ class _AnimatedListFullDefault extends State { } void insert() { - final int index = _selectedItem == null ? _list.length : _list.indexOf(_selectedItem); + final int index = + _selectedItem == null ? _list.length : _list.indexOf(_selectedItem); _list.insert(index, _nextItem++); } @@ -41,7 +41,7 @@ class _AnimatedListFullDefault extends State { void remove() { if (_selectedItem != null) { _list.removeAt(_list.indexOf(_selectedItem)); - if(mounted) { + if (mounted) { setState(() { _selectedItem = null; }); @@ -49,8 +49,9 @@ class _AnimatedListFullDefault extends State { } } - Widget _buildItem(BuildContext context, int index, Animation animation) { - return CardItem( + Widget _buildItem( + BuildContext context, int index, Animation animation) { + return CardItem( animation: animation, item: _list[index], selected: _selectedItem == _list[index], @@ -62,8 +63,9 @@ class _AnimatedListFullDefault extends State { ); } - Widget _buildRemovedItem(int item, BuildContext context, Animation animation) { - return CardItem( + Widget _buildRemovedItem( + int item, BuildContext context, Animation animation) { + return CardItem( animation: animation, item: item, selected: false, @@ -75,24 +77,25 @@ class _AnimatedListFullDefault extends State { Widget build(BuildContext context) { return SizedBox( height: 500.0, - child:AnimatedList( + child: AnimatedList( //shrinkWrap: true, key: _listKey, initialItemCount: _list.length, itemBuilder: _buildItem, )); } + void methodA() {} } class CardItem extends StatelessWidget { - const CardItem({ - Key key, - @required this.animation, - this.onTap, - @required this.item, - this.selected: false - }) : assert(animation != null), + const CardItem( + {Key key, + @required this.animation, + this.onTap, + @required this.item, + this.selected: false}) + : assert(animation != null), assert(item != null && item >= 0), assert(selected != null), super(key: key); @@ -107,20 +110,20 @@ class CardItem extends StatelessWidget { TextStyle textStyle = Theme.of(context).textTheme.display1; if (selected) textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]); - return Padding( + return Padding( padding: const EdgeInsets.all(2.0), - child: SizeTransition( + child: SizeTransition( axis: Axis.vertical, sizeFactor: animation, - child: GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: onTap, - child: SizedBox( + child: SizedBox( height: 128.0, - child: Card( + child: Card( color: Colors.primaries[item % Colors.primaries.length], - child: Center( - child: Text('Item $item', style: textStyle), + child: Center( + child: Text('Item $item', style: textStyle), ), ), ), @@ -128,4 +131,4 @@ class CardItem extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/List/AnimatedList/index.dart b/lib/widgets/components/List/AnimatedList/index.dart index 23992c1e..10548fda 100644 --- a/lib/widgets/components/List/AnimatedList/index.dart +++ b/lib/widgets/components/List/AnimatedList/index.dart @@ -13,21 +13,17 @@ import './demo.dart'; //var _AnimatedListFullDefault = AnimatedListDemo.AnimatedListFullDefault; GlobalKey globalKey = GlobalKey(); -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > AnimatedList “动画滚动容器” - 一个滚动容器,可在插入或移除项目时为其设置动画 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > AnimatedList - AnimatedListState 可用于动态插入或删除项目。 - 下面示例展示效果:点击+号增加 card, 点击 card 保持激活状态,再点击-号,减少 card。 """; - class Demo extends StatefulWidget { static const String routeName = '/components/List/AnimatedList'; @@ -48,7 +44,6 @@ class _DemoState extends State { } } - /// 所有的 AnimatedList widget /// context: 运行上下文 /// that: 指向有状态的 StatefulWidget @@ -73,33 +68,28 @@ List allDemoBoxs(BuildContext context, _DemoState that) { ]; } - // 演示辅助按钮 Widget assistButtonLeft(that) { return FloatingActionButton( - // 文本内容 - backgroundColor:Colors.red, + // 文本内容 + backgroundColor: Colors.red, child: const Icon(Icons.add_circle_outline), heroTag: null, // 不加这个参数会黑屏... onPressed: () { //demo.insert(); //print('${globalKey.currentState}'); that.animatedList.insert(); - } - ); + }); } - // 演示辅助按钮 Widget assistButtonRight(that) { return FloatingActionButton( - // 文本内容 - backgroundColor:Colors.green, + // 文本内容 + backgroundColor: Colors.green, child: const Icon(Icons.remove_circle_outline), heroTag: null, // 不加这个参数会黑屏... onPressed: () { that.animatedList.remove(); - } - ); + }); } - diff --git a/lib/widgets/components/List/AnimatedList/model.dart b/lib/widgets/components/List/AnimatedList/model.dart index 3b0b3d59..b7ad33c8 100644 --- a/lib/widgets/components/List/AnimatedList/model.dart +++ b/lib/widgets/components/List/AnimatedList/model.dart @@ -12,9 +12,9 @@ class ListModel { @required this.listKey, @required this.removedItemBuilder, Iterable initialItems, - }) : assert(listKey != null), + }) : assert(listKey != null), assert(removedItemBuilder != null), - _items = List.from(initialItems ?? []); + _items = List.from(initialItems ?? []); final GlobalKey listKey; final dynamic removedItemBuilder; @@ -30,7 +30,8 @@ class ListModel { E removeAt(int index) { final E removedItem = _items.removeAt(index); if (removedItem != null) { - _animatedList.removeItem(index, (BuildContext context, Animation animation) { + _animatedList.removeItem(index, + (BuildContext context, Animation animation) { return removedItemBuilder(removedItem, context, animation); }); } @@ -40,4 +41,4 @@ class ListModel { int get length => _items.length; E operator [](int index) => _items[index]; int indexOf(E item) => _items.indexOf(item); -} \ No newline at end of file +} diff --git a/lib/widgets/components/List/ListBody/demo.dart b/lib/widgets/components/List/ListBody/demo.dart index 038c69b2..7313a693 100644 --- a/lib/widgets/components/List/ListBody/demo.dart +++ b/lib/widgets/components/List/ListBody/demo.dart @@ -15,14 +15,13 @@ class ListBodyFullDefault extends StatefulWidget { State createState() => _ListBodyFullDefault(); } - /// ListBody 默认的实例,有状态 class _ListBodyFullDefault extends State { @override Widget build(BuildContext context) { return ListBody( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); + // ... // 如果没有,就是不需要有状态的 StatefulWidget + ); } } @@ -31,36 +30,40 @@ class ListBodyLessDefault extends StatelessWidget { final widget; final parent; - const ListBodyLessDefault([this.widget, this.parent]) - : super(); + const ListBodyLessDefault([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { return ListBody( - mainAxis: Axis.vertical, // 排列的主轴方向 - reverse: false, // 是否反向 - children: [ - Container(color: Colors.red, - width: 50.0, - height: 150.0, - child: Text('标题1', style: TextStyle(color: Color(0xffffffff)))), - Container(color: Colors.yellow, - width: 50.0, - height: 50.0, - child: Text('标题2', style: TextStyle(color: Color(0xffffffff)))), - Container(color: Colors.green, - width: 50.0, - height: 50.0, - child: Text('标题3', style: TextStyle(color: Color(0xffffffff)))), - Container(color: Colors.blue, - width: 50.0, - height: 50.0, - child: Text('标题4', style: TextStyle(color: Color(0xffffffff)))), - Container(color: Colors.black, - width: 50.0, - height: 50.0, - child: Text('标题5', style: TextStyle(color: Color(0xffffffff)))) - ], - ); + mainAxis: Axis.vertical, // 排列的主轴方向 + reverse: false, // 是否反向 + children: [ + Container( + color: Colors.red, + width: 50.0, + height: 150.0, + child: Text('标题1', style: TextStyle(color: Color(0xffffffff)))), + Container( + color: Colors.yellow, + width: 50.0, + height: 50.0, + child: Text('标题2', style: TextStyle(color: Color(0xffffffff)))), + Container( + color: Colors.green, + width: 50.0, + height: 50.0, + child: Text('标题3', style: TextStyle(color: Color(0xffffffff)))), + Container( + color: Colors.blue, + width: 50.0, + height: 50.0, + child: Text('标题4', style: TextStyle(color: Color(0xffffffff)))), + Container( + color: Colors.black, + width: 50.0, + height: 50.0, + child: Text('标题5', style: TextStyle(color: Color(0xffffffff)))) + ], + ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/List/ListBody/index.dart b/lib/widgets/components/List/ListBody/index.dart index 5b5bdb56..2adeffa5 100644 --- a/lib/widgets/components/List/ListBody/index.dart +++ b/lib/widgets/components/List/ListBody/index.dart @@ -11,16 +11,13 @@ import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as ListBodyDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > ListBody “列表组件” - 作用是按给定的轴方向,按照顺序排列子节点。 - 是一个不常直接使用的控件,一般都会配合ListView或者Column等控件使用。 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 布局行为 - 在主轴上,子节点按照顺序进行布局,在交叉轴上,子节点尺寸会被拉伸,以适应交叉轴的区域。 - 在主轴上,给予子节点的空间必须是不受限制的(unlimited),使得子节点可以全部被容纳,ListBody不会去裁剪或者缩放其子节点。 @@ -46,7 +43,6 @@ class _DemoState extends State { } } - /// 所有的 ListBody widget /// context: 运行上下文 /// that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/List/ListView/demo.dart b/lib/widgets/components/List/ListView/demo.dart index 4e31f69f..3373265a 100644 --- a/lib/widgets/components/List/ListView/demo.dart +++ b/lib/widgets/components/List/ListView/demo.dart @@ -15,29 +15,29 @@ class ListViewFullDefault extends StatefulWidget { State createState() => _ListViewFullDefault(); } - /// ListView 默认的实例,有状态 class _ListViewFullDefault extends State { @override Widget build(BuildContext context) { - return ListView( - ); + return ListView(); } } - /// ListView 默认的实例,无状态 class ListViewLessDefault extends StatelessWidget { final widget; final parent; final index; - const ListViewLessDefault([this.index, this.widget, this.parent,]) - : super(); + const ListViewLessDefault([ + this.index, + this.widget, + this.parent, + ]) : super(); @override Widget build(BuildContext context) { - switch(index){ + switch (index) { case 0: return ListView( shrinkWrap: true, @@ -45,18 +45,18 @@ class ListViewLessDefault extends StatelessWidget { children: [ Text('I\'m dedicating every day to you'), ListTile( - leading: Icon(Icons.map), - title: Text('Maps'), + leading: Icon(Icons.map), + title: Text('Maps'), ), Text('Domestic life was never quite my style'), ListTile( - leading: Icon(Icons.photo_album), - title: Text('Album'), + leading: Icon(Icons.photo_album), + title: Text('Album'), ), Text('When you smile, you knock me out, I fall apart'), ListTile( - leading: Icon(Icons.phone), - title: Text('Phone'), + leading: Icon(Icons.phone), + title: Text('Phone'), ), Text('And I thought I was so smart'), ], @@ -65,23 +65,27 @@ class ListViewLessDefault extends StatelessWidget { case 1: return SizedBox( height: 300.0, - child: ListView.builder( + child: ListView.builder( scrollDirection: Axis.vertical, itemCount: 10, // item 的个数 itemExtent: 50.0, // 如果为非null,则强制子项在滚动方向上具有给定范围 itemBuilder: (BuildContext context, int index) { return ListTile( - title: Text("title $index"), // item 标题 - leading: Icon(Icons.keyboard), // item 前置图标 - subtitle: Text("subtitle $index"), // item 副标题 - trailing: Icon(Icons.keyboard_arrow_right),// item 后置图标 - isThreeLine:false, // item 是否三行显示 - dense:true, // item 直观感受是整体大小 - contentPadding: EdgeInsets.all(10.0),// item 内容内边距 - enabled:true, - onTap:(){print('点击:$index');},// item onTap 点击事件 - onLongPress:(){print('长按:$index');},// item onLongPress 长按事件 - selected:false, // item 是否选中状态 + title: Text("title $index"), // item 标题 + leading: Icon(Icons.keyboard), // item 前置图标 + subtitle: Text("subtitle $index"), // item 副标题 + trailing: Icon(Icons.keyboard_arrow_right), // item 后置图标 + isThreeLine: false, // item 是否三行显示 + dense: true, // item 直观感受是整体大小 + contentPadding: EdgeInsets.all(10.0), // item 内容内边距 + enabled: true, + onTap: () { + print('点击:$index'); + }, // item onTap 点击事件 + onLongPress: () { + print('长按:$index'); + }, // item onLongPress 长按事件 + selected: false, // item 是否选中状态 ); }, ), @@ -90,34 +94,40 @@ class ListViewLessDefault extends StatelessWidget { case 2: return SizedBox( height: 300.0, - child: ListView.separated( + child: ListView.separated( scrollDirection: Axis.vertical, itemCount: 100, // item 的个数 - separatorBuilder: (BuildContext context, int index) => Divider(height:1.0,color: Colors.blue), // 添加分割线 + separatorBuilder: (BuildContext context, int index) => + Divider(height: 1.0, color: Colors.blue), // 添加分割线 itemBuilder: (BuildContext context, int index) { return ListTile( - title: Text("title $index"), // item 标题 + title: Text("title $index"), // item 标题 leading: Icon(Icons.keyboard), // item 前置图标 subtitle: Text("subtitle $index"), // item 副标题 - trailing: Icon(Icons.keyboard_arrow_right),// item 后置图标 - isThreeLine:false, // item 是否三行显示 - dense:true, // item 直观感受是整体大小 - contentPadding: EdgeInsets.all(10.0),// item 内容内边距 - enabled:true, - onTap:(){print('点击:$index');},// item onTap 点击事件 - onLongPress:(){print('长按:$index');},// item onLongPress 长按事件 - selected:false, // item 是否选中状态 + trailing: Icon(Icons.keyboard_arrow_right), // item 后置图标 + isThreeLine: false, // item 是否三行显示 + dense: true, // item 直观感受是整体大小 + contentPadding: EdgeInsets.all(10.0), // item 内容内边距 + enabled: true, + onTap: () { + print('点击:$index'); + }, // item onTap 点击事件 + onLongPress: () { + print('长按:$index'); + }, // item onLongPress 长按事件 + selected: false, // item 是否选中状态 ); }, ), ); - break; + break; case 3: return SizedBox( height: 300.0, - child: ListView.custom( + child: ListView.custom( scrollDirection: Axis.vertical, - childrenDelegate:SliverChildBuilderDelegate((BuildContext context, int index) { + childrenDelegate: + SliverChildBuilderDelegate((BuildContext context, int index) { return Container( height: 50.0, alignment: Alignment.center, @@ -133,4 +143,4 @@ class ListViewLessDefault extends StatelessWidget { break; } } -} \ No newline at end of file +} diff --git a/lib/widgets/components/List/ListView/index.dart b/lib/widgets/components/List/ListView/index.dart index a953337d..b5366737 100644 --- a/lib/widgets/components/List/ListView/index.dart +++ b/lib/widgets/components/List/ListView/index.dart @@ -11,16 +11,13 @@ import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as ListViewDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > ListView “滚动列表” - 一个非常常用的控件,涉及到数据列表展示的,一般情况下都会选用该控件。 - 跟GridView相似,基本上是一个slivers里面只包含一个SliverList的CustomScrollView。 """; - -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 布局行为 - ListView在主轴方向可以滚动,在交叉轴方向,则是填满ListView。 @@ -28,28 +25,24 @@ const String _Text1 = - ### 在Flutter中有几种构建ListView的方式,分别是: **默认List,ListView.builder, ListView.separated,ListView.custom**。 """; -const String _Text2 = -""" +const String _Text2 = """ > ListView() - 默认 List 方式,是把数据 Iterable 添加到列表中,之后直接添加到 ListView 即可。 - Tips: 如果需要设置分割线,需要对列表 item 添加处理,ListTile.divideTiles。 - 仅适用于内容较少的情形,因为它是一次性渲染所有的 items ,当 items 的数目较多时,很容易出现卡顿现象的,导致滑动不流畅。 """; -const String _Text3 = -""" +const String _Text3 = """ > ListView.builder() - 设置单个item的属性,懒加载的,假如有 1000 个列表,初始渲染时并不会所有都渲染,而只会特定数量的 item ,这对于性能和用户体验来说,是很好的提升。 """; -const String _Text4 = -""" +const String _Text4 = """ > 官方示例 ListView.separated() - 带分割线的item,separated 相比较于 builder,又多了一个参数 separatorBuilder ,用于控制列表各个元素的间隔如何渲染。 """; -const String _Text5 = -""" +const String _Text5 = """ > 官方示例 ListView.custom() - 必须的参数就是 childrenDelegate , 然后传入一个 实现了 SliverChildDelegate 的组件,如 SliverChildListDelegate 和 SliverChildBuilderDelegate。 """; @@ -94,5 +87,3 @@ List allDomeBox(BuildContext context, _DemoState that) { ListViewDemo.ListViewLessDefault(3), ]; } - - diff --git a/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart b/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart index 6cd604d7..2eb12e4c 100644 --- a/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart +++ b/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart @@ -1,8 +1,8 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 21:01:51 +/// @Author: 一凨 +/// @Date: 2018-12-22 21:01:51 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 15:37:04 - + import 'package:flutter/material.dart'; class CheckedPopupMenuItemDemo extends StatefulWidget { @@ -24,18 +24,17 @@ class _CheckedPopupMenuItemDemoState extends State { _checkedValues = [_checkedValue3]; } - bool isChecked(String value) => _checkedValues.contains(value); - void showCheckedMenuSelections(String value){ - if(_checkedValues.contains(value)){ + void showCheckedMenuSelections(String value) { + if (_checkedValues.contains(value)) { _checkedValues.remove(value); - }else{ + } else { _checkedValues.add(value); } - - Scaffold.of(context).showSnackBar( SnackBar( - content: Text('Checked $_checkedValues'))); + + Scaffold.of(context) + .showSnackBar(SnackBar(content: Text('Checked $_checkedValues'))); } @override @@ -43,33 +42,35 @@ class _CheckedPopupMenuItemDemoState extends State { return Container( color: Theme.of(context).primaryColor, child: ListTile( - title: const Text('CheckedPopupMenuItem Demo',style: TextStyle(color: Colors.white),), + title: const Text( + 'CheckedPopupMenuItem Demo', + style: TextStyle(color: Colors.white), + ), trailing: PopupMenuButton( padding: EdgeInsets.zero, onSelected: showCheckedMenuSelections, - icon: Icon(Icons.menu,color: Colors.white,), - itemBuilder: (BuildContext context)=>>[ + icon: Icon( + Icons.menu, + color: Colors.white, + ), + itemBuilder: (BuildContext context) => >[ CheckedPopupMenuItem( - value: _checkedValue1, - checked: isChecked(_checkedValue1), - child: Text(_checkedValue1) - ), - CheckedPopupMenuItem( - value: _checkedValue2, - enabled: false, - checked: isChecked(_checkedValue2), - child: Text(_checkedValue2) - ), - CheckedPopupMenuItem( - value: _checkedValue3, - checked: isChecked(_checkedValue3), - child: Text(_checkedValue3) - ), - CheckedPopupMenuItem( - value: _checkedValue4, - checked: isChecked(_checkedValue4), - child: Text(_checkedValue4) - ) + value: _checkedValue1, + checked: isChecked(_checkedValue1), + child: Text(_checkedValue1)), + CheckedPopupMenuItem( + value: _checkedValue2, + enabled: false, + checked: isChecked(_checkedValue2), + child: Text(_checkedValue2)), + CheckedPopupMenuItem( + value: _checkedValue3, + checked: isChecked(_checkedValue3), + child: Text(_checkedValue3)), + CheckedPopupMenuItem( + value: _checkedValue4, + checked: isChecked(_checkedValue4), + child: Text(_checkedValue4)) ], ), ), diff --git a/lib/widgets/components/Menu/CheckedPopupMenuItem/index.dart b/lib/widgets/components/Menu/CheckedPopupMenuItem/index.dart index 9d6fb700..ada4e29c 100644 --- a/lib/widgets/components/Menu/CheckedPopupMenuItem/index.dart +++ b/lib/widgets/components/Menu/CheckedPopupMenuItem/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 21:01:45 +/// @Author: 一凨 +/// @Date: 2018-12-22 21:01:45 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 21:26:54 @@ -23,7 +23,7 @@ const String content1 = ''' '''; class Demo extends StatefulWidget { - static const String routeName = '/components/Menu/CheckedPopupMenuItem'; + static const String routeName = '/components/Menu/CheckedPopupMenuItem'; _DemoState createState() => _DemoState(); } @@ -32,7 +32,8 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( codeUrl: 'components/Menu/CheckedPopupMenuItem/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/material/CheckedPopupMenuItem-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/CheckedPopupMenuItem-class.html', title: 'CheckedPopupMenuItem', contentList: [ content0, @@ -41,4 +42,4 @@ class _DemoState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/DropdownMenuItem/demo.dart b/lib/widgets/components/Menu/DropdownMenuItem/demo.dart index effe3dd8..9f591ad0 100644 --- a/lib/widgets/components/Menu/DropdownMenuItem/demo.dart +++ b/lib/widgets/components/Menu/DropdownMenuItem/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 14:05:32 +/// @Author: 一凨 +/// @Date: 2018-12-27 14:05:32 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 14:05:52 @@ -10,12 +10,10 @@ class DropdownMenuItemDemo extends StatefulWidget { } class _DropdownMenuItemDemoState extends State { - String dropdown1Value = 'Three'; String dropdown2Value; String dropdown3Value = 'Four'; - @override Widget build(BuildContext context) { return Padding( @@ -32,7 +30,8 @@ class _DropdownMenuItemDemoState extends State { dropdown1Value = newValue; }); }, - items: ['One', 'Two', 'Three', 'Four'].map>((String value) { + items: ['One', 'Two', 'Three', 'Four'] + .map>((String value) { return DropdownMenuItem( value: value, child: Text(value), @@ -53,7 +52,8 @@ class _DropdownMenuItemDemoState extends State { dropdown2Value = newValue; }); }, - items: ['One', 'Two', 'Three', 'Four'].map>((String value) { + items: ['One', 'Two', 'Three', 'Four'] + .map>((String value) { return DropdownMenuItem( value: value, child: Text(value), @@ -74,20 +74,33 @@ class _DropdownMenuItemDemoState extends State { }); }, items: [ - 'One', 'Two', 'Three', 'Four', 'Can', 'I', 'Have', 'A', 'Little', - 'Bit', 'More', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten' - ] - .map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }) - .toList(), - ), + 'One', + 'Two', + 'Three', + 'Four', + 'Can', + 'I', + 'Have', + 'A', + 'Little', + 'Bit', + 'More', + 'Five', + 'Six', + 'Seven', + 'Eight', + 'Nine', + 'Ten' + ].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), ), ], ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/DropdownMenuItem/index.dart b/lib/widgets/components/Menu/DropdownMenuItem/index.dart index c378f5b6..dbfe6bdb 100644 --- a/lib/widgets/components/Menu/DropdownMenuItem/index.dart +++ b/lib/widgets/components/Menu/DropdownMenuItem/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 11:20:07 +/// @Author: 一凨 +/// @Date: 2018-12-27 11:20:07 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 14:51:44 @@ -38,8 +38,9 @@ class _DemoState extends State { DropdownMenuItemDemo(), ], title: 'DropdownMenuItem', - docUrl: 'https://docs.flutter.io/flutter/material/DropdownMenuItem-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/DropdownMenuItem-class.html', codeUrl: 'components/Menu/DropdownMenuItem/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/PopupMenuButton/demo.dart b/lib/widgets/components/Menu/PopupMenuButton/demo.dart index b290c760..14bd1941 100644 --- a/lib/widgets/components/Menu/PopupMenuButton/demo.dart +++ b/lib/widgets/components/Menu/PopupMenuButton/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 15:17:10 +/// @Author: 一凨 +/// @Date: 2018-12-27 15:17:10 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 15:39:35 @@ -18,20 +18,16 @@ class _PopupMenuButtonDemoState extends State { void showMenuSelection(String value) { if ([_simpleValue1, _simpleValue2, _simpleValue3].contains(value)) _simpleValue = value; - Scaffold.of(context).showSnackBar( SnackBar( - content: Text('You selected: $value'))); + Scaffold.of(context) + .showSnackBar(SnackBar(content: Text('You selected: $value'))); } - - @override void initState() { super.initState(); _simpleValue = _simpleValue2; } - - @override Widget build(BuildContext context) { return Container( @@ -43,15 +39,15 @@ class _PopupMenuButtonDemoState extends State { padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: _simpleValue1, - child: const Text('Context menu item one')), - const PopupMenuItem( - enabled: false, child: Text('A disabled menu item')), - PopupMenuItem( - value: _simpleValue3, - child: const Text('Context menu item three')), - ], + PopupMenuItem( + value: _simpleValue1, + child: const Text('Context menu item one')), + const PopupMenuItem( + enabled: false, child: Text('A disabled menu item')), + PopupMenuItem( + value: _simpleValue3, + child: const Text('Context menu item three')), + ], ), ), ListTile( @@ -60,27 +56,25 @@ class _PopupMenuButtonDemoState extends State { padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ - const PopupMenuItem( - value: 'Preview', - child: ListTile( - leading: Icon(Icons.visibility), - title: Text('Preview'))), - const PopupMenuItem( - value: 'Share', - child: ListTile( - leading: Icon(Icons.person_add), - title: Text('Share'))), - const PopupMenuItem( - value: 'Get Link', - child: ListTile( - leading: Icon(Icons.link), - title: Text('Get link'))), - const PopupMenuDivider(), - const PopupMenuItem( - value: 'Remove', - child: ListTile( - leading: Icon(Icons.delete), title: Text('Remove'))) - ], + const PopupMenuItem( + value: 'Preview', + child: ListTile( + leading: Icon(Icons.visibility), + title: Text('Preview'))), + const PopupMenuItem( + value: 'Share', + child: ListTile( + leading: Icon(Icons.person_add), title: Text('Share'))), + const PopupMenuItem( + value: 'Get Link', + child: ListTile( + leading: Icon(Icons.link), title: Text('Get link'))), + const PopupMenuDivider(), + const PopupMenuItem( + value: 'Remove', + child: ListTile( + leading: Icon(Icons.delete), title: Text('Remove'))) + ], ), ), PopupMenuButton( @@ -91,52 +85,43 @@ class _PopupMenuButtonDemoState extends State { title: const Text('An item with a simple menu'), subtitle: Text(_simpleValue)), itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: _simpleValue1, child: Text(_simpleValue1)), - PopupMenuItem( - value: _simpleValue2, child: Text(_simpleValue2)), - PopupMenuItem( - value: _simpleValue3, child: Text(_simpleValue3)) - ], + PopupMenuItem( + value: _simpleValue1, child: Text(_simpleValue1)), + PopupMenuItem( + value: _simpleValue2, child: Text(_simpleValue2)), + PopupMenuItem( + value: _simpleValue3, child: Text(_simpleValue3)) + ], ), ListTile( - title: const Text('An item with a sectioned menu'), - trailing: PopupMenuButton( - padding: EdgeInsets.zero, - onSelected: showMenuSelection, - itemBuilder: (BuildContext context) => >[ - const PopupMenuItem( - value: 'Preview', - child: ListTile( - leading: Icon(Icons.visibility), - title: Text('Preview') - ) - ), - const PopupMenuItem( - value: 'Share', - child: ListTile( - leading: Icon(Icons.person_add), - title: Text('Share') - ) - ), - const PopupMenuItem( - value: 'Get Link', - child: ListTile( - leading: Icon(Icons.link), - title: Text('Get link') - ) - ), - const PopupMenuDivider(), - const PopupMenuItem( - value: 'Remove', - child: ListTile( - leading: Icon(Icons.delete), - title: Text('Remove') - ) - ) - ] - ) - ), + title: const Text('An item with a sectioned menu'), + trailing: PopupMenuButton( + padding: EdgeInsets.zero, + onSelected: showMenuSelection, + itemBuilder: (BuildContext context) => + >[ + const PopupMenuItem( + value: 'Preview', + child: ListTile( + leading: Icon(Icons.visibility), + title: Text('Preview'))), + const PopupMenuItem( + value: 'Share', + child: ListTile( + leading: Icon(Icons.person_add), + title: Text('Share'))), + const PopupMenuItem( + value: 'Get Link', + child: ListTile( + leading: Icon(Icons.link), + title: Text('Get link'))), + const PopupMenuDivider(), + const PopupMenuItem( + value: 'Remove', + child: ListTile( + leading: Icon(Icons.delete), + title: Text('Remove'))) + ])), ], ), ); diff --git a/lib/widgets/components/Menu/PopupMenuButton/index.dart b/lib/widgets/components/Menu/PopupMenuButton/index.dart index cd81f7d5..80dfac55 100644 --- a/lib/widgets/components/Menu/PopupMenuButton/index.dart +++ b/lib/widgets/components/Menu/PopupMenuButton/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 14:43:50 +/// @Author: 一凨 +/// @Date: 2018-12-27 14:43:50 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 15:44:31 @@ -40,8 +40,9 @@ class _DemoState extends State { PopupMenuButtonDemo(), ], codeUrl: 'components/Menu/PopupMenuButton/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/material/PopupMenuButton-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/PopupMenuButton-class.html', title: 'PopupMenuButton', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/PopupMenuDivider/demo.dart b/lib/widgets/components/Menu/PopupMenuDivider/demo.dart index 3b578b53..32d68ecf 100644 --- a/lib/widgets/components/Menu/PopupMenuDivider/demo.dart +++ b/lib/widgets/components/Menu/PopupMenuDivider/demo.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 15:45:26 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-27 15:45:26 +/// @Author: 一凨 +/// @Date: 2018-12-27 15:45:26 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-27 15:45:26 import 'package:flutter/material.dart'; @@ -12,7 +12,7 @@ class PopupMenuDividerDemo extends StatefulWidget { class _PopupMenuDividerDemoState extends State { void showInSnackBar(String value) { Scaffold.of(context) - .showSnackBar( SnackBar(content: Text('You selected: $value'))); + .showSnackBar(SnackBar(content: Text('You selected: $value'))); } @override diff --git a/lib/widgets/components/Menu/PopupMenuDivider/index.dart b/lib/widgets/components/Menu/PopupMenuDivider/index.dart index f6c2fd68..7d0ee26b 100644 --- a/lib/widgets/components/Menu/PopupMenuDivider/index.dart +++ b/lib/widgets/components/Menu/PopupMenuDivider/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 14:51:58 +/// @Author: 一凨 +/// @Date: 2018-12-27 14:51:58 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 15:55:22 diff --git a/lib/widgets/components/Menu/PopupMenuEntry/index.dart b/lib/widgets/components/Menu/PopupMenuEntry/index.dart index 54b15669..2dca2cbe 100644 --- a/lib/widgets/components/Menu/PopupMenuEntry/index.dart +++ b/lib/widgets/components/Menu/PopupMenuEntry/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 14:51:58 +/// @Author: 一凨 +/// @Date: 2018-12-27 14:51:58 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 16:06:20 @@ -28,14 +28,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - PopupMenuDividerDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/PopupMenuEntry-class.html', + contentList: [content0, content1, PopupMenuDividerDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/PopupMenuEntry-class.html', codeUrl: 'components/Menu/PopupMenuDivider/demo.dart', title: 'PopupMenuEntry', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/PopupMenuItem/index.dart b/lib/widgets/components/Menu/PopupMenuItem/index.dart index dbb05dc9..87cb58d4 100644 --- a/lib/widgets/components/Menu/PopupMenuItem/index.dart +++ b/lib/widgets/components/Menu/PopupMenuItem/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-29 15:04:51 +/// @Date: 2018-12-29 15:04:51 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-29 15:07:16 @@ -28,14 +28,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - PopupMenuDividerDemo() - ], - docUrl: "https://docs.flutter.io/flutter/material/PopupMenuItem-class.html", + contentList: [content0, content1, PopupMenuDividerDemo()], + docUrl: + "https://docs.flutter.io/flutter/material/PopupMenuItem-class.html", codeUrl: 'components/Menu/PopupMenuDivider/demo.dart', title: 'PopupMenuItem', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/PopupMenuItemState/index.dart b/lib/widgets/components/Menu/PopupMenuItemState/index.dart index 327724b4..214b33b9 100644 --- a/lib/widgets/components/Menu/PopupMenuItemState/index.dart +++ b/lib/widgets/components/Menu/PopupMenuItemState/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-29 15:04:51 +/// @Date: 2018-12-29 15:04:51 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-29 16:22:06 @@ -29,14 +29,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - PopupMenuDividerDemo() - ], - docUrl: "https://docs.flutter.io/flutter/material/PopupMenuItem-class.html", + contentList: [content0, content1, PopupMenuDividerDemo()], + docUrl: + "https://docs.flutter.io/flutter/material/PopupMenuItem-class.html", codeUrl: 'components/Menu/PopupMenuEntry/demo.dart', title: 'PopupMenuItem', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Menu/index.dart b/lib/widgets/components/Menu/index.dart index ce1de856..c6e70232 100644 --- a/lib/widgets/components/Menu/index.dart +++ b/lib/widgets/components/Menu/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 21:01:42 +/// @Author: 一凨 +/// @Date: 2018-12-22 21:01:42 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 14:53:04 @@ -14,41 +14,40 @@ import './PopupMenuEntry/index.dart' as PopupMenuEntry; import './PopupMenuItemState/index.dart' as PopupMenuItemState; import './PopupMenuItem/index.dart' as PopupMenuItem; - List widgetPoints = [ WidgetPoint( - name:'CheckedPopupMenuItem', + name: 'CheckedPopupMenuItem', routerName: CheckedPopupMenuItem.Demo.routeName, buildRouter: (BuildContext context) => CheckedPopupMenuItem.Demo(), ), WidgetPoint( - name:'DropdownMenuItem', + name: 'DropdownMenuItem', routerName: DropdownMenuItem.Demo.routeName, buildRouter: (BuildContext context) => DropdownMenuItem.Demo(), ), WidgetPoint( - name:'PopupMenuButton', + name: 'PopupMenuButton', routerName: PopupMenuButton.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuButton.Demo(), ), WidgetPoint( - name:'PopupMenuDivider', + name: 'PopupMenuDivider', routerName: PopupMenuDivider.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuDivider.Demo(), ), WidgetPoint( - name:'PopupMenuEntry', + name: 'PopupMenuEntry', routerName: PopupMenuEntry.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuEntry.Demo(), ), WidgetPoint( - name:'PopupMenuItemState', + name: 'PopupMenuItemState', routerName: PopupMenuItemState.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuItemState.Demo(), ), WidgetPoint( - name:'PopupMenuItem', + name: 'PopupMenuItem', routerName: PopupMenuItem.Demo.routeName, buildRouter: (BuildContext context) => PopupMenuItem.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart b/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart index 62af199c..63dabced 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart @@ -7,7 +7,6 @@ import 'package:flutter/material.dart'; - // BottomNavigationBar 默认的实例 class BottomNavigationBarFullDefault extends StatefulWidget { const BottomNavigationBarFullDefault() : super(); @@ -15,13 +14,12 @@ class BottomNavigationBarFullDefault extends StatefulWidget { State createState() => _BottomNavigationBarFullDefault(); } - // BottomNavigationBar 默认的实例,有状态 class _BottomNavigationBarFullDefault extends State { - int _currentIndex = 1; + int _currentIndex = 1; void _onItemTapped(int index) { - if(mounted) { + if (mounted) { setState(() { _currentIndex = index; }); @@ -31,29 +29,25 @@ class _BottomNavigationBarFullDefault extends State { @override Widget build(BuildContext context) { return BottomNavigationBar( - type: BottomNavigationBarType.fixed, // BottomNavigationBarType 中定义的类型,有 fixed 和 shifting 两种类型 + type: BottomNavigationBarType + .fixed, // BottomNavigationBarType 中定义的类型,有 fixed 和 shifting 两种类型 iconSize: 24.0, // BottomNavigationBarItem 中 icon 的大小 currentIndex: _currentIndex, // 当前所高亮的按钮index onTap: _onItemTapped, // 点击里面的按钮的回调函数,参数为当前点击的按钮 index - fixedColor: Colors.deepPurple, // 如果 type 类型为 fixed,则通过 fixedColor 设置选中 item 的颜色 + fixedColor: + Colors.deepPurple, // 如果 type 类型为 fixed,则通过 fixedColor 设置选中 item 的颜色 selectedFontSize: 12.0, unselectedFontSize: 12.0, - items: [ + items: [ + BottomNavigationBarItem(title: Text("Home"), icon: Icon(Icons.home)), + BottomNavigationBarItem(title: Text("List"), icon: Icon(Icons.list)), BottomNavigationBarItem( - title: Text("Home"), icon: Icon(Icons.home)), + title: Text("Message"), icon: Icon(Icons.message)), + BottomNavigationBarItem(title: Text("add"), icon: Icon(Icons.add)), + BottomNavigationBarItem(title: Text("menu"), icon: Icon(Icons.menu)), BottomNavigationBarItem( - title: Text("List"), icon: Icon(Icons.list)), - BottomNavigationBarItem( - title: Text("Message"), icon: Icon(Icons.message)), - BottomNavigationBarItem( - title: Text("add"), icon: Icon(Icons.add)), - BottomNavigationBarItem( - title: Text("menu"), icon: Icon(Icons.menu)), - BottomNavigationBarItem( - title: Text("other"), icon: Icon(Icons.devices_other)), - + title: Text("other"), icon: Icon(Icons.devices_other)), ], ); } } - diff --git a/lib/widgets/components/Navigation/BottomNavigationBar/index.dart b/lib/widgets/components/Navigation/BottomNavigationBar/index.dart index ae1e72e5..c21fe875 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBar/index.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBar/index.dart @@ -7,20 +7,17 @@ import 'package:flutter/material.dart'; -import 'package:flutter_go/components/widget_demo.dart'; +import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as BottomNavigationBarDemo; -const String _text0 = -"""### **简介** +const String _text0 = """### **简介** > BottomNavigationBar “底部导航栏” - 显示在应用程序底部的导航栏,由文本标签,图标或两者形式的多个项目组成; - 它提供了应用程序顶级视图之间的快速导航; """; - -const String _text1 = -"""### **基本用法** +const String _text1 = """### **基本用法** > BottomNavigationBar 底部导航栏通常与Scaffold结合使用 - 它作为 Scaffold.bottomNavigationBar 参数; - BottomNavigationBar 3-5个之间个底部按钮数量是合理的,理论上 icon 大小合适,可以支持更多; @@ -40,16 +37,16 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - title: 'BottomNavigationBar', - codeUrl: 'components/Navigation/BottomNavigationBar/demo.dart', - contentList: allDemoBoxs(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/BottomNavigationBar-class.html', - bottomNaviBar:BottomNavigationBarDemo.BottomNavigationBarFullDefault() - ); + title: 'BottomNavigationBar', + codeUrl: 'components/Navigation/BottomNavigationBar/demo.dart', + contentList: allDemoBoxs(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/BottomNavigationBar-class.html', + bottomNaviBar: + BottomNavigationBarDemo.BottomNavigationBarFullDefault()); } } - // 所有的 BottomNavigationBar widget // context: 运行上下文 // that: 指向有状态的 StatefulWidget @@ -67,5 +64,3 @@ List allDemoBoxs(BuildContext context, _DemoState that) { SizedBox(width: 20.0), // 间距 ]; } - - diff --git a/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart b/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart index 1cebb426..ebee54c8 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart @@ -17,25 +17,27 @@ class BottomNavigationBarItemLessDefault extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( + return SizedBox( height: 100, child: Scaffold( - bottomNavigationBar: BottomNavigationBar(items: [ - BottomNavigationBarItem( - icon: Icon(Icons.laptop_chromebook), - title: Text("主页"), - backgroundColor: Colors.red - ), - BottomNavigationBarItem( - icon: Icon(Icons.list), title: Text("分类"),backgroundColor: Colors.grey), - BottomNavigationBarItem( - icon: Icon(Icons.local_grocery_store), title: Text("购物车")), - BottomNavigationBarItem(icon: Icon(Icons.person), title: Text("我的")) - ], + bottomNavigationBar: BottomNavigationBar( + items: [ + BottomNavigationBarItem( + icon: Icon(Icons.laptop_chromebook), + title: Text("主页"), + backgroundColor: Colors.red), + BottomNavigationBarItem( + icon: Icon(Icons.list), + title: Text("分类"), + backgroundColor: Colors.grey), + BottomNavigationBarItem( + icon: Icon(Icons.local_grocery_store), title: Text("购物车")), + BottomNavigationBarItem( + icon: Icon(Icons.person), title: Text("我的")) + ], //onTap: onTap, //currentIndex: page ), - ) - ); + )); } } diff --git a/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart b/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart index 3ff65af9..5ebc9587 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart @@ -11,19 +11,18 @@ import 'package:flutter/material.dart'; import './demo.dart' as BottomNavigationBarItemDemo; -const String _Text0 = -"""### **简介** +const String _Text0 = """### **简介** > BottomNavigationBarItem “底部导航应用栏” - material 的 BottomNavigationBar 或带有图标和标题的 iOS主题 CupertinoTabBar 中的交互式按钮; """; -const String _Text1 = -"""### **基本用法** +const String _Text1 = """### **基本用法** > 这个类很少单独使用。通常嵌入在上面的一个底部 bottom navigation widgets 中; """; class Demo extends StatefulWidget { - static const String routeName = '/components/Navigation/BottomNavigationBarItem'; + static const String routeName = + '/components/Navigation/BottomNavigationBarItem'; @override _DemoState createState() => _DemoState(); @@ -36,12 +35,12 @@ class _DemoState extends State { title: 'BottomNavigationBarItem', codeUrl: 'components/Navigation/BottomNavigationBarItem/demo.dart', contentList: allDomeBox(context, this), - docUrl: 'https://docs.flutter.io/flutter/widgets/BottomNavigationBarItem-class.html', + docUrl: + 'https://docs.flutter.io/flutter/widgets/BottomNavigationBarItem-class.html', ); } } - // 所有的 BottomNavigationBarItem widget // context: 运行上下文 // that: 指向有状态的 StatefulWidget @@ -55,6 +54,3 @@ List allDomeBox(BuildContext context, _DemoState that) { SizedBox(height: 20.0), // 间距 ]; } - - - diff --git a/lib/widgets/components/Panel/ExpansionPanel/demo.dart b/lib/widgets/components/Panel/ExpansionPanel/demo.dart index 716abd43..65a73fd4 100644 --- a/lib/widgets/components/Panel/ExpansionPanel/demo.dart +++ b/lib/widgets/components/Panel/ExpansionPanel/demo.dart @@ -4,24 +4,14 @@ import 'package:flutter/material.dart'; - @visibleForTesting -enum Location { - Barbados, - Bahamas, - Bermuda -} +enum Location { Barbados, Bahamas, Bermuda } typedef DemoItemBodyBuilder = Widget Function(DemoItem item); typedef ValueToString = String Function(T value); class DualHeaderWithHint extends StatelessWidget { - const DualHeaderWithHint({ - this.name, - this.value, - this.hint, - this.showHint - }); + const DualHeaderWithHint({this.name, this.value, this.hint, this.showHint}); final String name; final String value; @@ -35,7 +25,8 @@ class DualHeaderWithHint extends StatelessWidget { firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, - crossFadeState: isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, + crossFadeState: + isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, duration: const Duration(milliseconds: 200), ); } @@ -45,45 +36,37 @@ class DualHeaderWithHint extends StatelessWidget { final ThemeData theme = Theme.of(context); final TextTheme textTheme = theme.textTheme; - return Row( - children: [ - Expanded( - flex: 2, - child: Container( - margin: const EdgeInsets.only(left: 24.0), - child: FittedBox( - fit: BoxFit.scaleDown, - alignment: Alignment.centerLeft, - child: Text( - name, - style: textTheme.body1.copyWith(fontSize: 15.0), - ), + return Row(children: [ + Expanded( + flex: 2, + child: Container( + margin: const EdgeInsets.only(left: 24.0), + child: FittedBox( + fit: BoxFit.scaleDown, + alignment: Alignment.centerLeft, + child: Text( + name, + style: textTheme.body1.copyWith(fontSize: 15.0), ), ), ), - Expanded( + ), + Expanded( flex: 3, child: Container( - margin: const EdgeInsets.only(left: 24.0), - child: _crossFade( - Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)), - Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), - showHint - ) - ) - ) - ] - ); + margin: const EdgeInsets.only(left: 24.0), + child: _crossFade( + Text(value, + style: textTheme.caption.copyWith(fontSize: 15.0)), + Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), + showHint))) + ]); } } class CollapsibleBody extends StatelessWidget { - const CollapsibleBody({ - this.margin = EdgeInsets.zero, - this.child, - this.onSave, - this.onCancel - }); + const CollapsibleBody( + {this.margin = EdgeInsets.zero, this.child, this.onSave, this.onCancel}); final EdgeInsets margin; final Widget child; @@ -95,62 +78,42 @@ class CollapsibleBody extends StatelessWidget { final ThemeData theme = Theme.of(context); final TextTheme textTheme = theme.textTheme; - return Column( - children: [ - Container( - margin: const EdgeInsets.only( - left: 24.0, - right: 24.0, - bottom: 24.0 - ) - margin, + return Column(children: [ + Container( + margin: const EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0) - + margin, child: Center( - child: DefaultTextStyle( - style: textTheme.caption.copyWith(fontSize: 15.0), - child: child - ) - ) - ), - const Divider(height: 1.0), - Container( + child: DefaultTextStyle( + style: textTheme.caption.copyWith(fontSize: 15.0), + child: child))), + const Divider(height: 1.0), + Container( padding: const EdgeInsets.symmetric(vertical: 16.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( + child: + Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + Container( margin: const EdgeInsets.only(right: 8.0), child: FlatButton( - onPressed: onCancel, - child: const Text('CANCEL', style: TextStyle( - color: Colors.black54, - fontSize: 15.0, - fontWeight: FontWeight.w500 - )) - ) - ), - Container( + onPressed: onCancel, + child: const Text('CANCEL', + style: TextStyle( + color: Colors.black54, + fontSize: 15.0, + fontWeight: FontWeight.w500)))), + Container( margin: const EdgeInsets.only(right: 8.0), child: FlatButton( - onPressed: onSave, - textTheme: ButtonTextTheme.accent, - child: const Text('SAVE') - ) - ) - ] - ) - ) - ] - ); + onPressed: onSave, + textTheme: ButtonTextTheme.accent, + child: const Text('SAVE'))) + ])) + ]); } } class DemoItem { - DemoItem({ - this.name, - this.value, - this.hint, - this.builder, - this.valueToString - }) : textController = TextEditingController(text: valueToString(value)); + DemoItem({this.name, this.value, this.hint, this.builder, this.valueToString}) + : textController = TextEditingController(text: valueToString(value)); final String name; final String hint; @@ -163,11 +126,10 @@ class DemoItem { ExpansionPanelHeaderBuilder get headerBuilder { return (BuildContext context, bool isExpanded) { return DualHeaderWithHint( - name: name, - value: valueToString(value), - hint: hint, - showHint: isExpanded - ); + name: name, + value: valueToString(value), + hint: hint, + showHint: isExpanded); }; } @@ -189,87 +151,88 @@ class _ExpansionPanelsDemoState extends State { super.initState(); _demoItems = >[ - DemoItem( - name: 'Location', - value: Location.Bahamas, - hint: 'Select location', - valueToString: (Location location) => location.toString().split('.')[1], - builder: (DemoItem item) { - void close() { - setState(() { - item.isExpanded = false; - }); - } - return Form( - child: Builder( - builder: (BuildContext context) { - return CollapsibleBody( - onSave: () { Form.of(context).save(); close(); }, - onCancel: () { Form.of(context).reset(); close(); }, - child: FormField( + name: 'Location', + value: Location.Bahamas, + hint: 'Select location', + valueToString: (Location location) => + location.toString().split('.')[1], + builder: (DemoItem item) { + void close() { + setState(() { + item.isExpanded = false; + }); + } + + return Form(child: Builder(builder: (BuildContext context) { + return CollapsibleBody( + onSave: () { + Form.of(context).save(); + close(); + }, + onCancel: () { + Form.of(context).reset(); + close(); + }, + child: FormField( initialValue: item.value, - onSaved: (Location result) { item.value = result; }, + onSaved: (Location result) { + item.value = result; + }, builder: (FormFieldState field) { return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - RadioListTile( - value: Location.Bahamas, - title: const Text('Bahamas'), - groupValue: field.value, - onChanged: field.didChange, - ), - RadioListTile( - value: Location.Barbados, - title: const Text('Barbados'), - groupValue: field.value, - onChanged: field.didChange, - ), - RadioListTile( - value: Location.Bermuda, - title: const Text('Bermuda'), - groupValue: field.value, - onChanged: field.didChange, - ), - ] - ); - } - ), - ); - } - ) - ); - } - ), + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RadioListTile( + value: Location.Bahamas, + title: const Text('Bahamas'), + groupValue: field.value, + onChanged: field.didChange, + ), + RadioListTile( + value: Location.Barbados, + title: const Text('Barbados'), + groupValue: field.value, + onChanged: field.didChange, + ), + RadioListTile( + value: Location.Bermuda, + title: const Text('Bermuda'), + groupValue: field.value, + onChanged: field.didChange, + ), + ]); + }), + ); + })); + }), ]; } @override Widget build(BuildContext context) { - return SingleChildScrollView( - child: SafeArea( - top: false, - bottom: false, - child: Container( - margin: const EdgeInsets.all(24.0), - child: ExpansionPanelList( + return SingleChildScrollView( + child: SafeArea( + top: false, + bottom: false, + child: Container( + margin: const EdgeInsets.all(24.0), + child: ExpansionPanelList( expansionCallback: (int index, bool isExpanded) { setState(() { _demoItems[index].isExpanded = !isExpanded; }); }, - children: _demoItems.map((DemoItem item) { + children: + _demoItems.map((DemoItem item) { return ExpansionPanel( - isExpanded: true, - headerBuilder: item.headerBuilder, - body: item.build() - ); - }).toList() - ), - ), + isExpanded: true, + headerBuilder: item.headerBuilder, + body: item.build()); + }).toList()), ), - ); + ), + ); } } diff --git a/lib/widgets/components/Panel/ExpansionPanel/index.dart b/lib/widgets/components/Panel/ExpansionPanel/index.dart index b39aa257..4ef19fd1 100644 --- a/lib/widgets/components/Panel/ExpansionPanel/index.dart +++ b/lib/widgets/components/Panel/ExpansionPanel/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-21 11:35:39 +/// @Date: 2018-12-21 11:35:39 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:36:23 @@ -34,7 +34,7 @@ class _DemoState extends State { ExpansionPanelsDemo(), ], codeUrl: 'widgets/components/Panel/ExpansionPanel/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RawChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/RawChip-class.html', title: 'ExpansionPanel'); } } diff --git a/lib/widgets/components/Panel/ExpansionPanelList/demo.dart b/lib/widgets/components/Panel/ExpansionPanelList/demo.dart index 8d8259e5..48acd398 100644 --- a/lib/widgets/components/Panel/ExpansionPanelList/demo.dart +++ b/lib/widgets/components/Panel/ExpansionPanelList/demo.dart @@ -5,11 +5,7 @@ import 'package:flutter/material.dart'; @visibleForTesting -enum Location { - Barbados, - Bahamas, - Bermuda -} +enum Location { Barbados, Bahamas, Bermuda } typedef DemoItemBodyBuilder = Widget Function(DemoItem item); typedef ValueToString = String Function(T value); @@ -18,12 +14,7 @@ typedef ValueToString = String Function(T value); // https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart class DualHeaderWithHint extends StatelessWidget { - const DualHeaderWithHint({ - this.name, - this.value, - this.hint, - this.showHint - }); + const DualHeaderWithHint({this.name, this.value, this.hint, this.showHint}); final String name; final String value; @@ -37,7 +28,8 @@ class DualHeaderWithHint extends StatelessWidget { firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, - crossFadeState: isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, + crossFadeState: + isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, duration: const Duration(milliseconds: 200), ); } @@ -47,47 +39,37 @@ class DualHeaderWithHint extends StatelessWidget { final ThemeData theme = Theme.of(context); final TextTheme textTheme = theme.textTheme; - return Row( - children: [ - Expanded( - flex: 2, - child: Container( - margin: const EdgeInsets.only(left: 24.0), - child: FittedBox( - fit: BoxFit.scaleDown, - alignment: Alignment.centerLeft, - child: Text( - name, - style: textTheme.body1.copyWith(fontSize: 15.0), - ), + return Row(children: [ + Expanded( + flex: 2, + child: Container( + margin: const EdgeInsets.only(left: 24.0), + child: FittedBox( + fit: BoxFit.scaleDown, + alignment: Alignment.centerLeft, + child: Text( + name, + style: textTheme.body1.copyWith(fontSize: 15.0), ), ), ), - Expanded( + ), + Expanded( flex: 3, child: Container( - margin: const EdgeInsets.only(left: 24.0), - child: _crossFade( - Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)), - Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), - showHint - ) - ) - ) - ] - ); + margin: const EdgeInsets.only(left: 24.0), + child: _crossFade( + Text(value, + style: textTheme.caption.copyWith(fontSize: 15.0)), + Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), + showHint))) + ]); } } - class DemoItem { - DemoItem({ - this.name, - this.value, - this.hint, - this.builder, - this.valueToString - }) : textController = TextEditingController(text: valueToString(value)); + DemoItem({this.name, this.value, this.hint, this.builder, this.valueToString}) + : textController = TextEditingController(text: valueToString(value)); final String name; final String hint; @@ -100,11 +82,10 @@ class DemoItem { ExpansionPanelHeaderBuilder get headerBuilder { return (BuildContext context, bool isExpanded) { return DualHeaderWithHint( - name: name, - value: valueToString(value), - hint: hint, - showHint: isExpanded - ); + name: name, + value: valueToString(value), + hint: hint, + showHint: isExpanded); }; } @@ -126,21 +107,21 @@ class _ExpansionPanelsDemoState extends State { super.initState(); _demoItems = >[ - DemoItem( - name: 'Location', - value: Location.Bahamas, - hint: 'Select location', - valueToString: (Location location) => location.toString().split('.')[1], - builder: (DemoItem item) { - return Form( - child: Builder( - builder: (BuildContext context) { - return FormField( - initialValue: item.value, - onSaved: (Location result) { item.value = result; }, - builder: (FormFieldState field) { - return Column( + name: 'Location', + value: Location.Bahamas, + hint: 'Select location', + valueToString: (Location location) => + location.toString().split('.')[1], + builder: (DemoItem item) { + return Form(child: Builder(builder: (BuildContext context) { + return FormField( + initialValue: item.value, + onSaved: (Location result) { + item.value = result; + }, + builder: (FormFieldState field) { + return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -162,42 +143,36 @@ class _ExpansionPanelsDemoState extends State { groupValue: field.value, onChanged: field.didChange, ), - ] - ); - } - ); - } - ) - ); - } - ), + ]); + }); + })); + }), ]; } @override Widget build(BuildContext context) { - return SingleChildScrollView( - child: SafeArea( - top: false, - bottom: false, - child: Container( - margin: const EdgeInsets.all(24.0), - child: ExpansionPanelList( + return SingleChildScrollView( + child: SafeArea( + top: false, + bottom: false, + child: Container( + margin: const EdgeInsets.all(24.0), + child: ExpansionPanelList( expansionCallback: (int index, bool isExpanded) { setState(() { _demoItems[index].isExpanded = !isExpanded; }); }, - children: _demoItems.map((DemoItem item) { + children: + _demoItems.map((DemoItem item) { return ExpansionPanel( - isExpanded: true, - headerBuilder: item.headerBuilder, - body: item.build() - ); - }).toList() - ), - ), + isExpanded: true, + headerBuilder: item.headerBuilder, + body: item.build()); + }).toList()), ), - ); + ), + ); } } diff --git a/lib/widgets/components/Panel/ExpansionPanelList/index.dart b/lib/widgets/components/Panel/ExpansionPanelList/index.dart index f9c3657c..6b3bb3c3 100644 --- a/lib/widgets/components/Panel/ExpansionPanelList/index.dart +++ b/lib/widgets/components/Panel/ExpansionPanelList/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 20:30:41 +/// @Date: 2018-12-20 20:30:41 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2019-01-08 16:15:20 @@ -39,7 +39,7 @@ class _DemoState extends State { ExpansionPanelsDemo(), ], codeUrl: 'components/Panel/ExpansionPanelList/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RawChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/RawChip-class.html', title: 'RawChip'); } } diff --git a/lib/widgets/components/Panel/ExpansionPanelRadio/index.dart b/lib/widgets/components/Panel/ExpansionPanelRadio/index.dart index df757027..f858c679 100644 --- a/lib/widgets/components/Panel/ExpansionPanelRadio/index.dart +++ b/lib/widgets/components/Panel/ExpansionPanelRadio/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-20 20:30:41 +/// @Date: 2018-12-20 20:30:41 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:35:48 @@ -39,7 +39,7 @@ class _DemoState extends State { // FilterChipDemo(), ], codeUrl: 'components/Chip/RawChip/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RawChip-class.html', + docUrl: 'https://docs.flutter.io/flutter/material/RawChip-class.html', title: 'RawChip'); } } diff --git a/lib/widgets/components/Panel/index.dart b/lib/widgets/components/Panel/index.dart index dc8f3fae..aa1783a6 100644 --- a/lib/widgets/components/Panel/index.dart +++ b/lib/widgets/components/Panel/index.dart @@ -21,5 +21,4 @@ List widgetPoints = [ routerName: ExpansionPanelList.Demo.routeName, buildRouter: (BuildContext context) => ExpansionPanelList.Demo(), ), - ]; diff --git a/lib/widgets/components/Pick/CityPIcker/demo.dart b/lib/widgets/components/Pick/CityPIcker/demo.dart index 4e39b2d2..1ff95d91 100644 --- a/lib/widgets/components/Pick/CityPIcker/demo.dart +++ b/lib/widgets/components/Pick/CityPIcker/demo.dart @@ -15,7 +15,7 @@ class CityPickerDemo extends StatefulWidget { class _Demo extends State { String _result; show(context) async { - Result temp = await CityPickers.showCityPicker( + Result temp = await CityPickers.showCityPicker( context: context, // locationCode: '640221', height: 400, @@ -28,15 +28,15 @@ class _Demo extends State { Widget build(BuildContext context) { return Center( child: Column( - children: [ - Text("result: ${_result.toString()}"), - RaisedButton( - onPressed: () {this.show(context); - }, - child: Text("select"), - ), - ], - ) - ); + children: [ + Text("result: ${_result.toString()}"), + RaisedButton( + onPressed: () { + this.show(context); + }, + child: Text("select"), + ), + ], + )); } } diff --git a/lib/widgets/components/Pick/CityPIcker/index.dart b/lib/widgets/components/Pick/CityPIcker/index.dart index 066b3aae..01a625e0 100644 --- a/lib/widgets/components/Pick/CityPIcker/index.dart +++ b/lib/widgets/components/Pick/CityPIcker/index.dart @@ -21,23 +21,19 @@ const String content1 = ''' - height 弹出层高度 - context 上下文对象 '''; + class Demo extends StatefulWidget { static const String routeName = '/components/Pick/CityPicker'; _Demo createState() => _Demo(); } class _Demo extends State { - Widget build(BuildContext context) { return WidgetDemo( title: 'CityPicker', codeUrl: '', docUrl: '', - contentList: [ - content0, - content1, - CityPickerDemo() - ], + contentList: [content0, content1, CityPickerDemo()], ); } } diff --git a/lib/widgets/components/Pick/DayPicker/demo.dart b/lib/widgets/components/Pick/DayPicker/demo.dart index 2ba81f04..447bd0a7 100644 --- a/lib/widgets/components/Pick/DayPicker/demo.dart +++ b/lib/widgets/components/Pick/DayPicker/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:32 +/// @Date: 2018-12-17 15:37:32 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 19:12:32 @@ -13,8 +13,8 @@ class DayPickerDemo extends StatefulWidget { } class _DayPickerState extends State { - DateTime _date = DateTime.now(); - TimeOfDay _time = TimeOfDay.now(); + DateTime _date = DateTime.now(); + TimeOfDay _time = TimeOfDay.now(); Future _selectDate(BuildContext context) async { final DateTime picked = await showDatePicker( @@ -28,7 +28,7 @@ class _DayPickerState extends State { _date = picked; }); - if (picked == null) _date = DateTime.now(); + if (picked == null) _date = DateTime.now(); } Future _selectTime(BuildContext context) async { @@ -39,23 +39,23 @@ class _DayPickerState extends State { setState(() { _time = picked; }); - if (picked == null) _time = TimeOfDay.now(); + if (picked == null) _time = TimeOfDay.now(); } @override Widget build(BuildContext context) { - return Column( + return Column( children: [ - Text('日期选择'), - RaisedButton( - child: Text('date selected:${_date.toString()}'), + Text('日期选择'), + RaisedButton( + child: Text('date selected:${_date.toString()}'), onPressed: () { _selectDate(context); }, ), - Text('时间选择'), - RaisedButton( - child: Text('date selected:${_time.toString()}'), + Text('时间选择'), + RaisedButton( + child: Text('date selected:${_time.toString()}'), onPressed: () { _selectTime(context); }, diff --git a/lib/widgets/components/Pick/DayPicker/index.dart b/lib/widgets/components/Pick/DayPicker/index.dart index 72cdc9ed..be47a1f7 100644 --- a/lib/widgets/components/Pick/DayPicker/index.dart +++ b/lib/widgets/components/Pick/DayPicker/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 15:50:02 diff --git a/lib/widgets/components/Pick/MonthPicker/demo.dart b/lib/widgets/components/Pick/MonthPicker/demo.dart index bf4584c5..061a1bf7 100644 --- a/lib/widgets/components/Pick/MonthPicker/demo.dart +++ b/lib/widgets/components/Pick/MonthPicker/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:32 +/// @Date: 2018-12-17 15:37:32 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-21 11:26:21 @@ -13,7 +13,7 @@ class MothPickerDemo extends StatefulWidget { } class _MothPickerState extends State { - DateTime _date = DateTime.now(); + DateTime _date = DateTime.now(); Future _selectDate(BuildContext context) async { final DateTime picked = await showDatePicker( @@ -27,16 +27,16 @@ class _MothPickerState extends State { _date = picked; }); - if (picked == null) _date = DateTime.now(); + if (picked == null) _date = DateTime.now(); } @override Widget build(BuildContext context) { - return Column( + return Column( children: [ - Text('日期选择'), - RaisedButton( - child: Text('date selected:${_date.toString()}'), + Text('日期选择'), + RaisedButton( + child: Text('date selected:${_date.toString()}'), onPressed: () { _selectDate(context); }, diff --git a/lib/widgets/components/Pick/MonthPicker/index.dart b/lib/widgets/components/Pick/MonthPicker/index.dart index 4f4f864d..c34ee1ed 100644 --- a/lib/widgets/components/Pick/MonthPicker/index.dart +++ b/lib/widgets/components/Pick/MonthPicker/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 17:06:34 diff --git a/lib/widgets/components/Pick/ShowdatePicker/demo.dart b/lib/widgets/components/Pick/ShowdatePicker/demo.dart index c5c2c147..2a8d2c06 100644 --- a/lib/widgets/components/Pick/ShowdatePicker/demo.dart +++ b/lib/widgets/components/Pick/ShowdatePicker/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:32 +/// @Date: 2018-12-17 15:37:32 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-18 19:12:32 @@ -13,8 +13,8 @@ class ShowDatePickerDemo extends StatefulWidget { } class _ShowDatePickerState extends State { - DateTime _date = DateTime.now(); - TimeOfDay _time = TimeOfDay.now(); + DateTime _date = DateTime.now(); + TimeOfDay _time = TimeOfDay.now(); Future _selectDate(BuildContext context) async { final DateTime picked = await showDatePicker( @@ -28,7 +28,7 @@ class _ShowDatePickerState extends State { _date = picked; }); - if (picked == null) _date = DateTime.now(); + if (picked == null) _date = DateTime.now(); } Future _selectTime(BuildContext context) async { @@ -39,23 +39,23 @@ class _ShowDatePickerState extends State { setState(() { _time = picked; }); - if (picked == null) _time = TimeOfDay.now(); + if (picked == null) _time = TimeOfDay.now(); } @override Widget build(BuildContext context) { - return Column( + return Column( children: [ - Text('日期选择'), - RaisedButton( - child: Text('date selected:${_date.toString()}'), + Text('日期选择'), + RaisedButton( + child: Text('date selected:${_date.toString()}'), onPressed: () { _selectDate(context); }, ), - Text('时间选择'), - RaisedButton( - child: Text('date selected:${_time.toString()}'), + Text('时间选择'), + RaisedButton( + child: Text('date selected:${_time.toString()}'), onPressed: () { _selectTime(context); }, diff --git a/lib/widgets/components/Pick/ShowdatePicker/index.dart b/lib/widgets/components/Pick/ShowdatePicker/index.dart index fd2fe108..96aa59ff 100644 --- a/lib/widgets/components/Pick/ShowdatePicker/index.dart +++ b/lib/widgets/components/Pick/ShowdatePicker/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 diff --git a/lib/widgets/components/Pick/YearPicker/demo.dart b/lib/widgets/components/Pick/YearPicker/demo.dart index b6a74d2c..26eb7833 100644 --- a/lib/widgets/components/Pick/YearPicker/demo.dart +++ b/lib/widgets/components/Pick/YearPicker/demo.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:32 +/// @Date: 2018-12-17 15:37:32 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-11 15:17:26 @@ -13,7 +13,7 @@ class YearPickerDemo extends StatefulWidget { } class _YearPickerDemoState extends State { - DateTime _date = DateTime.now(); + DateTime _date = DateTime.now(); Future _selectDate(BuildContext context) async { final DateTime picked = await showDatePicker( @@ -27,16 +27,16 @@ class _YearPickerDemoState extends State { _date = picked; }); - if (picked == null) _date = DateTime.now(); + if (picked == null) _date = DateTime.now(); } @override Widget build(BuildContext context) { - return Column( + return Column( children: [ - Text('日期选择'), - RaisedButton( - child: Text('date selected:${_date.toString()}'), + Text('日期选择'), + RaisedButton( + child: Text('date selected:${_date.toString()}'), onPressed: () { _selectDate(context); }, diff --git a/lib/widgets/components/Pick/YearPicker/index.dart b/lib/widgets/components/Pick/YearPicker/index.dart index 9177677a..c2dbffe7 100644 --- a/lib/widgets/components/Pick/YearPicker/index.dart +++ b/lib/widgets/components/Pick/YearPicker/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 diff --git a/lib/widgets/components/Pick/index.dart b/lib/widgets/components/Pick/index.dart index 3e61a2ed..560d4b62 100644 --- a/lib/widgets/components/Pick/index.dart +++ b/lib/widgets/components/Pick/index.dart @@ -33,5 +33,4 @@ List widgetPoints = [ routerName: CityPicker.Demo.routeName, buildRouter: (BuildContext context) => CityPicker.Demo(), ), - ]; diff --git a/lib/widgets/components/Progress/CircularProgressIndicator/index.dart b/lib/widgets/components/Progress/CircularProgressIndicator/index.dart index c7579ad9..4ba1fe69 100644 --- a/lib/widgets/components/Progress/CircularProgressIndicator/index.dart +++ b/lib/widgets/components/Progress/CircularProgressIndicator/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 diff --git a/lib/widgets/components/Progress/LinearProgressIndicator/index.dart b/lib/widgets/components/Progress/LinearProgressIndicator/index.dart index dffc8dfb..a9641f2e 100644 --- a/lib/widgets/components/Progress/LinearProgressIndicator/index.dart +++ b/lib/widgets/components/Progress/LinearProgressIndicator/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 diff --git a/lib/widgets/components/Progress/RefreshProgressIndicator/demo.dart b/lib/widgets/components/Progress/RefreshProgressIndicator/demo.dart index e69de29b..8b137891 100644 --- a/lib/widgets/components/Progress/RefreshProgressIndicator/demo.dart +++ b/lib/widgets/components/Progress/RefreshProgressIndicator/demo.dart @@ -0,0 +1 @@ + diff --git a/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart b/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart index 92cce808..09c3342e 100644 --- a/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart +++ b/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart @@ -1,5 +1,5 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-17 15:37:16 +/// @Date: 2018-12-17 15:37:16 /// @Last Modified by: xiaojia.dxj /// @Last Modified time: 2018-12-17 16:00:07 @@ -22,7 +22,8 @@ const String content1 = ''' '''; class Demo extends StatefulWidget { - static const String routeName = '/components/Progress/RefreshProgressIndicator'; + static const String routeName = + '/components/Progress/RefreshProgressIndicator'; _DemoState createState() => _DemoState(); } @@ -36,7 +37,8 @@ class _DemoState extends State { // LinearProgressIndicatorDemo(), ], codeUrl: 'components/Progress/RefreshProgressIndicator/demo.dart', - docUrl:'https://docs.flutter.io/flutter/material/RefreshProgressIndicator-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/RefreshProgressIndicator-class.html', title: 'RefreshProgressIndicator'); } } diff --git a/lib/widgets/components/Scaffold/Scaffold/demo.dart b/lib/widgets/components/Scaffold/Scaffold/demo.dart index cd65e73e..1d80ecce 100644 --- a/lib/widgets/components/Scaffold/Scaffold/demo.dart +++ b/lib/widgets/components/Scaffold/Scaffold/demo.dart @@ -33,9 +33,9 @@ class _ScaffoldDemo extends State with SingleTickerProviderStateMixin { // 如果省略了 leading ,但 AppBar 在带有 Drawer 的 Scaffold 中,则会插入一个 button 以打开 Drawer。 // 否则,如果最近的 Navigator 具有任何先前的 router ,则会插入BackButton。 // 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。 - return SizedBox( + return SizedBox( height: 500, - child: Scaffold( + child: Scaffold( appBar: AppBar( title: Text('Sample Code'), ), @@ -46,8 +46,8 @@ class _ScaffoldDemo extends State with SingleTickerProviderStateMixin { FloatingActionButtonLocation.centerDocked, floatingActionButton: FloatingActionButton( onPressed: () => setState(() { - count += 1; - }), + count += 1; + }), tooltip: 'Increment Counter', child: Icon(Icons.add), ), diff --git a/lib/widgets/components/Scaffold/Scaffold/index.dart b/lib/widgets/components/Scaffold/Scaffold/index.dart index f90e562c..e83dc7a8 100644 --- a/lib/widgets/components/Scaffold/Scaffold/index.dart +++ b/lib/widgets/components/Scaffold/Scaffold/index.dart @@ -40,7 +40,6 @@ Scaffold 有下面几个主要属性: """; - class Demo extends StatefulWidget { static const String routeName = '/components/Scaffold/Scaffold'; @@ -56,7 +55,7 @@ class _DemoState extends State { codeUrl: 'components/Scaffold/Scaffold/demo.dart', contentList: [ _Text0, - ScaffoldDemo(), + ScaffoldDemo(), ], docUrl: 'https://docs.flutter.io/flutter/material/Scaffold-class.html', ); diff --git a/lib/widgets/components/Scaffold/ScaffoldState/demo.dart b/lib/widgets/components/Scaffold/ScaffoldState/demo.dart index 79f6aea0..ff581187 100644 --- a/lib/widgets/components/Scaffold/ScaffoldState/demo.dart +++ b/lib/widgets/components/Scaffold/ScaffoldState/demo.dart @@ -16,7 +16,6 @@ class ScaffoldStateDemo extends StatefulWidget { // AppBar 默认的实例,有状态 class _ScaffoldStateDemo extends State with SingleTickerProviderStateMixin { - int count = 0; final GlobalKey _scaffoldKey = GlobalKey(); @override @@ -24,14 +23,14 @@ class _ScaffoldStateDemo extends State with SingleTickerProviderStateMixin { // 如果省略了 leading ,但 AppBar 在带有 Drawer 的 Scaffold 中,则会插入一个 button 以打开 Drawer。 // 否则,如果最近的 Navigator 具有任何先前的 router ,则会插入BackButton。 // 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。 - return SizedBox( + return SizedBox( height: 500, child: Scaffold( - key:_scaffoldKey, + key: _scaffoldKey, appBar: AppBar( title: Text('ScaffoldState Demo'), ), - body: Center( + body: Center( child: Column( children: [ RaisedButton( @@ -39,8 +38,7 @@ class _ScaffoldStateDemo extends State with SingleTickerProviderStateMixin { onPressed: () { _scaffoldKey.currentState.openDrawer(); _scaffoldKey.currentState.showSnackBar(const SnackBar( - content: Text("我是通过ScaffoldState的方式呼出的SnackBar.") - )); + content: Text("我是通过ScaffoldState的方式呼出的SnackBar."))); }, ) ], @@ -72,9 +70,6 @@ class _ScaffoldStateDemo extends State with SingleTickerProviderStateMixin { ], ), ), - - ) - - ); + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Scaffold/ScaffoldState/index.dart b/lib/widgets/components/Scaffold/ScaffoldState/index.dart index 00dc10b0..3a5fae1d 100644 --- a/lib/widgets/components/Scaffold/ScaffoldState/index.dart +++ b/lib/widgets/components/Scaffold/ScaffoldState/index.dart @@ -24,7 +24,6 @@ const String _Text0 = """ """; - class Demo extends StatefulWidget { static const String routeName = '/components/Scaffold/ScaffoldState'; @@ -38,11 +37,9 @@ class _DemoState extends State { return WidgetDemo( title: 'ScaffoldState', codeUrl: 'components/Scaffold/ScaffoldState/demo.dart', - contentList: [ - _Text0, - ScaffoldStateDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/ScaffoldState-class.html', + contentList: [_Text0, ScaffoldStateDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/ScaffoldState-class.html', ); } } diff --git a/lib/widgets/components/Scroll/BoxScrollView/demo.dart b/lib/widgets/components/Scroll/BoxScrollView/demo.dart index 9562295e..8719e16f 100644 --- a/lib/widgets/components/Scroll/BoxScrollView/demo.dart +++ b/lib/widgets/components/Scroll/BoxScrollView/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-17 13:16:29 +/// @Author: 一凨 +/// @Date: 2018-12-17 13:16:29 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-17 13:43:01 diff --git a/lib/widgets/components/Scroll/BoxScrollView/index.dart b/lib/widgets/components/Scroll/BoxScrollView/index.dart index a696fba1..1f0d203d 100644 --- a/lib/widgets/components/Scroll/BoxScrollView/index.dart +++ b/lib/widgets/components/Scroll/BoxScrollView/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-17 13:16:46 +/// @Author: 一凨 +/// @Date: 2018-12-17 13:16:46 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-17 13:34:46 @@ -31,11 +31,7 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - BoxScrollViewDemo() - ], + contentList: [content0, content1, BoxScrollViewDemo()], codeUrl: 'components/Scroll/BoxScrollView/demo.dart', docUrl: 'https://docs.flutter.io/flutter/widgets/BoxScrollView-class.html', diff --git a/lib/widgets/components/Scroll/CustomScrollView/demo.dart b/lib/widgets/components/Scroll/CustomScrollView/demo.dart index b06e2dbb..aba849a2 100644 --- a/lib/widgets/components/Scroll/CustomScrollView/demo.dart +++ b/lib/widgets/components/Scroll/CustomScrollView/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-20 13:40:58 +/// @Author: 一凨 +/// @Date: 2018-12-20 13:40:58 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-20 14:06:31 @@ -58,9 +58,10 @@ class CustomScrollViewDemo extends StatelessWidget { backgroundColor: Theme.of(context).primaryColor, expandedHeight: 200.0, flexibleSpace: FlexibleSpaceBar( - background: Image.asset('assets/images/food01.jpeg', fit: BoxFit.cover), + background: + Image.asset('assets/images/food01.jpeg', fit: BoxFit.cover), ), - pinned: true,//固定导航 + pinned: true, //固定导航 ), SliverFixedExtentList( delegate: SliverChildListDelegate(products.map((product) { diff --git a/lib/widgets/components/Scroll/CustomScrollView/index.dart b/lib/widgets/components/Scroll/CustomScrollView/index.dart index cb466740..cc754166 100644 --- a/lib/widgets/components/Scroll/CustomScrollView/index.dart +++ b/lib/widgets/components/Scroll/CustomScrollView/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-20 13:21:36 +/// @Author: 一凨 +/// @Date: 2018-12-20 13:21:36 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-20 14:08:29 @@ -29,7 +29,6 @@ class Demo extends StatefulWidget { } class _DemoState extends State { - @override Widget build(BuildContext context) { return WidgetDemo( @@ -39,8 +38,9 @@ class _DemoState extends State { CustomScrollViewDemo(), ], codeUrl: 'components/Scroll/CustomScrollView/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/widgets/CustomScrollView-class.html', + docUrl: + 'https://docs.flutter.io/flutter/widgets/CustomScrollView-class.html', title: 'CustomScrollView', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Scroll/CustomScrollView/product_list.dart b/lib/widgets/components/Scroll/CustomScrollView/product_list.dart index 0c802382..f26e2d02 100644 --- a/lib/widgets/components/Scroll/CustomScrollView/product_list.dart +++ b/lib/widgets/components/Scroll/CustomScrollView/product_list.dart @@ -1,5 +1,3 @@ - - class ProductItem { final String name; final String tag; diff --git a/lib/widgets/components/Scroll/NestedScrollView/demo.dart b/lib/widgets/components/Scroll/NestedScrollView/demo.dart index cdb38f89..91780ee1 100644 --- a/lib/widgets/components/Scroll/NestedScrollView/demo.dart +++ b/lib/widgets/components/Scroll/NestedScrollView/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-20 14:19:26 +/// @Author: 一凨 +/// @Date: 2018-12-20 14:19:26 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 20:50:36 @@ -46,9 +46,9 @@ class _NestedScrollViewDemoState extends State flexibleSpace: Container( child: Image.asset( 'assets/images/timg.jpeg', - width: double.infinity, - repeat: ImageRepeat.repeat, - height: double.infinity, + width: double.infinity, + repeat: ImageRepeat.repeat, + height: double.infinity, ), ), bottom: TabBar( @@ -118,16 +118,16 @@ class PageTwo extends StatelessWidget { return ListView.builder( itemExtent: 250.0, itemBuilder: (context, index) => Container( - padding: EdgeInsets.all(10.0), - child: Material( - elevation: 4.0, - borderRadius: BorderRadius.circular(5.0), - color: index % 2 == 0 ? Colors.cyan : Colors.deepOrange, - child: Center( - child: Text(index.toString()), - ), - ), + padding: EdgeInsets.all(10.0), + child: Material( + elevation: 4.0, + borderRadius: BorderRadius.circular(5.0), + color: index % 2 == 0 ? Colors.cyan : Colors.deepOrange, + child: Center( + child: Text(index.toString()), ), + ), + ), ); } } diff --git a/lib/widgets/components/Scroll/NestedScrollView/index.dart b/lib/widgets/components/Scroll/NestedScrollView/index.dart index 6ea21f59..96185cec 100644 --- a/lib/widgets/components/Scroll/NestedScrollView/index.dart +++ b/lib/widgets/components/Scroll/NestedScrollView/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-20 14:18:36 +/// @Author: 一凨 +/// @Date: 2018-12-20 14:18:36 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-20 14:19:15 diff --git a/lib/widgets/components/Scroll/ScrollMetrics/demo.dart b/lib/widgets/components/Scroll/ScrollMetrics/demo.dart index 5a6a9fc4..d7e21896 100644 --- a/lib/widgets/components/Scroll/ScrollMetrics/demo.dart +++ b/lib/widgets/components/Scroll/ScrollMetrics/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 19:43:41 +/// @Author: 一凨 +/// @Date: 2018-12-15 19:43:41 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 21:37:03 diff --git a/lib/widgets/components/Scroll/ScrollMetrics/index.dart b/lib/widgets/components/Scroll/ScrollMetrics/index.dart index b0a50565..835e14dc 100644 --- a/lib/widgets/components/Scroll/ScrollMetrics/index.dart +++ b/lib/widgets/components/Scroll/ScrollMetrics/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 19:44:12 +/// @Author: 一凨 +/// @Date: 2018-12-15 19:44:12 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 20:33:47 @@ -36,7 +36,8 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( title: 'ScrollMetrics', - docUrl: 'https://docs.flutter.io/flutter/widgets/ScrollMetrics-class.html', + docUrl: + 'https://docs.flutter.io/flutter/widgets/ScrollMetrics-class.html', codeUrl: 'components/Scroll/ScrollMetrics/demo.dart', contentList: [ content0, @@ -45,4 +46,4 @@ class _DemoState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Scroll/ScrollPhysics/demo.dart b/lib/widgets/components/Scroll/ScrollPhysics/demo.dart index 3b31a90e..e511e580 100644 --- a/lib/widgets/components/Scroll/ScrollPhysics/demo.dart +++ b/lib/widgets/components/Scroll/ScrollPhysics/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 20:39:14 +/// @Author: 一凨 +/// @Date: 2018-12-15 20:39:14 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 21:27:39 @@ -10,7 +10,7 @@ class ScrollPhysicsDemo extends StatefulWidget { } class _ScrollPhysicsDemoState extends State { - final PageController _pageController = PageController(); + final PageController _pageController = PageController(); double _currentPage = 0.0; @override @@ -20,27 +20,27 @@ class _ScrollPhysicsDemoState extends State { width: MediaQuery.of(context).size.width, child: LayoutBuilder( builder: (context, constraints) => NotificationListener( - onNotification: (ScrollNotification note) { - setState(() { - _currentPage = _pageController.page; - }); - return false; - }, - child: PageView.custom( - physics: const PageScrollPhysics( - parent: const BouncingScrollPhysics()), - controller: _pageController, - childrenDelegate: SliverChildBuilderDelegate( - (context, index) => _SimplePage( - '$index', - parallaxOffset: - constraints.maxWidth / 2.0 * (index - _currentPage), - // 小字 Text 在页面滑动时要比整体移动速度快一倍,所以小字的 translate X 为 \tt{pageWidth / 2 * progress} 。 - ), - childCount: 10, - ), + onNotification: (ScrollNotification note) { + setState(() { + _currentPage = _pageController.page; + }); + return false; + }, + child: PageView.custom( + physics: + const PageScrollPhysics(parent: const BouncingScrollPhysics()), + controller: _pageController, + childrenDelegate: SliverChildBuilderDelegate( + (context, index) => _SimplePage( + '$index', + parallaxOffset: + constraints.maxWidth / 2.0 * (index - _currentPage), + // 小字 Text 在页面滑动时要比整体移动速度快一倍,所以小字的 translate X 为 \tt{pageWidth / 2 * progress} 。 ), + childCount: 10, ), + ), + ), ), ); } @@ -54,22 +54,25 @@ class _SimplePage extends StatelessWidget { final double parallaxOffset; @override - Widget build(BuildContext context) => Center( + Widget build(BuildContext context) => Center( child: Container( color: Theme.of(context).primaryColor, - child: Center( - child: Column( + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - Text( + Text( data, - style: const TextStyle(fontSize: 60.0,color: Colors.white), + style: const TextStyle(fontSize: 60.0, color: Colors.white), ), - SizedBox(height: 40.0), - Transform( + SizedBox(height: 40.0), + Transform( transform: - Matrix4.translationValues(parallaxOffset, 0.0, 0.0), - child: const Text('左右滑动,这是第二行滚动速度更快的小字',style: const TextStyle(fontSize: 16.0,color: Colors.white),), + Matrix4.translationValues(parallaxOffset, 0.0, 0.0), + child: const Text( + '左右滑动,这是第二行滚动速度更快的小字', + style: const TextStyle(fontSize: 16.0, color: Colors.white), + ), ), ], ), diff --git a/lib/widgets/components/Scroll/ScrollPhysics/index.dart b/lib/widgets/components/Scroll/ScrollPhysics/index.dart index 1fd5afd6..258cb230 100644 --- a/lib/widgets/components/Scroll/ScrollPhysics/index.dart +++ b/lib/widgets/components/Scroll/ScrollPhysics/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 20:39:18 +/// @Author: 一凨 +/// @Date: 2018-12-15 20:39:18 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 21:26:11 @@ -8,14 +8,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart'; -const String content0 = ''' +const String content0 = ''' ### **简介** > 确定滚动组件的物理属性 - 例如,确定当用户达到最大滚动范围或者停止滚动时,Scrollable的一些滚动行为 - 当启动物理 [Simulation](https://docs.flutter.io/flutter/physics/Simulation-class.html) 时,当前滚动位置和速度将作为初始条件。 - 使用simulation中的模拟移动来确定widget的滚动位置 '''; -const String content1 = ''' +const String content1 = ''' ### **基本用法** > 该widget不能赋值给参数类型为Widget的组件 - 下方Demo,我们设置PageView的physics属性,滑动感受下下方小字自定义的滚动 @@ -36,7 +36,8 @@ class _DemoState extends State { ScrollPhysicsDemo(), ], codeUrl: 'components/Scroll/ScrollPhysics/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/widgets/ScrollPhysics-class.html', + docUrl: + 'https://docs.flutter.io/flutter/widgets/ScrollPhysics-class.html', title: 'ScrollPhysics', ); } diff --git a/lib/widgets/components/Scroll/ScrollView/demo.dart b/lib/widgets/components/Scroll/ScrollView/demo.dart index f305971a..fe4699b2 100644 --- a/lib/widgets/components/Scroll/ScrollView/demo.dart +++ b/lib/widgets/components/Scroll/ScrollView/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 21:15:27 +/// @Author: 一凨 +/// @Date: 2018-12-10 21:15:27 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-10 21:16:05 @@ -9,7 +9,7 @@ class ScrollViewDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - height: 400.0,//注意这里的高度必须得指定 + height: 400.0, //注意这里的高度必须得指定 child: PageView( children: [ Container( diff --git a/lib/widgets/components/Scroll/ScrollView/index.dart b/lib/widgets/components/Scroll/ScrollView/index.dart index 465e6a4a..03c309b2 100644 --- a/lib/widgets/components/Scroll/ScrollView/index.dart +++ b/lib/widgets/components/Scroll/ScrollView/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 20:30:53 +/// @Author: 一凨 +/// @Date: 2018-12-10 20:30:53 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-14 20:36:57 @@ -8,7 +8,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart'; - const String contentText0 = ''' ### **简介** > 一个可以使内容滚动的Widget diff --git a/lib/widgets/components/Scroll/Scrollable/demo.dart b/lib/widgets/components/Scroll/Scrollable/demo.dart index 1ab53c44..fb04f416 100644 --- a/lib/widgets/components/Scroll/Scrollable/demo.dart +++ b/lib/widgets/components/Scroll/Scrollable/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 21:32:07 +/// @Author: 一凨 +/// @Date: 2018-12-10 21:32:07 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 16:26:20 diff --git a/lib/widgets/components/Scroll/Scrollable/index.dart b/lib/widgets/components/Scroll/Scrollable/index.dart index 82c07fe0..fe364669 100644 --- a/lib/widgets/components/Scroll/Scrollable/index.dart +++ b/lib/widgets/components/Scroll/Scrollable/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 21:31:24 +/// @Author: 一凨 +/// @Date: 2018-12-10 21:31:24 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 17:05:20 @@ -40,4 +40,4 @@ class _DemoState extends State { title: 'Scrollable', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Scroll/ScrollbarPainter/demo.dart b/lib/widgets/components/Scroll/ScrollbarPainter/demo.dart index 7698eef5..320e595e 100644 --- a/lib/widgets/components/Scroll/ScrollbarPainter/demo.dart +++ b/lib/widgets/components/Scroll/ScrollbarPainter/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 16:25:39 +/// @Author: 一凨 +/// @Date: 2018-12-15 16:25:39 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 19:36:43 @@ -14,7 +14,6 @@ const Duration _kScrollbarFadeDuration = Duration(milliseconds: 300); const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600); class PaintDemo extends StatelessWidget { - @override Widget build(BuildContext context) { return Container( diff --git a/lib/widgets/components/Scroll/ScrollbarPainter/index.dart b/lib/widgets/components/Scroll/ScrollbarPainter/index.dart index faf72744..cd9638aa 100644 --- a/lib/widgets/components/Scroll/ScrollbarPainter/index.dart +++ b/lib/widgets/components/Scroll/ScrollbarPainter/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-15 16:25:36 +/// @Author: 一凨 +/// @Date: 2018-12-15 16:25:36 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-15 19:38:18 diff --git a/lib/widgets/components/Scroll/index.dart b/lib/widgets/components/Scroll/index.dart index 0bdf7d15..5be113d5 100644 --- a/lib/widgets/components/Scroll/index.dart +++ b/lib/widgets/components/Scroll/index.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 20:37:51 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-22 20:37:51 +/// @Author: 一凨 +/// @Date: 2018-12-22 20:37:51 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-22 20:37:51 import 'package:flutter/material.dart'; @@ -56,4 +56,4 @@ List widgetPoints = [ routerName: NestedScrollView.Demo.routeName, buildRouter: (BuildContext context) => NestedScrollView.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/components/Tab/Tab/demo.dart b/lib/widgets/components/Tab/Tab/demo.dart index d5d5774e..371cc5db 100644 --- a/lib/widgets/components/Tab/Tab/demo.dart +++ b/lib/widgets/components/Tab/Tab/demo.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 20:38:01 +/// @Author: 一凨 +/// @Date: 2018-12-22 20:38:01 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 20:51:47 @@ -16,12 +16,13 @@ class TabDemo extends StatelessWidget { } class MyTabbedPage extends StatefulWidget { - const MyTabbedPage({ Key key }) : super(key: key); + const MyTabbedPage({Key key}) : super(key: key); @override _MyTabbedPageState createState() => _MyTabbedPageState(); } -class _MyTabbedPageState extends State with SingleTickerProviderStateMixin { +class _MyTabbedPageState extends State + with SingleTickerProviderStateMixin { final List myTabs = [ Tab(text: 'LEFT'), Tab(text: 'RIGHT'), @@ -35,11 +36,11 @@ class _MyTabbedPageState extends State with SingleTickerProviderSt _tabController = TabController(vsync: this, length: myTabs.length); } - @override - void dispose() { - _tabController.dispose(); - super.dispose(); - } + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -58,4 +59,4 @@ class _MyTabbedPageState extends State with SingleTickerProviderSt ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Tab/Tab/index.dart b/lib/widgets/components/Tab/Tab/index.dart index 02a80d98..c402b25f 100644 --- a/lib/widgets/components/Tab/Tab/index.dart +++ b/lib/widgets/components/Tab/Tab/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 20:37:58 +/// @Author: 一凨 +/// @Date: 2018-12-22 20:37:58 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 20:49:56 @@ -40,4 +40,4 @@ class _DemoState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/components/Tab/index.dart b/lib/widgets/components/Tab/index.dart index 866d9c8d..acea0f75 100644 --- a/lib/widgets/components/Tab/index.dart +++ b/lib/widgets/components/Tab/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-22 20:37:45 +/// @Author: 一凨 +/// @Date: 2018-12-22 20:37:45 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 20:43:15 @@ -10,8 +10,8 @@ import './Tab/index.dart' as Tab; List widgetPoints = [ WidgetPoint( - name:'Tab', + name: 'Tab', routerName: Tab.Demo.routeName, buildRouter: (BuildContext context) => Tab.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/components/index.dart b/lib/widgets/components/index.dart index 2077b0da..6225c978 100644 --- a/lib/widgets/components/index.dart +++ b/lib/widgets/components/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-10 20:34:18 +/// @Author: 一凨 +/// @Date: 2018-12-10 20:34:18 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-22 21:25:40 @@ -18,7 +18,6 @@ import 'Dialog/index.dart' as Dialog; import 'Scaffold/index.dart' as Scaffold; import 'Grid/index.dart' as GridTile; - List getWidgets() { List result = []; result.addAll(Scroll.widgetPoints); @@ -36,4 +35,4 @@ List getWidgets() { result.addAll(Scaffold.widgetPoints); result.addAll(GridTile.widgetPoints); return result; -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Button/DropdownButton/demo.dart b/lib/widgets/elements/Form/Button/DropdownButton/demo.dart index 42450c81..7d7d9bfe 100644 --- a/lib/widgets/elements/Form/Button/DropdownButton/demo.dart +++ b/lib/widgets/elements/Form/Button/DropdownButton/demo.dart @@ -13,16 +13,16 @@ var selectItValue; var selectItemValue; class DropdownButtonDefault extends StatelessWidget { - List generateItemList() { - final List items = List(); - final DropdownMenuItem item1 = DropdownMenuItem( - value: '张三', child: Text('张三')); - final DropdownMenuItem item2 = DropdownMenuItem( - value: '李四', child: Text('李四')); - final DropdownMenuItem item3 = DropdownMenuItem( - value: '王二', child: Text('王二')); - final DropdownMenuItem item4 = DropdownMenuItem( - value: '麻子', child: Text('麻子')); + List generateItemList() { + final List items = List(); + final DropdownMenuItem item1 = + DropdownMenuItem(value: '张三', child: Text('张三')); + final DropdownMenuItem item2 = + DropdownMenuItem(value: '李四', child: Text('李四')); + final DropdownMenuItem item3 = + DropdownMenuItem(value: '王二', child: Text('王二')); + final DropdownMenuItem item4 = + DropdownMenuItem(value: '麻子', child: Text('麻子')); items.add(item1); items.add(item2); items.add(item3); @@ -33,68 +33,68 @@ class DropdownButtonDefault extends StatelessWidget { @override Widget build(BuildContext context) { return DropdownButton( - hint: Text('下拉菜单选择一个人名'), - //设置这个value之后,选中对应位置的item, - //再次呼出下拉菜单,会自动定位item位置在当前按钮显示的位置处 - value: selectItValue, - items: generateItemList(), - onChanged: (T){ + hint: Text('下拉菜单选择一个人名'), + //设置这个value之后,选中对应位置的item, + //再次呼出下拉菜单,会自动定位item位置在当前按钮显示的位置处 + value: selectItValue, + items: generateItemList(), + onChanged: (T) { // setState(() { // selectItemValue=T; // }); - }, + }, ); } } -List getListData(){ - List items= List(); - DropdownMenuItem dropdownMenuItem1= DropdownMenuItem( +List getListData() { + List items = List(); + DropdownMenuItem dropdownMenuItem1 = DropdownMenuItem( child: Text('1'), value: '1', ); items.add(dropdownMenuItem1); - DropdownMenuItem dropdownMenuItem2= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem2 = DropdownMenuItem( child: Text('2'), value: '2', ); items.add(dropdownMenuItem2); - DropdownMenuItem dropdownMenuItem3= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem3 = DropdownMenuItem( child: Text('3'), value: '3', ); items.add(dropdownMenuItem3); - DropdownMenuItem dropdownMenuItem4= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem4 = DropdownMenuItem( child: Text('4'), value: '4', ); items.add(dropdownMenuItem4); - DropdownMenuItem dropdownMenuItem5= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem5 = DropdownMenuItem( child: Text('5'), value: '5', ); items.add(dropdownMenuItem5); - DropdownMenuItem dropdownMenuItem6= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem6 = DropdownMenuItem( child: Text('6'), value: '6', ); items.add(dropdownMenuItem6); - DropdownMenuItem dropdownMenuItem7= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem7 = DropdownMenuItem( child: Text('7'), value: '7', ); items.add(dropdownMenuItem7); - DropdownMenuItem dropdownMenuItem8= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem8 = DropdownMenuItem( child: Text('8'), value: '8', ); items.add(dropdownMenuItem8); - DropdownMenuItem dropdownMenuItem9= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem9 = DropdownMenuItem( child: Text('9'), value: '9', ); items.add(dropdownMenuItem9); - DropdownMenuItem dropdownMenuItem10= DropdownMenuItem( + DropdownMenuItem dropdownMenuItem10 = DropdownMenuItem( child: Text('10'), value: '10', ); @@ -106,34 +106,33 @@ List getListData(){ class DropdownButtonCustom extends StatelessWidget { final widget; final parent; - const DropdownButtonCustom([this.widget,this.parent]) - : super(); + const DropdownButtonCustom([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { return DropdownButton( - items: getListData(), - //当没有默认值的时候可以设置的提示 - hint:Text('下拉选择你想要的数据'), - //下拉菜单选择完之后显示给用户的值 - value: selectItemValue, - //下拉菜单item点击之后的回调 - onChanged: (T){ - if (parent.mounted) { - parent.setState(() { - selectItemValue = T; - }); - } - }, - //设置阴影的高度 - elevation: 24, - style: TextStyle(//设置文本框里面文字的样式 - color: Colors.red - ), - // isDense: true,//减少按钮的高度。默认情况下,此按钮的高度与其菜单项的高度相同。如果isDense为true,则按钮的高度减少约一半。 这个当按钮嵌入添加的容器中时,非常有用 - // 将下拉列表的内部内容设置为水平填充其父级 - isExpanded:true, - iconSize: 50.0,//设置三角标icon的大小 + items: getListData(), + //当没有默认值的时候可以设置的提示 + hint: Text('下拉选择你想要的数据'), + //下拉菜单选择完之后显示给用户的值 + value: selectItemValue, + //下拉菜单item点击之后的回调 + onChanged: (T) { + if (parent.mounted) { + parent.setState(() { + selectItemValue = T; + }); + } + }, + //设置阴影的高度 + elevation: 24, + style: TextStyle( + //设置文本框里面文字的样式 + color: Colors.red), + // isDense: true,//减少按钮的高度。默认情况下,此按钮的高度与其菜单项的高度相同。如果isDense为true,则按钮的高度减少约一半。 这个当按钮嵌入添加的容器中时,非常有用 + // 将下拉列表的内部内容设置为水平填充其父级 + isExpanded: true, + iconSize: 50.0, //设置三角标icon的大小 ); } } diff --git a/lib/widgets/elements/Form/Button/DropdownButton/index.dart b/lib/widgets/elements/Form/Button/DropdownButton/index.dart index f6d1ae8a..345d880b 100644 --- a/lib/widgets/elements/Form/Button/DropdownButton/index.dart +++ b/lib/widgets/elements/Form/Button/DropdownButton/index.dart @@ -11,19 +11,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart' as dropdownButton; -const String _dropdownText0 = -"""### **简介** +const String _dropdownText0 = """### **简介** > Dropdown button “用于从项目列表中进行选择的按钮” - 参数类型 T 是下拉菜单表示的值的类型。给定菜单中的所有条目必须表示具有一致类型的值。通常,使用枚举。每个DropdownMenuItem在项目必须专门与同类型的说法; """; -const String _dropdownText1 = -"""### **基本用法** +const String _dropdownText1 = """### **基本用法** > 此示例显示一个包含四个项目的菜单 """; -const String _dropdownText2 = -"""### **进阶用法** +const String _dropdownText2 = """### **进阶用法** > 此示例尝试调整所有属性,展示出效果 """; @@ -36,25 +33,27 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ + void setButtonShapeType() { //String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - this.setState((){ + this.setState(() { //buttonShapeType = _buttonShapeType; }); } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'DropdownButton', codeUrl: 'elements/Form/Button/DropdownButton/demo.dart', - contentList: allDropdownButtons(context,this), - docUrl: 'https://docs.flutter.io/flutter/material/DropdownButton-class.html', + contentList: allDropdownButtons(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/DropdownButton-class.html', ); } } // 所有的 DropdownButton 按钮 -List allDropdownButtons(BuildContext context,_DemoState that){ +List allDropdownButtons(BuildContext context, _DemoState that) { return [ _dropdownText0, _dropdownText1, @@ -71,4 +70,3 @@ List allDropdownButtons(BuildContext context,_DemoState that){ SizedBox(height: 20.0) ]; } - diff --git a/lib/widgets/elements/Form/Button/FlatButton/demo.dart b/lib/widgets/elements/Form/Button/FlatButton/demo.dart index 94cbcb50..88a4088a 100644 --- a/lib/widgets/elements/Form/Button/FlatButton/demo.dart +++ b/lib/widgets/elements/Form/Button/FlatButton/demo.dart @@ -14,20 +14,19 @@ import 'package:flutter/material.dart'; class FlatButtonDefault extends StatelessWidget { final bool isDisabled; - const FlatButtonDefault([ this.isDisabled = true]) + const FlatButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @override Widget build(BuildContext context) { return FlatButton( - // 文本内容 + // 文本内容 child: const Text('默认按钮', semanticsLabel: 'FLAT BUTTON 1'), onPressed: isDisabled ? () {} : null); } } - // FlatButton.icon 默认按钮的实例 // Create a text button from a pair of widgets that serve as the button's icon and label // isDisabled:是否是禁用 @@ -36,7 +35,7 @@ class FlatButtonIconDefault extends StatelessWidget { final IconData icon; const FlatButtonIconDefault( - [ this.isDisabled = true, this.icon = Icons.add_circle]) + [this.isDisabled = true, this.icon = Icons.add_circle]) : super(); Color _randomColor() { @@ -49,18 +48,17 @@ class FlatButtonIconDefault extends StatelessWidget { @override Widget build(BuildContext context) { return FlatButton.icon( - // 文本内容 + // 文本内容 icon: Icon(icon, size: 25.0, color: _randomColor()), label: Text('默认按钮', semanticsLabel: 'FLAT BUTTON 2'), onPressed: isDisabled ? () { - //_showMessage('点击了 FLAT BUTTON ', context); - } + //_showMessage('点击了 FLAT BUTTON ', context); + } : null); } } - // FlatButton 自定义的实例 class FlatButtonCustom extends StatelessWidget { @@ -69,18 +67,18 @@ class FlatButtonCustom extends StatelessWidget { final ShapeBorder shape; final VoidCallback onPressed; - const FlatButtonCustom([ - this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed - ]) :super(); + const FlatButtonCustom( + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) + : super(); @override Widget build(BuildContext context) { final _onPressed = onPressed; return FlatButton( - // 文本内容 + // 文本内容 child: Text(txt, semanticsLabel: 'FLAT BUTTON 2'), // 按钮颜色 color: color, @@ -101,14 +99,16 @@ class FlatButtonCustom extends StatelessWidget { splashColor: Colors.deepPurple, // 抗锯齿能力,抗锯齿等级依次递增,none(默认),hardEdge,antiAliasWithSaveLayer,antiAlias clipBehavior: Clip.antiAlias, - padding: EdgeInsets.only( - bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), - shape: (shape is ShapeBorder) ? shape : Border.all( - // 设置边框样式 - color: Colors.grey, - width: 2.0, - style: BorderStyle.solid, - ), + padding: + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + shape: (shape is ShapeBorder) + ? shape + : Border.all( + // 设置边框样式 + color: Colors.grey, + width: 2.0, + style: BorderStyle.solid, + ), // FlatButton 的点击事件 onPressed: () { // Perform some action @@ -120,7 +120,6 @@ class FlatButtonCustom extends StatelessWidget { // 参数 bool,按下后true,恢复false onHighlightChanged: (isClick) { print(isClick); - } - ); + }); } } diff --git a/lib/widgets/elements/Form/Button/FlatButton/index.dart b/lib/widgets/elements/Form/Button/FlatButton/index.dart index d7e5ba73..026b20f9 100644 --- a/lib/widgets/elements/Form/Button/FlatButton/index.dart +++ b/lib/widgets/elements/Form/Button/FlatButton/index.dart @@ -11,26 +11,21 @@ import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as flatButton; -const String _flatText0 = -"""### **简介** +const String _flatText0 = """### **简介** > FlatButton 是显示在(零高程)material widget 上的文本标签 - 通过填充颜色对触摸作出反应在工具栏上; - FlatButtons 故意不具有可见边框,因此必须依赖于它们相对于其他内容的位置以用于上下文; - 在对话框和卡片中,它们应该组合在一个底角中。避免使用平面按钮,它们会与其他内容混合,例如在列表中间;"""; -const String _flatText1 = -"""### **基本用法** +const String _flatText1 = """### **基本用法** > 参数的默认的 button 和禁用 button - 如果 onPressed 回调为null,则该按钮将被禁用,不会对触摸做出反应,并且将按 disabledColor 属性而不是color属性指定的颜色进行着色; - 如果您尝试更改按钮的颜色并且没有任何效果,请检查您是否正在传递非null onPressed处理程序;。"""; - -const String _flatText2 = -"""### **进阶用法1** +const String _flatText2 = """### **进阶用法1** > FlatButton.icon ,button 图标和标签的 widget 创建文本按钮;"""; -const String _flatText3 = -"""### **进阶用法2** +const String _flatText3 = """### **进阶用法2** > 更改参数的自定义,比如:边框,点击效果,内容文字颜色等; - 要使应用程序的一部分具有交互式,使用 ink splashes,请考虑使用InkWell; - Flat button 的最小尺寸为88.0×36.0,可以用 ButtonTheme 覆盖。该clipBehavior参数不能为空;"""; @@ -54,75 +49,76 @@ class _DemoState extends State { } } - // 所有的 FlatButton 按钮 -List allFlatButtons(BuildContext context){ +// 所有的 FlatButton 按钮 +List allFlatButtons(BuildContext context) { return [ - _flatText0, - _flatText1, - ButtonBar( - alignment: MainAxisAlignment.spaceAround, - mainAxisSize: MainAxisSize.max, - children: [ - flatButton.FlatButtonDefault(), - SizedBox(width: 20.0), // 间距 - flatButton.FlatButtonDefault(false), - ], - ), - _flatText2, - ButtonBar( - alignment: MainAxisAlignment.spaceAround, - //mainAxisSize: MainAxisSize.min, - children: [ - flatButton.FlatButtonIconDefault(), - flatButton.FlatButtonIconDefault(false), - ], - ), - ButtonBar( - alignment: MainAxisAlignment.spaceAround, - //mainAxisSize: MainAxisSize.min, - children: [ - flatButton.FlatButtonIconDefault(true, Icons.android), - flatButton.FlatButtonIconDefault(true, Icons.announcement), - ], - ), - _flatText3, - //flatButton.FlatButtonCustom(context,'主要按钮',Colors.blue), - flatButton.FlatButtonCustom('主要按钮',Colors.blue), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('成功按钮',Colors.green), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('信息按钮',Colors.grey), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('警告按钮',Colors.orange), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('危险按钮',Colors.pink), - SizedBox(height: 10.0), - flatButton.FlatButtonCustom('点击我试试!', Colors.red, - Border.all(color: Colors.brown, width: 5.0, style: BorderStyle.solid), - () => _showMessage('点击了 FLAT BUTTON ', context)), - SizedBox(height: 20.0) - ]; + _flatText0, + _flatText1, + ButtonBar( + alignment: MainAxisAlignment.spaceAround, + mainAxisSize: MainAxisSize.max, + children: [ + flatButton.FlatButtonDefault(), + SizedBox(width: 20.0), // 间距 + flatButton.FlatButtonDefault(false), + ], + ), + _flatText2, + ButtonBar( + alignment: MainAxisAlignment.spaceAround, + //mainAxisSize: MainAxisSize.min, + children: [ + flatButton.FlatButtonIconDefault(), + flatButton.FlatButtonIconDefault(false), + ], + ), + ButtonBar( + alignment: MainAxisAlignment.spaceAround, + //mainAxisSize: MainAxisSize.min, + children: [ + flatButton.FlatButtonIconDefault(true, Icons.android), + flatButton.FlatButtonIconDefault(true, Icons.announcement), + ], + ), + _flatText3, + //flatButton.FlatButtonCustom(context,'主要按钮',Colors.blue), + flatButton.FlatButtonCustom('主要按钮', Colors.blue), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom('成功按钮', Colors.green), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom('信息按钮', Colors.grey), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom('警告按钮', Colors.orange), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom('危险按钮', Colors.pink), + SizedBox(height: 10.0), + flatButton.FlatButtonCustom( + '点击我试试!', + Colors.red, + Border.all(color: Colors.brown, width: 5.0, style: BorderStyle.solid), + () => _showMessage('点击了 FLAT BUTTON ', context)), + SizedBox(height: 20.0) + ]; } - // alert 弹框 - // context:容器的父级 +// alert 弹框 +// context:容器的父级 void _showMessage(String name, BuildContext context) { showDialog( - // alert 的父级 - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text('提示'), - content: Text(name), - actions: [ - FlatButton( - // alert 的取消按钮 - onPressed: () { - // 取消的事件 - Navigator.of(context).pop(true); - }, - child: Text('取消')) - ]); - } - ); + // alert 的父级 + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('提示'), + content: Text(name), + actions: [ + FlatButton( + // alert 的取消按钮 + onPressed: () { + // 取消的事件 + Navigator.of(context).pop(true); + }, + child: Text('取消')) + ]); + }); } diff --git a/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart b/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart index 95303b83..045f0811 100644 --- a/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart +++ b/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart @@ -12,7 +12,7 @@ import 'package:flutter/material.dart'; class FloatingActionButtonDefault extends StatelessWidget { final bool isDisabled; - const FloatingActionButtonDefault([ this.isDisabled = true]) + const FloatingActionButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -20,7 +20,7 @@ class FloatingActionButtonDefault extends StatelessWidget { Widget build(BuildContext context) { return FloatingActionButton( // 文本内容 - backgroundColor:Colors.red, + backgroundColor: Colors.red, child: const Icon(Icons.add), heroTag: null, // 不加这个参数会黑屏... onPressed: isDisabled ? () {} : null); @@ -35,45 +35,44 @@ class FloatingActionButtonCustom extends StatelessWidget { final VoidCallback onPressed; const FloatingActionButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.orange, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.orange, + this.shape, + this.onPressed]) : super(); @override Widget build(BuildContext context) { - final _onPressed = (onPressed is Function) ? onPressed : ()=>{}; - return FloatingActionButton( - // 子视图,一般为Icon,不推荐使用文字 - child: const Icon(Icons.refresh), - // FAB的文字解释,FAB被长按时显示,也是无障碍功能 - tooltip: txt, - // 前景色 - foregroundColor: Colors.white, - // 背景色 - backgroundColor: color, - // hero效果使用的tag,系统默认会给所有FAB使用同一个tag,方便做动画效果,简单理解为两个界面内拥有同样tag的元素在界面切换过程中,会有动画效果,是界面切换不再那么生硬。 - heroTag: null, - // 未点击时阴影值,默认6.0 - elevation: 7.0, - // 点击时阴影值,默认12.0 - highlightElevation: 14.0, - // 点击事件回调 - onPressed: () { - Scaffold.of(context).showSnackBar( SnackBar( - content: Text("FAB is Clicked"), - )); - _onPressed(); - }, - // 是否为“mini”类型,默认为false,FAB 分为三种类型:regular, mini, and extended - mini: false, - // 定义FAB的shape,设置shape时,默认的elevation将会失效,默认为CircleBorder - //shape: CircleBorder(), - shape: shape, - // 是否为”extended”类型 - isExtended: true - ); + final _onPressed = (onPressed is Function) ? onPressed : () => {}; + return FloatingActionButton( + // 子视图,一般为Icon,不推荐使用文字 + child: const Icon(Icons.refresh), + // FAB的文字解释,FAB被长按时显示,也是无障碍功能 + tooltip: txt, + // 前景色 + foregroundColor: Colors.white, + // 背景色 + backgroundColor: color, + // hero效果使用的tag,系统默认会给所有FAB使用同一个tag,方便做动画效果,简单理解为两个界面内拥有同样tag的元素在界面切换过程中,会有动画效果,是界面切换不再那么生硬。 + heroTag: null, + // 未点击时阴影值,默认6.0 + elevation: 7.0, + // 点击时阴影值,默认12.0 + highlightElevation: 14.0, + // 点击事件回调 + onPressed: () { + Scaffold.of(context).showSnackBar(SnackBar( + content: Text("FAB is Clicked"), + )); + _onPressed(); + }, + // 是否为“mini”类型,默认为false,FAB 分为三种类型:regular, mini, and extended + mini: false, + // 定义FAB的shape,设置shape时,默认的elevation将会失效,默认为CircleBorder + //shape: CircleBorder(), + shape: shape, + // 是否为”extended”类型 + isExtended: true); } } @@ -85,10 +84,10 @@ class FloatingActionButtonCustom2 extends StatelessWidget { final VoidCallback onPressed; const FloatingActionButtonCustom2( - [ this.txt = '自定义按钮', - this.color = Colors.orange, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.orange, + this.shape, + this.onPressed]) : super(); @override @@ -102,8 +101,8 @@ class FloatingActionButtonCustom2 extends StatelessWidget { foregroundColor: Colors.white, backgroundColor: Colors.amber, //如果不手动设置icon和text颜色,则默认使用foregroundColor颜色 - icon: Icon(Icons.flag,color: Colors.red), - label: Text('FloatingActionButton.extended', maxLines: 1), + icon: Icon(Icons.flag, color: Colors.red), + label: Text('FloatingActionButton.extended', maxLines: 1), ); } } diff --git a/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart b/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart index 71e5b8ea..8d3948c9 100644 --- a/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart +++ b/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart @@ -13,28 +13,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as floatingActionButton; - -const String _floatingActionText0 = -"""### **简介** +const String _floatingActionText0 = """### **简介** > FloatingAction Button “浮动动作按钮” - FloatingActionButton 按钮是一个圆形图标按钮,悬停在内容上以提升应用程序中的主要操作。浮动操作按钮最常用于Scaffold.floatingActionButton字段中; - 每个屏幕最多使用一个浮动操作按钮。浮动操作按钮应用于积极操作,例如“创建”,“共享”或“导航”; - 一般用来处理界面中最常用,最基础的用户动作。它一般出现在屏幕内容的前面,通常是一个圆形,中间有一个图标。 FAB有三种类型:regular, mini, extended。不要强行使用FAB,只有当使用场景符合FAB功能的时候使用才最为恰当; """; -const String _floatingActionText1 = -"""### **基本用法** +const String _floatingActionText1 = """### **基本用法** > 默认参数的 button 和禁用 button - 如果 onPressed 回调为null,则该 button 将被禁用,并且不会对触摸作出反应,不会变成灰色; """; -const String _floatingActionText2 = -"""### **进阶用法1** +const String _floatingActionText2 = """### **进阶用法1** > 更改项参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等 """; -const String _floatingActionText3 = -"""### **进阶用法2** +const String _floatingActionText3 = """### **进阶用法2** > 更改项参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等 """; @@ -47,28 +42,31 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - if(mounted) { + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; + if (mounted) { this.setState(() { buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'FloatingActionButton', // desc: _floatingActionTitle, codeUrl: 'elements/Form/Button/FloatingActionButton/demo.dart', - contentList: allFloatingActionButtons(context,this), - docUrl: 'https://docs.flutter.io/flutter/material/FloatingActionButton-class.html', + contentList: allFloatingActionButtons(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/FloatingActionButton-class.html', ); } } - // 所有的 FloatingActionButton 按钮 -List allFloatingActionButtons(BuildContext context,_DemoState that){ +// 所有的 FloatingActionButton 按钮 +List allFloatingActionButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _floatingActionText0, @@ -96,12 +94,12 @@ List allFloatingActionButtons(BuildContext context,_DemoState that){ } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -112,7 +110,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -137,4 +136,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/IconButton/demo.dart b/lib/widgets/elements/Form/Button/IconButton/demo.dart index 69915c84..26010fda 100644 --- a/lib/widgets/elements/Form/Button/IconButton/demo.dart +++ b/lib/widgets/elements/Form/Button/IconButton/demo.dart @@ -10,16 +10,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/resources/icon_names.dart'; - -final int len = IconNames.names.length; - +final int len = IconNames.names.length; // IconButton 默认按钮的实例 // isDisabled:是否是禁用,isDisabled 默认为true class IconButtonDefault extends StatelessWidget { final bool isDisabled; - const IconButtonDefault([ this.isDisabled = true]) + const IconButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -41,13 +39,13 @@ class IconButtonCustom extends StatelessWidget { final VoidCallback onPressed; const IconButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); - getIcons(){ + getIcons() { return Icons; } @@ -58,22 +56,23 @@ class IconButtonCustom extends StatelessWidget { final _onPressed = onPressed; return IconButton( // 定义图标在IconButton中的定位方式,AlignmentGeometry 如果父Widget尺寸大于child Widget尺寸,这个属性设置会起作用,有很多种对齐方式。 - alignment:AlignmentDirectional.center, + alignment: AlignmentDirectional.center, // 按钮颜色 color: _randomColor(), // 如果图标被禁用,则用于按钮内图标的颜色。默认为当前主题的ThemeData.disabledColor - disabledColor:_randomColor(), + disabledColor: _randomColor(), // 高亮时的背景色 highlightColor: Colors.yellow, // 按钮内图标的大小 - icon:Icon(type), + icon: Icon(type), // 图标尺寸 - iconSize:(Random.secure().nextInt(20)+20).toDouble(), // 随机大小 + iconSize: (Random.secure().nextInt(20) + 20).toDouble(), // 随机大小 // 按钮内部,墨汁飞溅的颜色,点击按钮时的渐变背景色,当你不设置高亮背景时才会看的更清楚 splashColor: _randomColor(), - padding: EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + padding: + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), // 描述按下按钮时将发生的操作的文本 - tooltip:'这是${ type.codePoint }信息', + tooltip: '这是${type.codePoint}信息', // IconButton 的点击事件 onPressed: () { // Perform some action diff --git a/lib/widgets/elements/Form/Button/IconButton/index.dart b/lib/widgets/elements/Form/Button/IconButton/index.dart index e15147df..836f3185 100644 --- a/lib/widgets/elements/Form/Button/IconButton/index.dart +++ b/lib/widgets/elements/Form/Button/IconButton/index.dart @@ -1,11 +1,10 @@ - - /// Created with FlutterGo. - /// User: 一晟 - /// Date: 2018/11/14 - /// Time: 下午4:31 - /// email: zhu.yan@alibaba-inc.com - /// target: IconButton 的示例 - /// 对应文档地址:https://docs.flutter.io/flutter/material/IconButton-class.html +/// Created with FlutterGo. +/// User: 一晟 +/// Date: 2018/11/14 +/// Time: 下午4:31 +/// email: zhu.yan@alibaba-inc.com +/// target: IconButton 的示例 +/// 对应文档地址:https://docs.flutter.io/flutter/material/IconButton-class.html import 'dart:math'; @@ -14,20 +13,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as iconButton; -const String _iconText0 = -"""### **简介** +const String _iconText0 = """### **简介** > Icon button “图标按钮” - IconButton widget上的图片,通过填充颜色(墨水)来对触摸作出反应; """; -const String _iconText1 = -"""### **基本用法** +const String _iconText1 = """### **基本用法** > 参数的默认的按钮和禁用按钮 - 图标按钮通常在AppBar.actions字段中使用,但它们也可以在许多其他地方使用; - 如果您尝试更改按钮的颜色并且没有任何效果,请检查您是否正在传递非null onPressed处理程序;"""; -const String _iconText2 = -"""### **进阶用法** +const String _iconText2 = """### **进阶用法** > 更改项参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等; - 如果可能,图标按钮的命中区域的大小至少为48.0像素,与实际的iconSize无关,以满足 Material Design规范中的触摸目标大小要求。的对准控制图标本身如何定位命中区域内; - ** 长按可弹出 tip 文字 ** @@ -42,27 +38,29 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - if(mounted) { + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; + if (mounted) { this.setState(() { buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'IconButton', codeUrl: 'elements/Form/Button/IconButton/demo.dart', - contentList: allIconButtons(context,this), + contentList: allIconButtons(context, this), docUrl: 'https://docs.flutter.io/flutter/material/IconButton-class.html', ); } } // 所有的 IconButton 按钮 -List allIconButtons(BuildContext context,_DemoState that){ +List allIconButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _iconText0, @@ -89,7 +87,7 @@ List allIconButtons(BuildContext context,_DemoState that){ iconButton.IconButtonCustom('危险按钮', Colors.pink, buttonShape), SizedBox(height: 10.0), RaisedButton( - // 文本内容 + // 文本内容 child: const Text('点击切换,图标按钮', semanticsLabel: 'FLAT BUTTON 1'), onPressed: () => that.setButtonShapeType()), SizedBox(height: 20.0) @@ -97,12 +95,12 @@ List allIconButtons(BuildContext context,_DemoState that){ } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -113,7 +111,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -138,4 +137,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/OutlineButton/demo.dart b/lib/widgets/elements/Form/Button/OutlineButton/demo.dart index 5f169f1c..8a603bdc 100644 --- a/lib/widgets/elements/Form/Button/OutlineButton/demo.dart +++ b/lib/widgets/elements/Form/Button/OutlineButton/demo.dart @@ -14,7 +14,7 @@ import 'package:flutter/material.dart'; class OutlineButtonDefault extends StatelessWidget { final bool isDisabled; - const OutlineButtonDefault([ this.isDisabled = true]) + const OutlineButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -35,7 +35,7 @@ class OutlineButtonIconDefault extends StatelessWidget { final IconData icon; const OutlineButtonIconDefault( - [ this.isDisabled = true, this.icon = Icons.add_circle]) + [this.isDisabled = true, this.icon = Icons.add_circle]) : super(); @override @@ -60,10 +60,10 @@ class OutlineButtonCustom extends StatelessWidget { final VoidCallback onPressed; const OutlineButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override @@ -73,12 +73,14 @@ class OutlineButtonCustom extends StatelessWidget { // 文本内容 child: Text(txt, semanticsLabel: 'FLAT BUTTON 2'), // 边框的颜色,颜色也可以走主题色 Theme.of(context).primaryColor - borderSide: BorderSide(color: _randomColor(),width:Random.secure().nextInt(10).toDouble()), + borderSide: BorderSide( + color: _randomColor(), + width: Random.secure().nextInt(10).toDouble()), // 按钮颜色 color: _randomColor(), // 按钮失效时边框颜色 disabledBorderColor: Colors.red, - highlightedBorderColor:Colors.black54, + highlightedBorderColor: Colors.black54, // 高亮时的背景色 highlightColor: Colors.yellow, // 失效时的背景色 @@ -94,7 +96,8 @@ class OutlineButtonCustom extends StatelessWidget { splashColor: _randomColor(), // 抗锯齿能力,抗锯齿等级依次递增,none(默认),hardEdge,antiAliasWithSaveLayer,antiAlias clipBehavior: Clip.antiAlias, - padding: EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + padding: + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), //高亮时候的阴影 highlightElevation: 10.0, shape: shape, // 在Outline 里只能设置圆角,边框用borderSide diff --git a/lib/widgets/elements/Form/Button/OutlineButton/index.dart b/lib/widgets/elements/Form/Button/OutlineButton/index.dart index eb31d1e6..a215e1ec 100644 --- a/lib/widgets/elements/Form/Button/OutlineButton/index.dart +++ b/lib/widgets/elements/Form/Button/OutlineButton/index.dart @@ -13,26 +13,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as outlineButton; -const String _outlineText0 = -"""### **简介** +const String _outlineText0 = """### **简介** > Outline button “边框按钮” - RaisedButton和FlatButton之间的交叉:一个有边框的按钮,当按下按钮时,其高度增加,背景变得不透明; - 高程最初为0.0,其背景颜色 为透明。按下按钮时,其背景变为不透明,然后其高程增加到highlightElevation; """; -const String _outlineText1 = -"""### **基本用法** +const String _outlineText1 = """### **基本用法** > 参数的默认的 button 和禁用 button - 如果onPressed回调为null,则该按钮将被禁用,不会对触摸做出反应,并且将按 disabledColor 属性而不是color属性指定的颜色进行着色; - 如果您尝试更改按钮的颜色并且没有任何效果,请检查您是否正在传递非null onPressed处理程序;"""; - -const String _outlineText2 = -"""### **进阶用法1** +const String _outlineText2 = """### **进阶用法1** > OutlineButton.icon 的用法,按钮图标和标签的widget创建文本按钮"""; -const String _outlineText3 = -"""### **进阶用法2** +const String _outlineText3 = """### **进阶用法2** > 更改参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等; - Outline buttons 按钮有一个边框,其形状由形状定义 ,其外观由borderSide,disabledBorderColor 和 highlightedBorderColor 定义; - 如果您想要 ink-splash 效果,但又不想使用 button ,请考虑直接使用 InkWell; @@ -50,27 +45,30 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; if (mounted) { this.setState(() { buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'OutlineButton', codeUrl: 'elements/Form/Button/OutlineButton/demo.dart', - contentList: allOutlineButtons(context,this), - docUrl: 'https://docs.flutter.io/flutter/material/OutlineButton-class.html', + contentList: allOutlineButtons(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/OutlineButton-class.html', ); } } - // 所有的 OutlineButton 按钮 -List allOutlineButtons(BuildContext context,_DemoState that){ +// 所有的 OutlineButton 按钮 +List allOutlineButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _outlineText0, @@ -113,20 +111,19 @@ List allOutlineButtons(BuildContext context,_DemoState that){ SizedBox(height: 10.0), outlineButton.OutlineButtonCustom('危险按钮', Colors.pink, buttonShape), SizedBox(height: 10.0), - outlineButton.OutlineButtonCustom( - '点击切换,随机改变按钮的圆角,边框样式', Colors.blue, buttonShape, - () => that.setButtonShapeType()), + outlineButton.OutlineButtonCustom('点击切换,随机改变按钮的圆角,边框样式', Colors.blue, + buttonShape, () => that.setButtonShapeType()), SizedBox(height: 20.0) ]; } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -137,7 +134,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -162,4 +160,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart b/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart index 839f51c6..cf11ace0 100644 --- a/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart +++ b/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart @@ -15,8 +15,7 @@ class PopupMenuButtonDefault extends StatelessWidget { final bool isDisabled; final String type; - const PopupMenuButtonDefault( - [ this.type = 'default1', this.isDisabled = true]) + const PopupMenuButtonDefault([this.type = 'default1', this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -43,23 +42,23 @@ class PopupMenuButtonDefault extends StatelessWidget { // setState(() { _selection = result; }); }, itemBuilder: (BuildContext context) => >[ - const PopupMenuItem( - value: WhyFarther.harder, - child: Text('Working a lot harder'), - ), - const PopupMenuItem( - value: WhyFarther.smarter, - child: Text('Being a lot smarter'), - ), - const PopupMenuItem( - value: WhyFarther.selfStarter, - child: Text('Being a self-starter'), - ), - const PopupMenuItem( - value: WhyFarther.tradingCharter, - child: Text('Placed in charge of trading charter'), - ), - ], + const PopupMenuItem( + value: WhyFarther.harder, + child: Text('Working a lot harder'), + ), + const PopupMenuItem( + value: WhyFarther.smarter, + child: Text('Being a lot smarter'), + ), + const PopupMenuItem( + value: WhyFarther.selfStarter, + child: Text('Being a self-starter'), + ), + const PopupMenuItem( + value: WhyFarther.tradingCharter, + child: Text('Placed in charge of trading charter'), + ), + ], ); } @@ -68,8 +67,8 @@ class PopupMenuButtonDefault extends StatelessWidget { child: Text('点我试试'), onSelected: (String value) {}, itemBuilder: (BuildContext context) => >[ - PopupMenuItem(value: "选项一的内容", child: Text("选项一")), - PopupMenuItem(value: "选项二的内容", child: Text("选项二")) + PopupMenuItem(value: "选项一的内容", child: Text("选项一")), + PopupMenuItem(value: "选项二的内容", child: Text("选项二")) ]); } @@ -79,61 +78,58 @@ class PopupMenuButtonDefault extends StatelessWidget { icon: Icon(Icons.menu), onSelected: (String value) {}, itemBuilder: (BuildContext context) => >[ - PopupMenuItem(value: "选项一的内容", child: Text("选项一")), - PopupMenuItem(value: "选项二的内容", child: Text("选项二")) + PopupMenuItem(value: "选项一的内容", child: Text("选项一")), + PopupMenuItem(value: "选项二的内容", child: Text("选项二")) ]); } } - class PopupMenuButtonCustom extends StatelessWidget { final widget; final parent; - const PopupMenuButtonCustom([this.widget,this.parent]) - : super(); + const PopupMenuButtonCustom([this.widget, this.parent]) : super(); @override Widget build(BuildContext context) { final String selectStr = widget.options['defaultSelect']; return PopupMenuButton( //如果提供,则用于此按钮的widget。 child: RaisedButton.icon( - disabledColor:Colors.red, - icon: Icon(Icons.message, size: 25.0,color:Colors.yellow), - label: Text( - '自定义按钮', style: TextStyle(color: Colors.white), + disabledColor: Colors.red, + icon: Icon(Icons.message, size: 25.0, color: Colors.yellow), + label: Text('自定义按钮', + style: TextStyle(color: Colors.white), semanticsLabel: 'FLAT BUTTON'), - onPressed:(){} // 激活状态按钮 - ), + onPressed: () {} // 激活状态按钮 + ), // 打开时放置菜单的z坐标。这可以控制菜单下方阴影的大小。 - elevation:10.0, + elevation: 10.0, // 如果提供,则用于此按钮的图标。 //icon // 菜单项的值(如果有),在菜单打开时应突出显示。 //initialValue:options['defaultSelect'], - initialValue:selectStr, + initialValue: selectStr, // 按下按钮时调用以创建要在菜单中显示的项目。 itemBuilder: (BuildContext context) => >[ - PopupMenuItem(value: "选项一的内容", child: Text("选项一")), - PopupMenuItem(value: "选项二的内容", child: Text("选项二")), - PopupMenuItem(value: "选项三的内容", child: Text("选项三")), - PopupMenuItem(value: "选项四的内容", child: Text("选项四")) - ], + PopupMenuItem(value: "选项一的内容", child: Text("选项一")), + PopupMenuItem(value: "选项二的内容", child: Text("选项二")), + PopupMenuItem(value: "选项三的内容", child: Text("选项三")), + PopupMenuItem(value: "选项四的内容", child: Text("选项四")) + ], // 应用于弹出菜单按钮的偏移量(x,y)。 - offset:Offset(0.0,50.0), + offset: Offset(0.0, 50.0), // 当用户在不选择项目的情况下关闭弹出菜单时调用。 - onCanceled:()=> - print('onCanceled'), + onCanceled: () => print('onCanceled'), // 当用户从此按钮创建的弹出菜单中选择一个值时调用。 - onSelected:(String value){ + onSelected: (String value) { print('onSelected:${parent.setState}'); - parent.setState((){ - widget.options['defaultSelect']= value; + parent.setState(() { + widget.options['defaultSelect'] = value; }); }, // 默认情况下匹配IconButton的8 dps填充。在某些情况下,特别是在此按钮作为列表项的尾随元素出现的情况下,能够将填充设置为零是有用的。 - padding: EdgeInsets.only(bottom: 20.0, top: 20.0, left: 0.0, right: 0.0), + padding: + EdgeInsets.only(bottom: 20.0, top: 20.0, left: 0.0, right: 0.0), //描述按下按钮时将发生的操作的文本。 - tooltip:'这是信息' - ); + tooltip: '这是信息'); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart b/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart index a40e704d..e622da70 100644 --- a/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart +++ b/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart @@ -33,8 +33,8 @@ const String _titleText2 = """ class Demo extends StatefulWidget { static const String routeName = '/element/Form/Button/PopupMenuButton'; - final Map options = {'defaultSelect': '选项二的内容'}; - final _DemoState self = _DemoState(); + final Map options = {'defaultSelect': '选项二的内容'}; + final _DemoState self = _DemoState(); @override _DemoState createState() => self; @@ -42,19 +42,22 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - this.setState((){ + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; + this.setState(() { buttonShapeType = _buttonShapeType; }); } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'PopupMenuButton', codeUrl: 'elements/Form/Button/RaisedButton/demo.dart', - contentList: allPopupMenuButton(widget,this), - docUrl: 'https://docs.flutter.io/flutter/material/PopupMenuButton-class.html', + contentList: allPopupMenuButton(widget, this), + docUrl: + 'https://docs.flutter.io/flutter/material/PopupMenuButton-class.html', ); } } @@ -79,4 +82,4 @@ List allPopupMenuButton(Demo widget, State parent) { popupMenuButton.PopupMenuButtonCustom(widget, parent), SizedBox(height: 40.0) ]; -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Button/RaisedButton/demo.dart b/lib/widgets/elements/Form/Button/RaisedButton/demo.dart index b386be84..c38b30fb 100644 --- a/lib/widgets/elements/Form/Button/RaisedButton/demo.dart +++ b/lib/widgets/elements/Form/Button/RaisedButton/demo.dart @@ -13,7 +13,7 @@ import 'package:flutter/material.dart'; class RaisedButtonDefault extends StatelessWidget { final bool isDisabled; - const RaisedButtonDefault([ this.isDisabled = true]) + const RaisedButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -34,7 +34,7 @@ class RaisedButtonIconDefault extends StatelessWidget { final IconData icon; const RaisedButtonIconDefault( - [ this.isDisabled = true, this.icon = Icons.add_circle]) + [this.isDisabled = true, this.icon = Icons.add_circle]) : super(); Color _randomColor() { @@ -58,7 +58,6 @@ class RaisedButtonIconDefault extends StatelessWidget { } } - // RaisedButton 自定义的实例 class RaisedButtonCustom extends StatelessWidget { final String txt; @@ -67,10 +66,10 @@ class RaisedButtonCustom extends StatelessWidget { final VoidCallback onPressed; const RaisedButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override @@ -99,10 +98,10 @@ class RaisedButtonCustom extends StatelessWidget { // 抗锯齿能力,抗锯齿等级依次递增,none(默认),hardEdge,antiAliasWithSaveLayer,antiAlias clipBehavior: Clip.antiAlias, padding: - EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), shape: (shape is ShapeBorder) ? shape - : Border.all( + : Border.all( // 设置边框样式 color: Colors.grey, width: 2.0, diff --git a/lib/widgets/elements/Form/Button/RaisedButton/index.dart b/lib/widgets/elements/Form/Button/RaisedButton/index.dart index 87caba25..de352853 100644 --- a/lib/widgets/elements/Form/Button/RaisedButton/index.dart +++ b/lib/widgets/elements/Form/Button/RaisedButton/index.dart @@ -13,28 +13,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as raisedButton; - -const String _raisedText0 = -"""### **简介** +const String _raisedText0 = """### **简介** > Raised button “凸起按钮” - Raised button 基于 a Material widget 窗口widget,按下 button 时,Material.elevation 会增加; - 使用 Raised button 可将尺寸添加到大多数平面布局中; - 例如在复杂的内容列表中,或在宽阔的空间中。避免在已经提出的内容(例如对话框或卡片)上使用 Raised button; """; -const String _raisedText1 = -"""### **基本用法** +const String _raisedText1 = """### **基本用法** > 参数的默认的 button 和禁用 button; - 如果onPressed回调为null,则该按钮将被禁用,不会对触摸做出反应,并且将按 disabledColor 属性而不是color属性指定的颜色进行着色; - 如果您尝试更改按钮的颜色并且没有任何效果,请检查您是否正在传递非null onPressed处理程序;"""; - -const String _raisedText2 = -"""### **进阶用法1** +const String _raisedText2 = """### **进阶用法1** > RaisedButton.icon 的用方法,按钮图标和标签的widget创建文本按钮;"""; -const String _raisedText3 = -"""### **进阶用法2** +const String _raisedText3 = """### **进阶用法2** > 更改项参数的自定义,比如:边框,点击效果,内容文字,颜色,圆角等 - 如果您想要 ink-splash 的墨水效果,但又不想使用按钮,请考虑直接使用InkWell; - Raised buttons 的最小尺寸为88.0×36.0,可以用 ButtonTheme 覆盖; @@ -50,27 +44,30 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ - String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - if(mounted) { + void setButtonShapeType() { + String _buttonShapeType = + (buttonShapeType == 'border') ? 'radius' : 'border'; + if (mounted) { this.setState(() { buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'RaisedButton', codeUrl: 'elements/Form/Button/RaisedButton/demo.dart', contentList: allRaisedButtons(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/RaisedButton-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/RaisedButton-class.html', ); } } - // 所有的 RaisedButton 按钮 -List allRaisedButtons(BuildContext context,_DemoState that){ +// 所有的 RaisedButton 按钮 +List allRaisedButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _raisedText0, @@ -114,18 +111,18 @@ List allRaisedButtons(BuildContext context,_DemoState that){ raisedButton.RaisedButtonCustom('危险按钮', Colors.pink, buttonShape), SizedBox(height: 10.0), raisedButton.RaisedButtonCustom('点击切换,按钮的圆角', Colors.blue, buttonShape, - () => that.setButtonShapeType()), + () => that.setButtonShapeType()), SizedBox(height: 20.0) ]; } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -136,7 +133,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -161,4 +159,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart b/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart index a763504c..cb89d945 100644 --- a/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart +++ b/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart @@ -15,7 +15,7 @@ import 'package:flutter/material.dart'; class RawMaterialButtonDefault extends StatelessWidget { final bool isDisabled; - const RawMaterialButtonDefault([ this.isDisabled = true]) + const RawMaterialButtonDefault([this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -36,21 +36,21 @@ class RawMaterialButtonCustom extends StatelessWidget { final VoidCallback onPressed; const RawMaterialButtonCustom( - [ this.txt = '自定义按钮', - this.color = Colors.blueAccent, - this.shape, - this.onPressed]) + [this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override Widget build(BuildContext context) { final _onPressed = onPressed; - final _fontSize = (Random.secure().nextInt(10)+15).toDouble(); + final _fontSize = (Random.secure().nextInt(10) + 15).toDouble(); return RawMaterialButton( // 使用Material.textStyle为按钮的子项定义默认文本样式。 - textStyle:TextStyle(color: _randomColor(),fontSize: _fontSize), + textStyle: TextStyle(color: _randomColor(), fontSize: _fontSize), // 定义形状和高程的动画更改的持续时间 - animationDuration:Duration(seconds: 1), + animationDuration: Duration(seconds: 1), // 文本内容 child: Text(txt, semanticsLabel: 'FLAT BUTTON 2'), // 高亮时的背景色 @@ -59,7 +59,8 @@ class RawMaterialButtonCustom extends StatelessWidget { splashColor: _randomColor(), // 抗锯齿能力,抗锯齿等级依次递增,none(默认),hardEdge,antiAliasWithSaveLayer,antiAlias clipBehavior: Clip.antiAlias, - padding: EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), + padding: + EdgeInsets.only(bottom: 5.0, top: 5.0, left: 30.0, right: 30.0), //高亮时候的阴影 highlightElevation: 10.0, // 按钮材质的形状 diff --git a/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart b/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart index b17bf1fa..b422ef91 100644 --- a/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart +++ b/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart @@ -13,20 +13,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as rawMaterialButton; -const String _rawMaterialText0 = -"""### **简介** +const String _rawMaterialText0 = """### **简介** > RawMaterial button “RawMaterial 按钮” - 基于 Semantics,Material 和InkWell 小部件创建按钮; - 此类不使用当前 Theme 或 ButtonTheme 来计算未指定参数的默认值。它旨在用于自定义 Material button,可选择包含主题或特定于应用程序源的默认值; """; -const String _rawMaterialText1 = -"""### **基本用法** +const String _rawMaterialText1 = """### **基本用法** > 参数的默认的 button 和禁用 button """; -const String _rawMaterialText2 = -"""### **进阶用法** +const String _rawMaterialText2 = """### **进阶用法** > 更改项参数的自定义 """; @@ -39,28 +36,29 @@ class Demo extends StatefulWidget { class _DemoState extends State { String buttonShapeType = 'border'; // 边框类型 - void setButtonShapeType(){ + void setButtonShapeType() { //String _buttonShapeType = (buttonShapeType == 'border') ? 'radius' : 'border'; - if( mounted ) { + if (mounted) { this.setState(() { //buttonShapeType = _buttonShapeType; }); } } + @override Widget build(BuildContext context) { return WidgetDemo( title: 'RawMaterialButton', codeUrl: 'elements/Form/Button/RawMaterialButton/demo.dart', - contentList: allRawMaterialButtons(context,this), - docUrl: 'https://docs.flutter.io/flutter/material/RawMaterialButton-class.html', + contentList: allRawMaterialButtons(context, this), + docUrl: + 'https://docs.flutter.io/flutter/material/RawMaterialButton-class.html', ); } } - // 所有的 RawMaterialButton 按钮 -List allRawMaterialButtons(BuildContext context,_DemoState that){ +List allRawMaterialButtons(BuildContext context, _DemoState that) { final ShapeBorder buttonShape = drawShape(that.buttonShapeType); return [ _rawMaterialText0, @@ -88,20 +86,19 @@ List allRawMaterialButtons(BuildContext context,_DemoState that){ SizedBox(height: 10.0), rawMaterialButton.RawMaterialButtonCustom('危险按钮', Colors.pink, buttonShape), SizedBox(height: 10.0), - rawMaterialButton.RawMaterialButtonCustom( - '点击切换,观察字体变化', Colors.blue, buttonShape, - () => that.setButtonShapeType()), + rawMaterialButton.RawMaterialButtonCustom('点击切换,观察字体变化', Colors.blue, + buttonShape, () => that.setButtonShapeType()), SizedBox(height: 20.0) ]; } // 绘制边框信息,比如是否有边框,是否是圆角 -ShapeBorder drawShape(String type){ +ShapeBorder drawShape(String type) { final Color _color = _randomColor(); final borderWidth = Random.secure().nextInt(5).toDouble(); final radiusWidth = Random.secure().nextInt(50).toDouble(); - switch(type){ + switch (type) { case 'border': return Border.all( // 设置边框样式 @@ -112,7 +109,8 @@ ShapeBorder drawShape(String type){ break; case 'radius': return RoundedRectangleBorder( - side: BorderSide( // 保留原来的边框样式 + side: BorderSide( + // 保留原来的边框样式 width: borderWidth, color: _color, style: BorderStyle.solid, @@ -137,4 +135,3 @@ Color _randomColor() { var blue = Random.secure().nextInt(255); return Color.fromARGB(255, red, greed, blue); } - diff --git a/lib/widgets/elements/Form/Button/index.dart b/lib/widgets/elements/Form/Button/index.dart index b5cda7e7..24d2b29f 100644 --- a/lib/widgets/elements/Form/Button/index.dart +++ b/lib/widgets/elements/Form/Button/index.dart @@ -10,7 +10,6 @@ import 'FloatingActionButton/index.dart' as FloatingActionButton; import 'RawMaterialButton/index.dart' as RawMaterialButton; import 'DropdownButton/index.dart' as DropdownButton; - List widgetPoints = [ WidgetPoint( name: 'FlatButton', @@ -52,4 +51,4 @@ List widgetPoints = [ routerName: DropdownButton.Demo.routeName, buildRouter: (BuildContext context) => DropdownButton.Demo(), ) -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart b/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart index 7cd4037f..2ed71c8e 100644 --- a/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart +++ b/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart @@ -11,30 +11,30 @@ import 'package:flutter/material.dart'; /// Checkbox 默认的实例 /// index 当前checkbox 的索引值 -class CheckboxDefault extends StatefulWidget{ +class CheckboxDefault extends StatefulWidget { final int index; final parent; const CheckboxDefault([this.parent, this.index = -1]) : super(); @override - State createState() =>_CheckboxDefault(); + State createState() => _CheckboxDefault(); } + class _CheckboxDefault extends State { - bool isChecked=false; + bool isChecked = false; Color color = _randomColor(); // 注意和下面的 StatelessWidget 里的 _randomColor 区别 @override Widget build(BuildContext context) { return Checkbox( activeColor: color, - tristate:false, + tristate: false, value: isChecked, onChanged: (bool bol) { - if(mounted) { + if (mounted) { setState(() { isChecked = bol; }); } - } - ); + }); } } @@ -45,24 +45,22 @@ class CheckboxSelect extends StatelessWidget { final widget; final parent; - const CheckboxSelect([this.widget,this.parent, this.index = -1]) - : super(); + const CheckboxSelect([this.widget, this.parent, this.index = -1]) : super(); @override Widget build(BuildContext context) { Color color = _randomColor(); return Checkbox( activeColor: color, - tristate:false, + tristate: false, value: parent.selectValue == this.index, onChanged: (bool bol) { - if(parent.mounted) { + if (parent.mounted) { parent.setState(() { parent.selectValue = bol ? this.index : -1; }); } - } - ); + }); } } diff --git a/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart b/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart index 2a65383f..dd3a2efb 100644 --- a/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart +++ b/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart @@ -11,22 +11,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as checkbox; -const String _checkboxText0 = -"""### **简介** +const String _checkboxText0 = """### **简介** > checkbox “复选框” - 复选框本身不保持任何状态; - 当复选框的状态发生变化时,窗口小部件会调用onChanged回调; - 大多数使用复选框的小部件将侦听onChanged回调,并使用新值重建复选框以更新复选框的可视外观;"""; - -const String _checkboxText1 = -"""### **基本用法** +const String _checkboxText1 = """### **基本用法** > 下面示例展示多个颜色(随机)样式的 `checkbox` - 一个多选的 `checkbox`; """; -const String _checkboxText2 = -"""### **进阶用法** +const String _checkboxText2 = """### **进阶用法** > 下面示例展示多个颜色(随机)样式的 `checkbox` - 一个单选 `checkbox` 操作; """; @@ -45,14 +41,14 @@ class _DemoState extends State { return WidgetDemo( title: 'Checkbox', codeUrl: 'elements/Form/CheckBox/Checkbox/demo.dart', - contentList: allCheckboxs(context,this), + contentList: allCheckboxs(context, this), docUrl: 'https://docs.flutter.io/flutter/material/Checkbox-class.html', ); } } - // 所有的 Checkbox 按钮 -List allCheckboxs(BuildContext context,_DemoState that){ +// 所有的 Checkbox 按钮 +List allCheckboxs(BuildContext context, _DemoState that) { return [ _checkboxText0, _checkboxText1, @@ -82,5 +78,3 @@ List allCheckboxs(BuildContext context,_DemoState that){ SizedBox(width: 20.0), // 间距 ]; } - - diff --git a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart index a302b59c..84a8c950 100644 --- a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart +++ b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart @@ -23,78 +23,80 @@ class _CheckboxListTileStateDefault extends State { for (var i = 0; i < isChecks.length; i++) { isChecks[i] = value; } - if(mounted) { + if (mounted) { setState(() => _value = value); } } - bool isCheck=false; - List isChecks=[false,false,false,false]; + + bool isCheck = false; + List isChecks = [false, false, false, false]; @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Center( + Center( child: CheckboxListTile( value: _value, - selected:true,// 默认文字是否高亮 + selected: true, // 默认文字是否高亮 onChanged: _valueChanged, - dense: false,// 文字是否对齐 图标高度 - isThreeLine: false,// 文字是否三行显示 - title: Text('全部'), // 主标题 - controlAffinity: ListTileControlAffinity.trailing, // 将控件放在何处相对于文本,leading 按钮显示在文字后面,platform,trailing 按钮显示在文字前面 - subtitle: Text('勾选下列全部结果'), // 标题下方显示的副标题 - secondary: Icon(Icons.archive), // 从复选框显示在磁贴另一侧的小组件 + dense: false, // 文字是否对齐 图标高度 + isThreeLine: false, // 文字是否三行显示 + title: Text('全部'), // 主标题 + controlAffinity: ListTileControlAffinity + .trailing, // 将控件放在何处相对于文本,leading 按钮显示在文字后面,platform,trailing 按钮显示在文字前面 + subtitle: Text('勾选下列全部结果'), // 标题下方显示的副标题 + secondary: Icon(Icons.archive), // 从复选框显示在磁贴另一侧的小组件 activeColor: Colors.red, // 选中此复选框时要使用的颜色 ), ), - Center( - child: CheckboxListTile( + Center( + child: CheckboxListTile( value: isChecks[0], - title: Text('选项1'), + title: Text('选项1'), activeColor: _value ? Colors.red : Colors.green, controlAffinity: ListTileControlAffinity.platform, - onChanged: (bool){ - if(mounted) { + onChanged: (bool) { + if (mounted) { setState(() { isChecks[0] = bool; }); } }), ), - Center( - child: CheckboxListTile( + Center( + child: CheckboxListTile( value: isChecks[1], - title: Text('选项2'), + title: Text('选项2'), activeColor: _value ? Colors.red : Colors.green, controlAffinity: ListTileControlAffinity.platform, - onChanged: (bool){ + onChanged: (bool) { setState(() { - isChecks[1]=bool; + isChecks[1] = bool; }); }), ), - Center( - child: CheckboxListTile( + Center( + child: CheckboxListTile( value: isChecks[2], - title: Text('选项3'), + title: Text('选项3'), activeColor: _value ? Colors.red : Colors.green, controlAffinity: ListTileControlAffinity.platform, - onChanged: (bool){ + onChanged: (bool) { setState(() { - isChecks[2]=bool; + isChecks[2] = bool; }); }), ), - Center( - child: CheckboxListTile( + Center( + child: CheckboxListTile( value: isChecks[3], - title: Text('选项4'), + title: Text('选项4'), activeColor: _value ? Colors.red : Colors.green, controlAffinity: ListTileControlAffinity.platform, - onChanged: (bool){ + onChanged: (bool) { setState(() { - isChecks[3]=bool; + isChecks[3] = bool; }); }), ) @@ -107,8 +109,7 @@ class _CheckboxListTileStateDefault extends State { class CheckboxListTileDefault extends StatelessWidget { final widget; final parant; - const CheckboxListTileDefault ([this.widget,this.parant]) - : super(); + const CheckboxListTileDefault([this.widget, this.parant]) : super(); @override Widget build(BuildContext context) { @@ -116,10 +117,10 @@ class CheckboxListTileDefault extends StatelessWidget { title: Text('一个简单的例子'), activeColor: Colors.red, value: widget.valBool['val'], - onChanged: (bool value) { - parant.setState(()=> widget.valBool['val'] = value); - }, - secondary: const Icon(Icons.hourglass_empty), + onChanged: (bool value) { + parant.setState(() => widget.valBool['val'] = value); + }, + secondary: const Icon(Icons.hourglass_empty), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart index 47605144..6da94e38 100644 --- a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart +++ b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart @@ -10,16 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as CheckboxListTileDemo; -const String _CheckboxListTileText0 = -"""### **简介** +const String _CheckboxListTileText0 = """### **简介** > CheckboxListTile “下拉复选框” - 带有复选框的 ListTile,带有标签的 ListTile; - 整个列表图块是交互式的:点击图块中的任意位置可切换复选框; """; - -const String _CheckboxListTileText1 = -"""### **基本用法** +const String _CheckboxListTileText1 = """### **基本用法** > CheckboxListTile 的属性特征 - 与 Checkbox 类似的命名属性,比如:onChanged 和 activeColor; - 和 ListTile 类似的命名属性,比如:title, subtitle, isThreeLine,dense; @@ -27,14 +24,13 @@ const String _CheckboxListTileText1 = - onChanged 回调函数为 null,显示禁用; """; -const String _CheckboxListTileText2 = -"""### **进阶用法** +const String _CheckboxListTileText2 = """### **进阶用法** > CheckboxListTile 单选和全选的示例 """; class Demo extends StatefulWidget { static const String routeName = '/element/Form/Checkbox/CheckboxListTile'; - final Map valBool = {'val':true}; + final Map valBool = {'val': true}; @override _DemoState createState() => _DemoState(); } @@ -46,14 +42,15 @@ class _DemoState extends State { title: 'CheckboxListTile', codeUrl: 'elements/Form/CheckBox/CheckboxListTile/demo.dart', contentList: allCheckboxs(context, this), - docUrl: 'https://docs.flutter.io/flutter/material/CheckboxListTile-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/CheckboxListTile-class.html', ); } } - // 所有的 CheckboxListTile widget - // context: 运行上下文 - // that: 指向有状态的 StatefulWidget +// 所有的 CheckboxListTile widget +// context: 运行上下文 +// that: 指向有状态的 StatefulWidget List allCheckboxs(BuildContext context, _DemoState that) { return [ _CheckboxListTileText0, @@ -65,4 +62,3 @@ List allCheckboxs(BuildContext context, _DemoState that) { SizedBox(height: 20.0), ]; } - diff --git a/lib/widgets/elements/Form/CheckBox/index.dart b/lib/widgets/elements/Form/CheckBox/index.dart index 6c26b47d..8e9eea85 100644 --- a/lib/widgets/elements/Form/CheckBox/index.dart +++ b/lib/widgets/elements/Form/CheckBox/index.dart @@ -4,7 +4,6 @@ import '../../../../model/widget.dart'; import 'Checkbox/index.dart' as Checkbox; import 'CheckboxListTile/index.dart' as CheckboxListTile; - List widgetPoints = [ WidgetPoint( name: 'Checkbox', @@ -16,4 +15,4 @@ List widgetPoints = [ routerName: CheckboxListTile.Demo.routeName, buildRouter: (BuildContext context) => CheckboxListTile.Demo(), ) -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Form/Input/TextField/text_field_demo.dart b/lib/widgets/elements/Form/Input/TextField/text_field_demo.dart index f028bfe0..147a3435 100644 --- a/lib/widgets/elements/Form/Input/TextField/text_field_demo.dart +++ b/lib/widgets/elements/Form/Input/TextField/text_field_demo.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; class DefaultTextField extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return Container( padding: const EdgeInsets.all(30.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, //文本是起始端对齐 @@ -27,7 +27,7 @@ class CustomTextField extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return Container( padding: const EdgeInsets.all(30.0), child: TextField( keyboardType: TextInputType.number, diff --git a/lib/widgets/elements/Form/Radio/Radio/demo.dart b/lib/widgets/elements/Form/Radio/Radio/demo.dart index 2e5df8df..69e4a8ef 100644 --- a/lib/widgets/elements/Form/Radio/Radio/demo.dart +++ b/lib/widgets/elements/Form/Radio/Radio/demo.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 22/11/2018 - /// Time: 19:37 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 22/11/2018 +/// Time: 19:37 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; @@ -18,38 +18,34 @@ class _Demo extends State { groupValue = val; }); } + Widget build(BuildContext context) { - return ( - Container( - alignment: Alignment.centerLeft, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Radio( - value: 1, - groupValue: groupValue,//当value和groupValue一致的时候则选中 - onChanged: (T){ - onChange(T); - } - ), - Radio( - value: 2, - groupValue: groupValue, - onChanged: (T){ - onChange(T); - } - ), - Radio( - value: 3, - groupValue: groupValue, - onChanged: (T){ - onChange(T); - } - ) - ], - ), - ) - ); + return (Container( + alignment: Alignment.centerLeft, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Radio( + value: 1, + groupValue: groupValue, //当value和groupValue一致的时候则选中 + onChanged: (T) { + onChange(T); + }), + Radio( + value: 2, + groupValue: groupValue, + onChanged: (T) { + onChange(T); + }), + Radio( + value: 3, + groupValue: groupValue, + onChanged: (T) { + onChange(T); + }) + ], + ), + )); } } diff --git a/lib/widgets/elements/Form/Radio/Radio/index.dart b/lib/widgets/elements/Form/Radio/Radio/index.dart index ba347f19..8f79c2bf 100644 --- a/lib/widgets/elements/Form/Radio/Radio/index.dart +++ b/lib/widgets/elements/Form/Radio/Radio/index.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 22/11/2018 - /// Time: 19:17 - /// email: sanfan.hx@alibaba-inc.com - /// target: Radio相关 +/// Created with Android Studio. +/// User: 三帆 +/// Date: 22/11/2018 +/// Time: 19:17 +/// email: sanfan.hx@alibaba-inc.com +/// target: Radio相关 import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; @@ -24,6 +24,7 @@ Radio widget 代表表单中的单选按钮, 当groupValue = value时代表组 - onChanged → ValueChanged - 改变时触发。 - value → T - 单选的值。 """; + class Demo extends StatefulWidget { static const String routeName = '/element/Form/Radio/Radio'; _DemoState createState() => _DemoState(); diff --git a/lib/widgets/elements/Form/Radio/RadioListTile/demo.dart b/lib/widgets/elements/Form/Radio/RadioListTile/demo.dart index 7bd16122..57fe51e6 100644 --- a/lib/widgets/elements/Form/Radio/RadioListTile/demo.dart +++ b/lib/widgets/elements/Form/Radio/RadioListTile/demo.dart @@ -1,13 +1,12 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 20/12/2018 - /// Time: 14:32 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 20/12/2018 +/// Time: 14:32 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; - class DemoA extends StatefulWidget { _Demo createState() => _Demo(); } @@ -20,25 +19,23 @@ class _Demo extends State { value = v; }); } - Widget build(BuildContext context) { - return Column( + Widget build(BuildContext context) { + return Column( children: [ RadioListTile( - title: const Text('A'), - value: "A", - groupValue: this.value, - isThreeLine: false, - subtitle: const Text("subtitleA"), - onChanged:onChange - ), + title: const Text('A'), + value: "A", + groupValue: this.value, + isThreeLine: false, + subtitle: const Text("subtitleA"), + onChanged: onChange), RadioListTile( - title: const Text('B'), - value: "B", + title: const Text('B'), + value: "B", subtitle: const Text("subtitleB"), - groupValue: this.value, - onChanged: onChange - ), + groupValue: this.value, + onChanged: onChange), ], ); } diff --git a/lib/widgets/elements/Form/Radio/RadioListTile/index.dart b/lib/widgets/elements/Form/Radio/RadioListTile/index.dart index 603451c7..0f7ed52c 100644 --- a/lib/widgets/elements/Form/Radio/RadioListTile/index.dart +++ b/lib/widgets/elements/Form/Radio/RadioListTile/index.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 22/11/2018 - /// Time: 19:17 - /// email: sanfan.hx@alibaba-inc.com - /// target: Radio相关 +/// Created with Android Studio. +/// User: 三帆 +/// Date: 22/11/2018 +/// Time: 19:17 +/// email: sanfan.hx@alibaba-inc.com +/// target: Radio相关 import 'package:flutter/material.dart'; @@ -21,6 +21,7 @@ const content1 = """ ### **基本用法** Radio是单选框,和checkbox一样本身不包含状态,当groupValue = value时代表选中状态 """; + class Demo extends StatefulWidget { static const String routeName = '/element/Form/RadioListTile/index'; _DemoState createState() => _DemoState(); @@ -30,13 +31,10 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content1, - new DemoA() - - ], + contentList: [content1, new DemoA()], title: 'RadioListTile', - docUrl: 'https://docs.flutter.io/flutter/material/RadioListTile-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/RadioListTile-class.html', codeUrl: 'elements/Form/Radio/RadioListTile/demo.dart', ); } diff --git a/lib/widgets/elements/Form/Radio/index.dart b/lib/widgets/elements/Form/Radio/index.dart index f987d9ed..fb88bd7f 100644 --- a/lib/widgets/elements/Form/Radio/index.dart +++ b/lib/widgets/elements/Form/Radio/index.dart @@ -4,7 +4,6 @@ import '../../../../model/widget.dart'; import 'Radio/index.dart' as Radio; import 'RadioListTile/index.dart' as RadioTile; - List widgetPoints = [ WidgetPoint( name: 'Radio', @@ -16,5 +15,4 @@ List widgetPoints = [ routerName: RadioTile.Demo.routeName, buildRouter: (BuildContext context) => RadioTile.Demo(), ), - -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Form/Slider/Slider/demo.dart b/lib/widgets/elements/Form/Slider/Slider/demo.dart index 9e596828..9bc326ab 100644 --- a/lib/widgets/elements/Form/Slider/Slider/demo.dart +++ b/lib/widgets/elements/Form/Slider/Slider/demo.dart @@ -7,7 +7,6 @@ import 'package:flutter/material.dart'; - class SliderDemo extends StatefulWidget { _Demo createState() => _Demo(); } diff --git a/lib/widgets/elements/Form/Slider/Slider/index.dart b/lib/widgets/elements/Form/Slider/Slider/index.dart index 515ae27e..32cc4e04 100644 --- a/lib/widgets/elements/Form/Slider/Slider/index.dart +++ b/lib/widgets/elements/Form/Slider/Slider/index.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -40,7 +40,6 @@ slider 用来选择连续性的或者非连续性的数据. 默认是在一段 '''; - const contentB = ''' ### **高级用法** > 自定义Slider 样式 @@ -80,12 +79,7 @@ class _Demo extends State { return WidgetDemo( title: 'Slider', codeUrl: 'elements/Form/Slider/Slider/demo.dart', - contentList: [ - contentA, - SliderDemo(), - contentB, - SliderThemeDemo() - ], + contentList: [contentA, SliderDemo(), contentB, SliderThemeDemo()], docUrl: 'https://docs.flutter.io/flutter/material/Slider-class.html', ); } diff --git a/lib/widgets/elements/Form/Slider/SliderTheme/demo.dart b/lib/widgets/elements/Form/Slider/SliderTheme/demo.dart index babb65c5..0a1dd402 100644 --- a/lib/widgets/elements/Form/Slider/SliderTheme/demo.dart +++ b/lib/widgets/elements/Form/Slider/SliderTheme/demo.dart @@ -1,13 +1,12 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 27/12/2018 - /// Time: 14:40 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 27/12/2018 +/// Time: 14:40 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; - class SliderThemeDemo extends StatefulWidget { _SliderThemeDemo createState() => _SliderThemeDemo(); } @@ -16,43 +15,44 @@ class _SliderThemeDemo extends State { double value = 0.0; @override Widget build(BuildContext context) { - return Container( - child: SliderTheme( + return Container( + child: SliderTheme( data: SliderTheme.of(context).copyWith( // activeTickMarkColor:Colors.yellowAccent, - activeTrackColor: Colors.yellowAccent,//实际进度的颜色 + activeTrackColor: Colors.yellowAccent, //实际进度的颜色 // inactiveTickMarkColor:Colors.black - thumbColor: Colors.black,//滑块中心的颜色 - inactiveTrackColor:Colors.red,//默 认进度条的颜色 - valueIndicatorColor: Colors.blue,//提示进度的气派的背景色 - valueIndicatorTextStyle: TextStyle(//提示气泡里面文字的样式 + thumbColor: Colors.black, //滑块中心的颜色 + inactiveTrackColor: Colors.red, //默 认进度条的颜色 + valueIndicatorColor: Colors.blue, //提示进度的气派的背景色 + valueIndicatorTextStyle: TextStyle( + //提示气泡里面文字的样式 color: Colors.white, ), - inactiveTickMarkColor:Colors.blue,//divisions对进度线分割后 断续线中间间隔的颜色 - overlayColor: Colors.pink,//滑块边缘颜色 + inactiveTickMarkColor: Colors.blue, //divisions对进度线分割后 断续线中间间隔的颜色 + overlayColor: Colors.pink, //滑块边缘颜色 ), - child: Container( + child: Container( width: 340.0, margin: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0), - child: Row( + child: Row( children: [ - Text('0.0'), - Expanded( + Text('0.0'), + Expanded( flex: 1, - child: Slider( + child: Slider( value: value, label: '$value', divisions: 10, - onChanged: (double){ + onChanged: (double) { setState(() { - value=double.floorToDouble();//转化成double + value = double.floorToDouble(); //转化成double }); }, min: 0.0, max: 100.0, ), ), - Text('100.0'), + Text('100.0'), ], ), ), diff --git a/lib/widgets/elements/Form/Slider/SliderTheme/index.dart b/lib/widgets/elements/Form/Slider/SliderTheme/index.dart index 8b8e8b2a..61dc6a65 100644 --- a/lib/widgets/elements/Form/Slider/SliderTheme/index.dart +++ b/lib/widgets/elements/Form/Slider/SliderTheme/index.dart @@ -1,14 +1,14 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 20/12/2018 - /// Time: 17:43 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 20/12/2018 +/// Time: 17:43 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -52,7 +52,6 @@ const contentA = ''' '''; - class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Slider/SliderTheme'; _Demo createState() => _Demo(); @@ -66,7 +65,7 @@ class _Demo extends State { codeUrl: 'elements/Form/Slider/SliderTheme/demo.dart', contentList: [ contentA, - SliderThemeDemo(), + SliderThemeDemo(), ], docUrl: 'https://docs.flutter.io/flutter/material/SliderTheme-class.html', ); diff --git a/lib/widgets/elements/Form/Slider/SliderThemeData/demo.dart b/lib/widgets/elements/Form/Slider/SliderThemeData/demo.dart index babb65c5..0a1dd402 100644 --- a/lib/widgets/elements/Form/Slider/SliderThemeData/demo.dart +++ b/lib/widgets/elements/Form/Slider/SliderThemeData/demo.dart @@ -1,13 +1,12 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 27/12/2018 - /// Time: 14:40 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 27/12/2018 +/// Time: 14:40 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; - class SliderThemeDemo extends StatefulWidget { _SliderThemeDemo createState() => _SliderThemeDemo(); } @@ -16,43 +15,44 @@ class _SliderThemeDemo extends State { double value = 0.0; @override Widget build(BuildContext context) { - return Container( - child: SliderTheme( + return Container( + child: SliderTheme( data: SliderTheme.of(context).copyWith( // activeTickMarkColor:Colors.yellowAccent, - activeTrackColor: Colors.yellowAccent,//实际进度的颜色 + activeTrackColor: Colors.yellowAccent, //实际进度的颜色 // inactiveTickMarkColor:Colors.black - thumbColor: Colors.black,//滑块中心的颜色 - inactiveTrackColor:Colors.red,//默 认进度条的颜色 - valueIndicatorColor: Colors.blue,//提示进度的气派的背景色 - valueIndicatorTextStyle: TextStyle(//提示气泡里面文字的样式 + thumbColor: Colors.black, //滑块中心的颜色 + inactiveTrackColor: Colors.red, //默 认进度条的颜色 + valueIndicatorColor: Colors.blue, //提示进度的气派的背景色 + valueIndicatorTextStyle: TextStyle( + //提示气泡里面文字的样式 color: Colors.white, ), - inactiveTickMarkColor:Colors.blue,//divisions对进度线分割后 断续线中间间隔的颜色 - overlayColor: Colors.pink,//滑块边缘颜色 + inactiveTickMarkColor: Colors.blue, //divisions对进度线分割后 断续线中间间隔的颜色 + overlayColor: Colors.pink, //滑块边缘颜色 ), - child: Container( + child: Container( width: 340.0, margin: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0), - child: Row( + child: Row( children: [ - Text('0.0'), - Expanded( + Text('0.0'), + Expanded( flex: 1, - child: Slider( + child: Slider( value: value, label: '$value', divisions: 10, - onChanged: (double){ + onChanged: (double) { setState(() { - value=double.floorToDouble();//转化成double + value = double.floorToDouble(); //转化成double }); }, min: 0.0, max: 100.0, ), ), - Text('100.0'), + Text('100.0'), ], ), ), diff --git a/lib/widgets/elements/Form/Slider/SliderThemeData/index.dart b/lib/widgets/elements/Form/Slider/SliderThemeData/index.dart index b28e578a..8dd56b78 100644 --- a/lib/widgets/elements/Form/Slider/SliderThemeData/index.dart +++ b/lib/widgets/elements/Form/Slider/SliderThemeData/index.dart @@ -1,15 +1,15 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 20/12/2018 - /// Time: 17:43 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 20/12/2018 +/// Time: 17:43 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -25,7 +25,6 @@ const contentA = ''' '''; - class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Slider/SliderThemeData'; _Demo createState() => _Demo(); @@ -38,11 +37,9 @@ class _Demo extends State { return WidgetDemo( title: 'SliderThemeData', codeUrl: 'elements/Form/Slider/SliderThemeData/demo.dart', - contentList: [ - contentA, - SliderThemeDemo() - ], - docUrl: 'https://docs.flutter.io/flutter/material/SliderThemeData-class.html', + contentList: [contentA, SliderThemeDemo()], + docUrl: + 'https://docs.flutter.io/flutter/material/SliderThemeData-class.html', ); } } diff --git a/lib/widgets/elements/Form/Switch/AnimatedSwitcher/demo.dart b/lib/widgets/elements/Form/Switch/AnimatedSwitcher/demo.dart index 1ec3e50a..ab982c9a 100644 --- a/lib/widgets/elements/Form/Switch/AnimatedSwitcher/demo.dart +++ b/lib/widgets/elements/Form/Switch/AnimatedSwitcher/demo.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 28/12/2018 - /// Time: 19:58 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 28/12/2018 +/// Time: 19:58 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; @@ -47,4 +47,4 @@ class _ClickCounterState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Switch/Switch/demo.dart b/lib/widgets/elements/Form/Switch/Switch/demo.dart index a575b718..a6c9cbe8 100644 --- a/lib/widgets/elements/Form/Switch/Switch/demo.dart +++ b/lib/widgets/elements/Form/Switch/Switch/demo.dart @@ -15,7 +15,7 @@ class _Demo extends State { bool check = false; @override Widget build(BuildContext context) { - return Switch( + return Switch( value: this.check, onChanged: (bool val) { this.setState(() { @@ -34,9 +34,9 @@ class _SwitchHighDemo extends State { bool check = false; @override Widget build(BuildContext context) { - return Switch.adaptive( + return Switch.adaptive( value: this.check, - activeColor: Colors.blue, // 激活时原点颜色 + activeColor: Colors.blue, // 激活时原点颜色 onChanged: (bool val) { this.setState(() { this.check = !this.check; @@ -46,7 +46,6 @@ class _SwitchHighDemo extends State { } } - class SwitchTypesDemo extends StatefulWidget { _SwitchTypesDemo createState() => _SwitchTypesDemo(); } @@ -55,16 +54,16 @@ class _SwitchTypesDemo extends State { bool check = false; @override Widget build(BuildContext context) { - return Switch( + return Switch( value: this.check, - activeTrackColor:Colors.green, + activeTrackColor: Colors.green, inactiveThumbColor: Colors.black, - inactiveThumbImage: NetworkImage('https://flutter.io/images/homepage/header-illustration.png'), - activeThumbImage: NetworkImage( - "https://flutter.io/images/homepage/screenshot-2.png" - ), + inactiveThumbImage: NetworkImage( + 'https://flutter.io/images/homepage/header-illustration.png'), + activeThumbImage: + NetworkImage("https://flutter.io/images/homepage/screenshot-2.png"), inactiveTrackColor: Colors.yellow, - activeColor: Colors.blue, // 激活时原点颜色 + activeColor: Colors.blue, // 激活时原点颜色 onChanged: (bool val) { this.setState(() { this.check = !this.check; @@ -72,4 +71,4 @@ class _SwitchTypesDemo extends State { }, ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Switch/Switch/index.dart b/lib/widgets/elements/Form/Switch/Switch/index.dart index c7ce8dff..18c6c0c2 100644 --- a/lib/widgets/elements/Form/Switch/Switch/index.dart +++ b/lib/widgets/elements/Form/Switch/Switch/index.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -20,7 +20,6 @@ const contentA = ''' '''; - const contentB = ''' ios 风格的实例 @@ -45,7 +44,6 @@ const contentC = ''' '''; - class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Switch/Switch'; _Demo createState() => _Demo(); diff --git a/lib/widgets/elements/Form/Switch/SwitchListTile/demo.dart b/lib/widgets/elements/Form/Switch/SwitchListTile/demo.dart index 57b21ea1..05c8d8ee 100644 --- a/lib/widgets/elements/Form/Switch/SwitchListTile/demo.dart +++ b/lib/widgets/elements/Form/Switch/SwitchListTile/demo.dart @@ -1,9 +1,9 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 28/12/2018 - /// Time: 15:48 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 28/12/2018 +/// Time: 15:48 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; @@ -15,11 +15,15 @@ class _Demo extends State { bool _lights = false; @override Widget build(BuildContext context) { - return SwitchListTile( + return SwitchListTile( title: const Text('Lights'), value: _lights, - onChanged: (bool value) { setState(() { _lights = value; }); }, + onChanged: (bool value) { + setState(() { + _lights = value; + }); + }, secondary: const Icon(Icons.lightbulb_outline), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Switch/SwitchListTile/index.dart b/lib/widgets/elements/Form/Switch/SwitchListTile/index.dart index bc4adbcb..09c1eab1 100644 --- a/lib/widgets/elements/Form/Switch/SwitchListTile/index.dart +++ b/lib/widgets/elements/Form/Switch/SwitchListTile/index.dart @@ -1,13 +1,13 @@ - /// Created with Android Studio. - /// User: 三帆 - /// Date: 28/12/2018 - /// Time: 15:48 - /// email: sanfan.hx@alibaba-inc.com - /// target: xxx +/// Created with Android Studio. +/// User: 三帆 +/// Date: 28/12/2018 +/// Time: 15:48 +/// email: sanfan.hx@alibaba-inc.com +/// target: xxx import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; -import 'demo.dart'; +import 'demo.dart'; const contentA = ''' ### **简介** @@ -21,7 +21,6 @@ const contentA = ''' '''; - class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Switch/SwitchListTile'; _Demo createState() => _Demo(); @@ -33,10 +32,7 @@ class _Demo extends State { return WidgetDemo( title: 'SwitchListTile', codeUrl: 'elements/Form/Switch/SwitchListTile/demo.dart', - contentList: [ - contentA, - SwitchListTileDemo() - ], + contentList: [contentA, SwitchListTileDemo()], docUrl: '', ); } diff --git a/lib/widgets/elements/Form/Switch/index.dart b/lib/widgets/elements/Form/Switch/index.dart index c6f26d73..bd28c6d3 100644 --- a/lib/widgets/elements/Form/Switch/index.dart +++ b/lib/widgets/elements/Form/Switch/index.dart @@ -5,7 +5,6 @@ import "Switch/index.dart" as Switch; import "SwitchListTile/index.dart" as SwitchListTile; import "AnimatedSwitcher/index.dart" as AnimatedSwitcher; - List widgetPoints = [ WidgetPoint( name: 'Switch', diff --git a/lib/widgets/elements/Form/Text/RichText/demo.dart b/lib/widgets/elements/Form/Text/RichText/demo.dart index 8d8705ae..f2547f93 100644 --- a/lib/widgets/elements/Form/Text/RichText/demo.dart +++ b/lib/widgets/elements/Form/Text/RichText/demo.dart @@ -17,12 +17,16 @@ class _Demo extends State { return Container( color: Color(0xff000000), width: 750.0, - child: RichText( + child: RichText( text: TextSpan( text: 'Hello ', children: [ - TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold, color: Color(0xfffffc42))), - TextSpan(text: ' world!', style: TextStyle(fontStyle: FontStyle.italic)), + TextSpan( + text: 'bold', + style: TextStyle( + fontWeight: FontWeight.bold, color: Color(0xfffffc42))), + TextSpan( + text: ' world!', style: TextStyle(fontStyle: FontStyle.italic)), ], ), ), diff --git a/lib/widgets/elements/Form/Text/RichText/index.dart b/lib/widgets/elements/Form/Text/RichText/index.dart index 0e2e8451..d6e31a60 100644 --- a/lib/widgets/elements/Form/Text/RichText/index.dart +++ b/lib/widgets/elements/Form/Text/RichText/index.dart @@ -18,7 +18,6 @@ const String intro = """ """; - class Demo extends StatefulWidget { static const String routeName = '/element/Form/Text/RichText'; _Demo createState() => _Demo(); @@ -28,12 +27,12 @@ class _Demo extends State { @override Widget build(BuildContext context) { return WidgetDemo( - title: 'Rich Text', - docUrl: 'https://docs.flutter.io/flutter/widgets/RichText-class.html', - codeUrl: 'elements/Form/Text/RichText/demo.dart', - contentList: [ - intro, - RichTextDemo(), - ]); + title: 'Rich Text', + docUrl: 'https://docs.flutter.io/flutter/widgets/RichText-class.html', + codeUrl: 'elements/Form/Text/RichText/demo.dart', + contentList: [ + intro, + RichTextDemo(), + ]); } } diff --git a/lib/widgets/elements/Form/Text/Text/demo.dart b/lib/widgets/elements/Form/Text/Text/demo.dart index 505b5d09..48b27c34 100644 --- a/lib/widgets/elements/Form/Text/Text/demo.dart +++ b/lib/widgets/elements/Form/Text/Text/demo.dart @@ -17,6 +17,6 @@ class _Demo extends State { Duration timer = new Duration(minutes: 50); @override Widget build(BuildContext context) { - return Text("i'm a text"); + return Text("i'm a text"); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Form/Text/Text/index.dart b/lib/widgets/elements/Form/Text/Text/index.dart index 4c6586a7..6fac05a1 100644 --- a/lib/widgets/elements/Form/Text/Text/index.dart +++ b/lib/widgets/elements/Form/Text/Text/index.dart @@ -32,19 +32,16 @@ class Demo extends StatefulWidget { } class _Demo extends State { - onButtonTap() { - - } + onButtonTap() {} @override Widget build(BuildContext context) { return WidgetDemo( - title: "Text", - docUrl: 'flutter/widgets/Text-class.html', - codeUrl: 'elements/Form/Text/Text/demo.dart', - contentList: [ - intro, - TextDemo(), - ] - ); + title: "Text", + docUrl: 'flutter/widgets/Text-class.html', + codeUrl: 'elements/Form/Text/Text/demo.dart', + contentList: [ + intro, + TextDemo(), + ]); } } diff --git a/lib/widgets/elements/Form/Text/index.dart b/lib/widgets/elements/Form/Text/index.dart index f5b7eb50..40555e2f 100644 --- a/lib/widgets/elements/Form/Text/index.dart +++ b/lib/widgets/elements/Form/Text/index.dart @@ -4,16 +4,15 @@ import '../../../../model/widget.dart'; import 'RichText/index.dart' as RichText; import 'Text/index.dart' as Text; - List widgetPoints = [ - WidgetPoint( - name: 'RichText', - routerName: RichText.Demo.routeName, - buildRouter: (BuildContext context) => RichText.Demo(), - ), + WidgetPoint( + name: 'RichText', + routerName: RichText.Demo.routeName, + buildRouter: (BuildContext context) => RichText.Demo(), + ), WidgetPoint( name: 'Text', routerName: Text.Demo.routeName, buildRouter: (BuildContext context) => Text.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Form/index.dart b/lib/widgets/elements/Form/index.dart index 7a140fa3..8016383b 100644 --- a/lib/widgets/elements/Form/index.dart +++ b/lib/widgets/elements/Form/index.dart @@ -16,4 +16,4 @@ List getWidgets() { result.addAll(Slider.widgetPoints); result.addAll(Switch.widgetPoints); return result; -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Frame/Align/Align/demo.dart b/lib/widgets/elements/Frame/Align/Align/demo.dart index 98f48584..57a41ecb 100644 --- a/lib/widgets/elements/Frame/Align/Align/demo.dart +++ b/lib/widgets/elements/Frame/Align/Align/demo.dart @@ -1,9 +1,9 @@ /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Align描述 +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Align描述 import 'package:flutter/widgets.dart'; @@ -11,17 +11,17 @@ class AlignAlignment extends StatelessWidget { final Alignment status; final String dec; - const AlignAlignment( this.status, this.dec) : super(); + const AlignAlignment(this.status, this.dec) : super(); @override Widget build(BuildContext context) { - return Container( + return Container( color: Color(0xffd81b60), width: 90.0, height: 50.0, - child: Align( + child: Align( alignment: status, - child: Text( + child: Text( dec, style: TextStyle(fontSize: 12.0, color: Color(0xffffffff)), ), @@ -36,16 +36,15 @@ class AlignFactor extends StatelessWidget { final double hFactor; final String dec; - const AlignFactor( this.status, this.wFactor, - this.hFactor, this.dec) + const AlignFactor(this.status, this.wFactor, this.hFactor, this.dec) : super(); @override Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only(top: 10.0, bottom: 10.0), + return Container( + margin: EdgeInsets.only(top: 10.0, bottom: 10.0), color: Color(0xffd81b60), - child: Align( + child: Align( alignment: status, widthFactor: wFactor, heightFactor: hFactor, diff --git a/lib/widgets/elements/Frame/Align/Align/index.dart b/lib/widgets/elements/Frame/Align/Align/index.dart index 610ede29..125426f6 100644 --- a/lib/widgets/elements/Frame/Align/Align/index.dart +++ b/lib/widgets/elements/Frame/Align/Align/index.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; @@ -36,15 +35,15 @@ class _DemoState extends State { title: 'Align', codeUrl: "elements/Frame/Align/Align/demo.dart", docUrl: 'https://docs.flutter.io/flutter/widgets/Align-class.html', - contentList: [_flatText0, _alignCreate(),_flatText1,_alignCreates()], + contentList: [_flatText0, _alignCreate(), _flatText1, _alignCreates()], ); } Column _alignCreate() { - return Column( + return Column( children: [ SizedBox(height: 10.0), - Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AlignAlignment(Alignment.center, 'center'), @@ -52,7 +51,7 @@ class _DemoState extends State { ], ), SizedBox(height: 10.0), - Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AlignAlignment(Alignment.centerRight, 'centerRight'), @@ -61,7 +60,7 @@ class _DemoState extends State { ], ), SizedBox(height: 10.0), - Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ AlignAlignment(Alignment.topLeft, 'topLeft'), @@ -70,31 +69,29 @@ class _DemoState extends State { ], ), SizedBox(height: 10.0), - - ], ); } } -Column _alignCreates(){ +Column _alignCreates() { return Column( children: [ Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), - color: Color(0xffe91e63), - child: Align( - alignment: Alignment.topLeft, - child: Text( - "Align", - style: TextStyle(color: Color(0xffffffff)), - ), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + color: Color(0xffe91e63), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Align", + style: TextStyle(color: Color(0xffffffff)), ), ), - AlignFactor(Alignment.topLeft, 2.0, 2.0, 'topleft'), - AlignFactor(Alignment.topRight, null, null, 'topleft'), - AlignFactor(Alignment.center, null, null, 'center'), - AlignFactor(Alignment.bottomLeft, null, null, 'bottomLeft') + ), + AlignFactor(Alignment.topLeft, 2.0, 2.0, 'topleft'), + AlignFactor(Alignment.topRight, null, null, 'topleft'), + AlignFactor(Alignment.center, null, null, 'center'), + AlignFactor(Alignment.bottomLeft, null, null, 'bottomLeft') ], ); } diff --git a/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart b/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart index 03ceeb89..5c4f8bf5 100644 --- a/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:ConstrainedBox描述 +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:ConstrainedBox描述 import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -12,8 +12,8 @@ class ConstrainedBoxCreate extends StatelessWidget { final double currWidth; final String describe; - const ConstrainedBoxCreate({Key key,this.currWidth,this.describe}): - super(key: key); + const ConstrainedBoxCreate({Key key, this.currWidth, this.describe}) + : super(key: key); @override Widget build(BuildContext context) { @@ -27,12 +27,12 @@ class ConstrainedBoxCreate extends StatelessWidget { maxWidth: 300.0, maxHeight: 50.0, ), - child: Container( + child: Container( margin: const EdgeInsets.only(left: 20.0, right: 20.0), //child 宽高超过制定限制范围失效,效果宽/高=100/20区域 width: currWidth, height: 250.0, - child: Text( + child: Text( describe, style: TextStyle(color: Colors.white), ), diff --git a/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart b/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart index cd1d06fe..62054885 100644 --- a/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart @@ -1,7 +1,7 @@ /// Author: xiaojia.dxj -/// Date: 2019-01-08 15:56:53 +/// Date: 2019-01-08 15:56:53 /// Last Modified by: xiaojia.dxj -/// Last Modified time: 2019-01-08 15:56:53 +/// Last Modified time: 2019-01-08 15:56:53 /// email: xiaojia.dxj@alibaba-inc.com import 'package:flutter/material.dart'; @@ -61,7 +61,6 @@ class _DemoState extends State { height: 10.0, ), ConstrainedBoxCreate(currWidth: 100, describe: "currWidth=minWidth"), - ], docUrl: 'https://docs.flutter.io/flutter/widgets/ConstrainedBox-class.html', diff --git a/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart b/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart index 86da89f3..94cd956c 100644 --- a/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart @@ -20,8 +20,9 @@ class DecoratedBoxCreate extends StatelessWidget { color: const Color(0xff7c94b6), //设置图片内容 image: DecorationImage( - ///fix:BoxFit.contain: 保持图片的比例,最大程度填充容器 BoxFit.fill:容器被图片完全填充,不在意图片比例,只填充整个容器 - ///fix:BoxFit.fitWidth:图片以宽被完全填充 BoxFit.fix:fixHigth:图片以高度完全填充 + + ///fix:BoxFit.contain: 保持图片的比例,最大程度填充容器 BoxFit.fill:容器被图片完全填充,不在意图片比例,只填充整个容器 + ///fix:BoxFit.fitWidth:图片以宽被完全填充 BoxFit.fix:fixHigth:图片以高度完全填充 fit: BoxFit.cover, //图片填充整个容器,按比例放大,多余部分被裁切 image: ExactAssetImage('assets/images/food01.jpeg')), //外宽边框,可以不设置 diff --git a/lib/widgets/elements/Frame/Box/FittedBox/demo.dart b/lib/widgets/elements/Frame/Box/FittedBox/demo.dart index 084f8fe9..959ec799 100644 --- a/lib/widgets/elements/Frame/Box/FittedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/FittedBox/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/12/2 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/12/2 - /// LastUpdateBy: xj.deng - /// Describle:FittedBox +/// Author: xiaojia.dxj +/// Date: 2018/12/2 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/12/2 +/// LastUpdateBy: xj.deng +/// Describle:FittedBox import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -16,7 +16,7 @@ class FittedBoxDefault extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( + return Column( children: [ Container( //外部有位置约束,内部大小设定失效,保持和外部约束一致 diff --git a/lib/widgets/elements/Frame/Box/FittedBox/index.dart b/lib/widgets/elements/Frame/Box/FittedBox/index.dart index 74d1e25f..8bb98014 100644 --- a/lib/widgets/elements/Frame/Box/FittedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/FittedBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2019-01-08 - /// LastUpdateBy: xj.deng +/// Author: xiaojia.dxj +/// Date: 2019-01-08 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2019-01-08 +/// LastUpdateBy: xj.deng import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Box/LimitedBox/index.dart b/lib/widgets/elements/Frame/Box/LimitedBox/index.dart index 30dc8321..0890c223 100644 --- a/lib/widgets/elements/Frame/Box/LimitedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/LimitedBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:56:35 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:56:35 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:56:35 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:56:35 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Box/OverflowBox/index.dart b/lib/widgets/elements/Frame/Box/OverflowBox/index.dart index d9a26a75..4121311f 100644 --- a/lib/widgets/elements/Frame/Box/OverflowBox/index.dart +++ b/lib/widgets/elements/Frame/Box/OverflowBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:56:31 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:56:31 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:56:31 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:56:31 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Box/RotatedBox/index.dart b/lib/widgets/elements/Frame/Box/RotatedBox/index.dart index c87107d4..a35c0075 100644 --- a/lib/widgets/elements/Frame/Box/RotatedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/RotatedBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:56:13 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:56:13 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:56:13 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:56:13 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Box/SizeBox/index.dart b/lib/widgets/elements/Frame/Box/SizeBox/index.dart index 6ae1f9db..abcb4ebb 100644 --- a/lib/widgets/elements/Frame/Box/SizeBox/index.dart +++ b/lib/widgets/elements/Frame/Box/SizeBox/index.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:55:46 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:55:46 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:55:46 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:55:46 import 'package:flutter/material.dart'; @@ -30,15 +29,15 @@ class _DemoState extends State { } Column _sizeBoxCreate() { - return Column( + return Column( children: [ - Text("SizedBox", + Text("SizedBox", textAlign: TextAlign.right, style: TextStyle( fontSize: 28.0, fontWeight: FontWeight.bold, )), - Row( + Row( children: [ sizeBox.SizeBoxDefault(), SizedBox( diff --git a/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart b/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart index f69a3c0d..1d96402d 100644 --- a/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart @@ -20,7 +20,7 @@ class SizeOverflowBoxDefault extends StatelessWidget { color: Color(0xfff06292), width: 50.0, height: 50.0, - child: Text( + child: Text( text, style: TextStyle(color: Colors.white), ), diff --git a/lib/widgets/elements/Frame/Box/SizedOverflowBox/index.dart b/lib/widgets/elements/Frame/Box/SizedOverflowBox/index.dart index 2333db8c..744619bd 100644 --- a/lib/widgets/elements/Frame/Box/SizedOverflowBox/index.dart +++ b/lib/widgets/elements/Frame/Box/SizedOverflowBox/index.dart @@ -1,10 +1,9 @@ +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:55:31 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:55:31 - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:55:31 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:55:31 - import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; @@ -55,7 +54,7 @@ class _DemoState extends State { } Column _sizedOverflowBoxCreate() { - return Column( + return Column( children: [ SizeBoxDefault( curWidth: 200.0, @@ -63,13 +62,13 @@ class _DemoState extends State { ), SizedBox(height: 20.0), Container( - margin: EdgeInsets.only(top: 10.0), + margin: EdgeInsets.only(top: 10.0), color: Color(0xffd81b60), width: 200.0, height: 50.0, ), Container( - margin: EdgeInsets.only(top: 10.0), + margin: EdgeInsets.only(top: 10.0), color: Color(0xffd81b60), alignment: Alignment.topCenter, width: 200.0, @@ -79,7 +78,7 @@ class _DemoState extends State { ), ), Container( - margin: EdgeInsets.only(top: 10.0), + margin: EdgeInsets.only(top: 10.0), color: Color(0xffd81b60), width: 200.0, height: 50.0, @@ -90,7 +89,7 @@ class _DemoState extends State { ), ), Container( - margin: EdgeInsets.only(top: 10.0), + margin: EdgeInsets.only(top: 10.0), color: Color(0xffd81b60), width: 200.0, height: 50.0, diff --git a/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart b/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart index 0a62c64f..223c260d 100644 --- a/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart @@ -6,7 +6,7 @@ class UnconstrainedBoxDemo extends StatelessWidget { return UnconstrainedBox( constrainedAxis: Axis.vertical, textDirection: TextDirection.rtl, - child: Row( + child: Row( children: [ Container( width: 100.0, diff --git a/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart b/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart index b37fd267..841af7af 100644 --- a/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart @@ -1,10 +1,9 @@ +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:57:00 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 16:00:14 - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:57:00 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 16:00:14 - import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; diff --git a/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart b/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart index 24075553..982cd0c4 100644 --- a/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart +++ b/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart @@ -1,69 +1,86 @@ -/// @Author: 一凨 -/// @Date: 2018-11-28 20:09:40 +/// @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 { - final TextStyle txtColor = TextStyle(color: Colors.white); @override Widget build(BuildContext context) { return Column( children: [ Text('Expanded'), - Row(children: [ - RaisedButton( + Row(children: [ + RaisedButton( onPressed: () { print('点击红色按钮事件'); }, color: const Color(0xffcc0000), - child: Text('红色按钮',style: txtColor,), + child: Text( + '红色按钮', + style: txtColor, + ), ), - Expanded( - flex: 1,//flex用来设置当前可用空间的占优比 - child: RaisedButton( + Expanded( + flex: 1, //flex用来设置当前可用空间的占优比 + child: RaisedButton( onPressed: () { print('点击黄色按钮事件'); }, color: const Color(0xfff1c232), - child: Text('黄色按钮',style: txtColor,), + child: Text( + '黄色按钮', + style: txtColor, + ), ), ), - RaisedButton( + RaisedButton( onPressed: () { print('点击粉色按钮事件'); }, color: const Color(0xffea9999), - child: Text('粉色按钮',style: txtColor,), + child: Text( + '粉色按钮', + style: txtColor, + ), ), ]), Text('Flexible'), - Row(children: [ - RaisedButton( + Row(children: [ + RaisedButton( onPressed: () { print('点击红色按钮事件'); }, color: const Color(0xffcc0000), - child: Text('红色按钮',style: txtColor,), + child: Text( + '红色按钮', + style: txtColor, + ), ), - Flexible( + Flexible( flex: 1, - child: RaisedButton( + child: RaisedButton( onPressed: () { print('点击黄色按钮事件'); }, color: const Color(0xfff1c232), - child: Text('黄色按钮',style: txtColor,), + child: Text( + '黄色按钮', + style: txtColor, + ), ), ), - RaisedButton( + RaisedButton( onPressed: () { print('点击粉色按钮事件'); }, color: const Color(0xffea9999), - child: Text('粉色按钮',style: txtColor,), + child: Text( + '粉色按钮', + style: txtColor, + ), ), ]), ], diff --git a/lib/widgets/elements/Frame/Layout/Center/index.dart b/lib/widgets/elements/Frame/Layout/Center/index.dart index 42c2bc9c..d3b40169 100644 --- a/lib/widgets/elements/Frame/Layout/Center/index.dart +++ b/lib/widgets/elements/Frame/Layout/Center/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:57:00 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 16:00:14 - +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:57:00 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 16:00:14 + import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Column/demo.dart b/lib/widgets/elements/Frame/Layout/Column/demo.dart index e1c5a28e..7935ca30 100644 --- a/lib/widgets/elements/Frame/Layout/Column/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Column/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Colum describe +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Colum describe import 'package:flutter/widgets.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Column/index.dart b/lib/widgets/elements/Frame/Layout/Column/index.dart index 34d73786..50ba0ade 100644 --- a/lib/widgets/elements/Frame/Layout/Column/index.dart +++ b/lib/widgets/elements/Frame/Layout/Column/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Colum describe +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Colum describe import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Container/demo.dart b/lib/widgets/elements/Frame/Layout/Container/demo.dart index c09965c8..fd4e00b3 100644 --- a/lib/widgets/elements/Frame/Layout/Container/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Container/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Colum describe +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Colum describe import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Container/index.dart b/lib/widgets/elements/Frame/Layout/Container/index.dart index 86848cb7..4e97ebdc 100644 --- a/lib/widgets/elements/Frame/Layout/Container/index.dart +++ b/lib/widgets/elements/Frame/Layout/Container/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Colum describe +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Colum describe import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Layout/Row/demo.dart b/lib/widgets/elements/Frame/Layout/Row/demo.dart index 7e26823b..89942f34 100644 --- a/lib/widgets/elements/Frame/Layout/Row/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Row/demo.dart @@ -1,13 +1,14 @@ - import 'package:flutter/material.dart'; +import 'package:flutter/material.dart'; + /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Row +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Row import 'package:flutter/widgets.dart'; - + class RowMainAxisAlignment extends StatelessWidget { //> mainAxisAlignment属性 // - MainAxisAlignment.spaceEvenly/spaceAround/spaceBetween, @@ -34,7 +35,7 @@ class RowMainAxisAlignment extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( + return Row( mainAxisAlignment: status, children: [ Container( @@ -62,29 +63,29 @@ class RowLayoutCreate extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( + return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), color: Color(0xfffce4ec), width: 60.0, height: 50.0, ), Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), color: Color(0xfff8bbd0), width: 60.0, height: 50.0, ), Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), color: Color(0xfff48fb1), width: 60.0, height: 50.0, ), Container( - margin: EdgeInsets.only(top: 20.0, bottom: 20.0), + margin: EdgeInsets.only(top: 20.0, bottom: 20.0), color: Color(0xfff06292), width: 60.0, height: 50.0, @@ -94,33 +95,40 @@ class RowLayoutCreate extends StatelessWidget { } } -class RowExpanded extends StatelessWidget{ +class RowExpanded extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( children: [ ////填充数据 - Expanded(child: new RaisedButton( - onPressed: (){ - }, - color: Color(0xfffce4ec), - child:new Text('flutter',style: TextStyle(color: Colors.white),) - ),), - Expanded(child: new RaisedButton( - onPressed: (){ - }, - color: Color(0xfff8bbd0), - child:new Text('Expanded',style: TextStyle(color: Colors.white),) - ),), - Expanded(child: new RaisedButton( - onPressed: (){ - }, - color: Color(0xfff48fb1), - child:new Text('flutter',style: TextStyle(color: Colors.white),) - ),), + Expanded( + child: new RaisedButton( + onPressed: () {}, + color: Color(0xfffce4ec), + child: new Text( + 'flutter', + style: TextStyle(color: Colors.white), + )), + ), + Expanded( + child: new RaisedButton( + onPressed: () {}, + color: Color(0xfff8bbd0), + child: new Text( + 'Expanded', + style: TextStyle(color: Colors.white), + )), + ), + Expanded( + child: new RaisedButton( + onPressed: () {}, + color: Color(0xfff48fb1), + child: new Text( + 'flutter', + style: TextStyle(color: Colors.white), + )), + ), ], ); } - } diff --git a/lib/widgets/elements/Frame/Layout/Row/index.dart b/lib/widgets/elements/Frame/Layout/Row/index.dart index 4ebb6f8f..33d9bef2 100644 --- a/lib/widgets/elements/Frame/Layout/Row/index.dart +++ b/lib/widgets/elements/Frame/Layout/Row/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:Row +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:Row import 'package:flutter/material.dart'; @@ -57,10 +57,12 @@ class _DemoState extends State { } Column _rowCreate() { - return Column( + return Column( children: [ RowLayoutCreate(), - SizedBox(height: 10.0,), + SizedBox( + height: 10.0, + ), RowExpanded(), Row( children: [ diff --git a/lib/widgets/elements/Frame/Layout/index.dart b/lib/widgets/elements/Frame/Layout/index.dart index b936fa00..387978dd 100644 --- a/lib/widgets/elements/Frame/Layout/index.dart +++ b/lib/widgets/elements/Frame/Layout/index.dart @@ -22,7 +22,7 @@ List widgetPoints = [ routerName: Container.Demo.routeName, buildRouter: (BuildContext context) => Container.Demo(), ), - WidgetPoint( + WidgetPoint( name: 'Center', routerName: Center.Demo.routeName, buildRouter: (BuildContext context) => Center.Demo(), diff --git a/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart index 93bea0eb..b26e8b7d 100644 --- a/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart +++ b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:42:40 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-28 20:42:40 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:42:40 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-28 20:42:40 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart index 623bca26..f9058900 100644 --- a/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart +++ b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:44:13 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-14 17:02:20 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:44:13 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-14 17:02:20 import 'package:flutter/material.dart'; @@ -37,7 +37,8 @@ class _DemoState extends State { ], docUrl: 'https://docs.flutter.io/flutter/widgets/AnimatedPadding-class.html', - codeUrl: 'elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart', + codeUrl: + 'elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart', ); } } diff --git a/lib/widgets/elements/Frame/Spacing/Padding/index.dart b/lib/widgets/elements/Frame/Spacing/Padding/index.dart index 82233cd7..0b0d6d10 100644 --- a/lib/widgets/elements/Frame/Spacing/Padding/index.dart +++ b/lib/widgets/elements/Frame/Spacing/Padding/index.dart @@ -1,26 +1,27 @@ - /// Author: 一凨 - /// Date: 2018-11-28 20:25:24 - /// Last Modified by: 一凨 - /// Last Modified time: 2019-01-14 17:01:55 +/// Author: 一凨 +/// Date: 2018-11-28 20:25:24 +/// Last Modified by: 一凨 +/// Last Modified time: 2019-01-14 17:01:55 import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './padding_demo.dart'; -const contentDesc0=''' +const contentDesc0 = ''' ### **简介** > widget 内边距 - 类似于前端中的 div+css:padding 效果 - Container + padding = Padding '''; -const contentDesc1 = ''' +const contentDesc1 = ''' ### **基本用法** > Padding widget 的padding必须设置,不能为null - 通过给定的padding值来隔开子组件 - 通过EdgeInsets 类来计算 padding的大小 '''; + class Demo extends StatefulWidget { static const String routeName = '/element/Frame/spacing/Padding'; _DemoState createState() => _DemoState(); @@ -31,14 +32,9 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( title: 'Padding', - contentList: [ - contentDesc0, - contentDesc1, - PaddingDemo() - ], + contentList: [contentDesc0, contentDesc1, PaddingDemo()], docUrl: 'https://docs.flutter.io/flutter/widgets/Padding-class.html', - codeUrl: - 'elements/Frame/Spacing/Padding/padding_demo.dart', + codeUrl: 'elements/Frame/Spacing/Padding/padding_demo.dart', ); } } diff --git a/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart b/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart index 6721d366..d5236c51 100644 --- a/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart +++ b/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:20:04 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-14 16:30:16 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:20:04 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-14 16:30:16 import 'package:flutter/material.dart'; @@ -11,7 +11,7 @@ class PaddingDemo extends StatelessWidget { return Container( color: Colors.blueAccent, child: Padding( - padding: const EdgeInsets.all(18.0),//通过 EdgeInsets 来设置 padding的值 + padding: const EdgeInsets.all(18.0), //通过 EdgeInsets 来设置 padding的值 child: Container( height: 100.0, width: 100.0, diff --git a/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart index e836f35c..1136383d 100644 --- a/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart +++ b/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:26:16 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-14 17:06:36 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:26:16 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-14 17:06:36 import 'package:flutter/material.dart'; @@ -43,6 +43,4 @@ class _DemoState extends State { 'https://docs.flutter.io/flutter/widgets/SliverPadding-class.html', ); } - - } diff --git a/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart index 0c802382..f26e2d02 100644 --- a/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart +++ b/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart @@ -1,5 +1,3 @@ - - class ProductItem { final String name; final String tag; diff --git a/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart index db0fe909..449ea6ae 100644 --- a/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart +++ b/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart @@ -1,70 +1,66 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:36:17 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-28 20:36:17 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:36:17 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-28 20:36:17 import 'package:flutter/material.dart'; import 'package:flutter_go/widgets/components/Scroll/CustomScrollView/product_list.dart'; class SliverPaddingDemo extends StatelessWidget { - - - Widget _buildItem(BuildContext context,ProductItem product){ - return Container( + Widget _buildItem(BuildContext context, ProductItem product) { + return Container( height: 100.0, margin: const EdgeInsets.only(bottom: 5.0), padding: const EdgeInsets.only(left: 10.0), color: Colors.blueGrey, - child: Stack( - alignment: AlignmentDirectional.centerStart, - children: [ - Positioned( - right: 40.0, - child: Card( - child: Center( - child: Text( - product.name, - style: Theme.of(context).textTheme.title, - textAlign: TextAlign.center, - ), + child: Stack( + alignment: AlignmentDirectional.centerStart, + children: [ + Positioned( + right: 40.0, + child: Card( + child: Center( + child: Text( + product.name, + style: Theme.of(context).textTheme.title, + textAlign: TextAlign.center, ), - )), - ClipRRect( - child: SizedBox( - width: 70.0, - height: 70.0, - child: Image.asset( - product.asset, - fit: BoxFit.cover, ), + )), + ClipRRect( + child: SizedBox( + width: 70.0, + height: 70.0, + child: Image.asset( + product.asset, + fit: BoxFit.cover, ), - borderRadius: BorderRadius.all(Radius.circular(8.0)), ), - ], - ), + borderRadius: BorderRadius.all(Radius.circular(8.0)), + ), + ], + ), ); } @override Widget build(BuildContext context) { - return CustomScrollView( - shrinkWrap: true, - slivers: [ - SliverPadding( - padding: const EdgeInsets.fromLTRB(50.0,10.0,20.0,0.0), - sliver: SliverList( - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { + return CustomScrollView( + shrinkWrap: true, + slivers: [ + SliverPadding( + padding: const EdgeInsets.fromLTRB(50.0, 10.0, 20.0, 0.0), + sliver: SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { return _buildItem(context, products[index]); }, childCount: products.length, ), - ), - ) - ], - ); + ), + ) + ], + ); } - - -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart b/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart index bfc83c8c..76227266 100644 --- a/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart +++ b/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:indexedStack +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:indexedStack import 'package:flutter/material.dart'; @@ -28,7 +28,7 @@ class StackDefault extends StatelessWidget { // fit: BoxFit.cover, // ), CircleAvatar( - backgroundColor: Color(0xfff48fb1), + backgroundColor: Color(0xfff48fb1), radius: 40.0, ), Container( @@ -59,27 +59,27 @@ class StackIndex extends StatelessWidget { return IndexedStack( index: currIndex, children: [ - Icon( + Icon( Icons.update, size: 40.0, color: Color(0xffe91e63), ), - Icon( + Icon( Icons.access_alarm, size: 40.0, color: Color(0xffe91e63), ), - Icon( + Icon( Icons.add_alarm, size: 40.0, color: Color(0xffe91e63), ), - Icon( + Icon( Icons.access_time, size: 40.0, color: Color(0xffe91e63), ), - Icon( + Icon( Icons.alarm_off, size: 40.0, color: Color(0xffe91e63), diff --git a/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart b/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart index da85006c..77b8233b 100644 --- a/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart +++ b/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart @@ -1,9 +1,9 @@ - /// Author: xiaojia.dxj - /// Date: 2019-01-08 15:57:00 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 16:00:14 - +/// Author: xiaojia.dxj +/// Date: 2019-01-08 15:57:00 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 16:00:14 + import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; @@ -56,20 +56,20 @@ class _DemoState extends State { } Column _indexedStackCreate() { - return Column( + return Column( children: [ SizedBox( height: 10.0, ), - Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( - color: Color(0xffe91e63), + color: Color(0xffe91e63), child: StackDefault(0), ), Container( - color: Color(0xffe91e63), + color: Color(0xffe91e63), child: StackDefault(1), ) ], @@ -77,7 +77,7 @@ class _DemoState extends State { SizedBox( height: 10.0, ), - Row( + Row( mainAxisAlignment: MainAxisAlignment.center, children: [ StackIndex(0), @@ -97,7 +97,7 @@ class _DemoState extends State { onPressed: () { _indexAdd(); }, - icon: Icon(Icons.adb), + icon: Icon(Icons.adb), label: Text("点击这里")), StackIndex(currIndex) ], diff --git a/lib/widgets/elements/Frame/Stack/Stack/demo.dart b/lib/widgets/elements/Frame/Stack/Stack/demo.dart index b1a72425..1dd5441f 100644 --- a/lib/widgets/elements/Frame/Stack/Stack/demo.dart +++ b/lib/widgets/elements/Frame/Stack/Stack/demo.dart @@ -1,10 +1,10 @@ - /// Author: xiaojia.dxj - /// Date: 2018/11/22 - /// Email: xiaojia.dxj@alibaba-inc.com - /// LastUpdateTime: 2018/11/22 - /// LastUpdateBy: xj.deng - /// Describle:stack描述 - +/// Author: xiaojia.dxj +/// Date: 2018/11/22 +/// Email: xiaojia.dxj@alibaba-inc.com +/// LastUpdateTime: 2018/11/22 +/// LastUpdateBy: xj.deng +/// Describle:stack描述 + import 'package:flutter/material.dart'; class StackDefault extends StatelessWidget { @@ -14,19 +14,19 @@ class StackDefault extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - Stack( + Stack( //fit :定义如何设置non-positioned节点尺寸 fit: StackFit.loose, overflow: Overflow.clip, textDirection: TextDirection.ltr, alignment: Alignment.center, children: [ - Container( - color: Color(0xfff48fb1), + Container( + color: Color(0xfff48fb1), width: 100.0, height: 50.0, ), - Text("stack demo", + Text("stack demo", textDirection: TextDirection.ltr, style: TextStyle( fontSize: 20.0, @@ -47,22 +47,22 @@ class StackDefault2 extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - Stack( + Stack( //fit :定义如何设置non-positioned节点尺寸 fit: StackFit.loose, overflow: Overflow.clip, textDirection: TextDirection.ltr, alignment: Alignment.center, children: [ - Text("stack demo", + Text("stack demo", textDirection: TextDirection.ltr, style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, letterSpacing: 5.0, color: Colors.white)), - Container( - color: Color(0xfff48fb1), + Container( + color: Color(0xfff48fb1), width: 100.0, height: 50.0, ), @@ -78,32 +78,32 @@ class StackPositioned extends StatelessWidget { @override Widget build(BuildContext context) { - return Stack( + return Stack( alignment: Alignment.center, children: [ - Positioned( - child: Icon( + Positioned( + child: Icon( Icons.monetization_on, size: 40.0, color: Colors.yellow[300], )), - Positioned( + Positioned( left: 40.0, - child: Icon( + child: Icon( Icons.monetization_on, size: 40.0, color: Colors.yellow[600], )), - Positioned( + Positioned( left: 60.0, - child: Icon( + child: Icon( Icons.monetization_on, size: 40.0, color: Colors.yellow[600], )), - Positioned( + Positioned( left: 80.0, - child: Icon( + child: Icon( Icons.monetization_on, size: 40.0, color: Colors.yellow[600], @@ -118,12 +118,12 @@ class StackLayout extends StatelessWidget { @override Widget build(BuildContext context) { - return Stack( + return Stack( overflow: Overflow.visible, alignment: const Alignment(0.2, 0.6), children: [ CircleAvatar( - backgroundColor: Color(0xfff48fb1), + backgroundColor: Color(0xfff48fb1), radius: 140.0, ), Container( diff --git a/lib/widgets/elements/Frame/Stack/Stack/index.dart b/lib/widgets/elements/Frame/Stack/Stack/index.dart index 6787abd6..90dc530a 100644 --- a/lib/widgets/elements/Frame/Stack/Stack/index.dart +++ b/lib/widgets/elements/Frame/Stack/Stack/index.dart @@ -46,18 +46,18 @@ class _DemoState extends State { _stackText0, _stackCreate(), _stackText1, - Container( + Container( width: 300.0, height: 100.0, - margin: EdgeInsets.only(top: 10.0, bottom: 10.0), - color: Color(0xffe91e63), + margin: EdgeInsets.only(top: 10.0, bottom: 10.0), + color: Color(0xffe91e63), child: StackPositioned(), ), _stackText2, - Container( + Container( width: 200.0, height: 200.0, - color: Color(0xffe91e63), + color: Color(0xffe91e63), child: StackLayout(), ), ], @@ -65,18 +65,18 @@ class _DemoState extends State { } Column _stackCreate() { - return Column( + return Column( children: [ Column( children: [ - Container( - margin: EdgeInsets.only(top: 10.0, bottom: 10.0), + Container( + margin: EdgeInsets.only(top: 10.0, bottom: 10.0), width: 300.0, height: 100.0, color: Color(0xffe91e63), child: StackDefault(), ), - Container( + Container( width: 300.0, height: 100.0, color: Color(0xffe91e63), diff --git a/lib/widgets/elements/Frame/Table/Table/index.dart b/lib/widgets/elements/Frame/Table/Table/index.dart index 7706c69d..aa5b0426 100644 --- a/lib/widgets/elements/Frame/Table/Table/index.dart +++ b/lib/widgets/elements/Frame/Table/Table/index.dart @@ -15,6 +15,7 @@ const contentDesc1 = ''' - 表格中行的大小是根据列行数和宽度计算的来,控制列宽可以使用 columnWidth 属性 - 注意,Table中每一行的列数需要一致,否则报错 '''; + class Demo extends StatefulWidget { static const String routeName = '/element/Frame/Table/Table'; _DemoState createState() => _DemoState(); @@ -25,8 +26,7 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( title: 'Table', - codeUrl: - 'elements/Frame/Table/Table/table_demo.dart', + codeUrl: 'elements/Frame/Table/Table/table_demo.dart', contentList: [ contentDesc0, contentDesc1, diff --git a/lib/widgets/elements/Frame/Table/Table/table_demo.dart b/lib/widgets/elements/Frame/Table/Table/table_demo.dart index 9d81d71e..beb89d0d 100644 --- a/lib/widgets/elements/Frame/Table/Table/table_demo.dart +++ b/lib/widgets/elements/Frame/Table/Table/table_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-28 20:52:35 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-28 20:59:50 +/// @Author: 一凨 +/// @Date: 2018-11-28 20:52:35 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-28 20:59:50 import 'package:flutter/material.dart'; @@ -9,8 +9,8 @@ class TableDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - margin:const EdgeInsets.only(top: 10.0), - child:Table( + margin: const EdgeInsets.only(top: 10.0), + child: Table( columnWidths: const { 0: FixedColumnWidth(50.0), 1: FixedColumnWidth(100.0), @@ -48,4 +48,4 @@ class TableDemo extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Frame/index.dart b/lib/widgets/elements/Frame/index.dart index 25348967..02c378be 100644 --- a/lib/widgets/elements/Frame/index.dart +++ b/lib/widgets/elements/Frame/index.dart @@ -6,7 +6,6 @@ import 'Layout/index.dart' as Layout; import 'Stack/index.dart' as Stack; import 'Box/index.dart' as Box; - List getWidgets() { List result = []; result.addAll(Spacing.widgetPoints); diff --git a/lib/widgets/elements/Media/Canvas/Canvas/demo.dart b/lib/widgets/elements/Media/Canvas/Canvas/demo.dart index eee36df0..355a2297 100644 --- a/lib/widgets/elements/Media/Canvas/Canvas/demo.dart +++ b/lib/widgets/elements/Media/Canvas/Canvas/demo.dart @@ -18,9 +18,8 @@ CustomPaint graph; var image; class CustomViewPage extends StatefulWidget { - final String type; - CustomViewPage({this.type='drawLine'}) : super(); + CustomViewPage({this.type = 'drawLine'}) : super(); @override State createState() => CustomViewPageState(); @@ -28,7 +27,6 @@ class CustomViewPage extends StatefulWidget { class CustomViewPageState extends State with SingleTickerProviderStateMixin { - static Future getImage(String asset) async { ByteData data = await rootBundle.load(asset); Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List()); @@ -50,9 +48,7 @@ class CustomViewPageState extends State @override Widget build(BuildContext context) { - graph = CustomPaint( - painter: DrawPainter(type:widget.type) - ); + graph = CustomPaint(painter: DrawPainter(type: widget.type)); return Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width * 0.6, @@ -60,10 +56,9 @@ class CustomViewPageState extends State //padding: EdgeInsets.all(10.0), child: graph //child:Center(child: graph) - ); + ); } - @override void reassemble() { super.reassemble(); @@ -80,7 +75,7 @@ class DrawPainter extends CustomPainter { Paint painter; final type; - DrawPainter ({this.type}){ + DrawPainter({this.type}) { // Paint painter = Paint() // ..color = Colors.blueAccent //画笔颜色 // ..strokeCap = StrokeCap.round //画笔笔触类型 @@ -100,69 +95,93 @@ class DrawPainter extends CustomPainter { ..filterQuality = FilterQuality.high ..style = PaintingStyle.stroke; } + ///Flutter中负责View绘制的地方,使用传递来的canvas和size即可完成对目标View的绘制 @override void paint(Canvas canvas, Size size) { - switch(type) { + switch (type) { case 'drawPoints': - const List points1 = [Offset(20.0, 0.0), Offset(100.0, 50.0), Offset(150.0, 0.0),Offset(300.0, 0.0)]; - const List points2 = [Offset(20.0, 100.0), Offset(100.0, 100.0), Offset(150.0, 100.0), Offset(300.0, 100.0)]; - const List points3 = [Offset(20.0, 150.0), Offset(100.0, 150.0), Offset(150.0, 180.0), Offset(300.0, 150.0)]; + const List points1 = [ + Offset(20.0, 0.0), + Offset(100.0, 50.0), + Offset(150.0, 0.0), + Offset(300.0, 0.0) + ]; + const List points2 = [ + Offset(20.0, 100.0), + Offset(100.0, 100.0), + Offset(150.0, 100.0), + Offset(300.0, 100.0) + ]; + const List points3 = [ + Offset(20.0, 150.0), + Offset(100.0, 150.0), + Offset(150.0, 180.0), + Offset(300.0, 150.0) + ]; //绘制点 canvas.drawPoints( + ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) PointMode.points, points1, - painter..color = Colors.redAccent // 这里可以追加修改 painter 属性 - ..strokeWidth = 10.0 - ); + painter + ..color = Colors.redAccent // 这里可以追加修改 painter 属性 + ..strokeWidth = 10.0); canvas.drawPoints( - ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) + + ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) PointMode.lines, points2, - painter..color = Colors.orange // 这里可以追加修改 painter 属性 - ..strokeWidth = 10.0 - ); + painter + ..color = Colors.orange // 这里可以追加修改 painter 属性 + ..strokeWidth = 10.0); canvas.drawPoints( - ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) + + ///PointMode的枚举类型有三个,points(点),lines(线,隔点连接),polygon(线,相邻连接) PointMode.polygon, points3, - painter..color = Colors.blue // 这里可以追加修改 painter 属性 - ..strokeWidth = 10.0 - ); + painter + ..color = Colors.blue // 这里可以追加修改 painter 属性 + ..strokeWidth = 10.0); break; case 'drawLine': //绘制直线 - canvas.drawLine(Offset(20.0, 0.0), Offset(size.width*0.8, 200), painter ..color = Colors.redAccent); + canvas.drawLine(Offset(20.0, 0.0), Offset(size.width * 0.8, 200), + painter..color = Colors.redAccent); break; case 'rawCircle': //绘制圆 参数(圆心,半径,画笔) canvas.drawCircle( - Offset(size.width/2, 100.0), - 100.0, - painter - ..color = Colors.greenAccent - ..style = PaintingStyle.stroke //绘画风格改为stroke - ); + Offset(size.width / 2, 100.0), + 100.0, + painter + ..color = Colors.greenAccent + ..style = PaintingStyle.stroke //绘画风格改为stroke + ); break; case 'drawOval': // 绘制椭圆 // 使用左上和右下角坐标来确定矩形的大小和位置,椭圆是在这个矩形之中内切的形状 - Rect rect1 = Rect.fromPoints(Offset(0.0, 0.0), Offset(size.width, 200.0)); - canvas.drawOval(rect1, painter ..color = Colors.indigo); + Rect rect1 = + Rect.fromPoints(Offset(0.0, 0.0), Offset(size.width, 200.0)); + canvas.drawOval(rect1, painter..color = Colors.indigo); break; case 'drawArc': // 绘制圆弧 // Rect来确认圆弧的位置,还需要开始的弧度、结束的弧度、是否使用中心点绘制、以及paint弧度 const PI = 3.1415926; Rect rect1 = Rect.fromCircle(center: Offset(20, 50.0), radius: 100.0); - canvas.drawArc(rect1, 0.0, PI / 2, false, painter ..color = Colors.pink); + canvas.drawArc(rect1, 0.0, PI / 2, false, painter..color = Colors.pink); - Rect rect2 = Rect.fromCircle(center: Offset(size.width*0.6, 50.0), radius: 100.0); - canvas.drawArc(rect2, 0.0, PI / 2, true, painter ..color = Colors.deepPurple); + Rect rect2 = Rect.fromCircle( + center: Offset(size.width * 0.6, 50.0), radius: 100.0); + canvas.drawArc( + rect2, 0.0, PI / 2, true, painter..color = Colors.deepPurple); break; case 'drawRRect': + /// fromPoints(Offset a, Offset b) /// 使用左上和右下角坐标来确定矩形的大小和位置 /// fromCircle({ Offset center, double radius }) @@ -173,7 +192,8 @@ class DrawPainter extends CustomPainter { /// 使用矩形左边的X坐标、矩形顶部的Y坐标矩形的宽高来确定矩形的大小和位置 // 用Rect构建一个边长50,中心点坐标为50,100的矩形 Rect rect1 = Rect.fromCircle(center: Offset(80.0, 100.0), radius: 50.0); - Rect rect2 = Rect.fromCircle(center: Offset(250.0, 100.0), radius: 50.0); + Rect rect2 = + Rect.fromCircle(center: Offset(250.0, 100.0), radius: 50.0); // 根据上面的矩形,构建一个圆角矩形 RRect rrect1 = RRect.fromRectAndRadius(rect1, Radius.circular(0.0)); canvas.drawRRect(rrect1, painter); @@ -182,12 +202,14 @@ class DrawPainter extends CustomPainter { break; case 'drawDRRect': //绘制两个矩形 - Rect rect1 = Rect.fromCircle(center: Offset(size.width/2, 100.0), radius: 60.0); - Rect rect2 = Rect.fromCircle(center: Offset(size.width/2, 100.0), radius: 40.0); + Rect rect1 = Rect.fromCircle( + center: Offset(size.width / 2, 100.0), radius: 60.0); + Rect rect2 = Rect.fromCircle( + center: Offset(size.width / 2, 100.0), radius: 40.0); //分别绘制外部圆角矩形和内部的圆角矩形 RRect outer = RRect.fromRectAndRadius(rect1, Radius.circular(30.0)); RRect inner = RRect.fromRectAndRadius(rect2, Radius.circular(5.0)); - canvas.drawDRRect(outer, inner, painter ..color = Colors.lime); + canvas.drawDRRect(outer, inner, painter..color = Colors.lime); break; case 'drawImage': // canvas.drawImage(image, Offset(0.0, 0.0), painter); @@ -197,40 +219,48 @@ class DrawPainter extends CustomPainter { break; case 'drawStar': var rect = Offset.zero & size; + /// 背景颜色 canvas.drawRect(rect, Paint()..color = Color(0xFF000000)); + /// 绘制星形 - canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(50.0, 50.0)), painter..color = Colors.red); + canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(50.0, 50.0)), + painter..color = Colors.red); + /// 绘制多边形 - canvas.save();// save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 + canvas.save(); // save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 canvas.translate(0, 100); - canvas.scale(1.2,1.2); - canvas.drawPath(MathTools().nStarPath(4, 30, 30, Offset(40.0, 50.0)), painter); - canvas.restore();// 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 + canvas.scale(1.2, 1.2); + canvas.drawPath( + MathTools().nStarPath(4, 30, 30, Offset(40.0, 50.0)), painter); + canvas.restore(); // 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 /// 绘制旋转星形 - canvas.save();// save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 + canvas.save(); // save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 canvas.translate(150, 50); canvas.rotate(50 * pi / 180); - canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(0,0)), painter..color = Colors.green); - canvas.restore();// 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 + canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(0, 0)), + painter..color = Colors.green); + canvas.restore(); // 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 /// 绘制变形星形 - canvas.save();// save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 + canvas.save(); // save之后,可以调用Canvas的平移、放缩、旋转、错切、裁剪等操作 canvas.translate(80, 100); - canvas.skew(0.5,0.2); - canvas.drawPath(MathTools().regularStarPath(6, 30,Offset(50,50)), painter..color = Colors.lime); - canvas.restore();// 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 + canvas.skew(0.5, 0.2); + canvas.drawPath(MathTools().regularStarPath(6, 30, Offset(50, 50)), + painter..color = Colors.lime); + canvas.restore(); // 用来恢复Canvas之前保存的状态。防止save后对Canvas执行的操作对后续的绘制有影响 /// 绘制matrix星形 canvas.translate(250, 0); Float64List matrix = Float64List.fromList(const [ // careful, this is in _column_-major order - 0.7, -0.7, 0.0, 0.0, - 0.7, 0.7, 0.0, 0.0, - 0.7, 0.0, 1.0, 0.0, - -70.697, 98.057, 0.0, 1.0, + 0.7, -0.7, 0.0, 0.0, + 0.7, 0.7, 0.0, 0.0, + 0.7, 0.0, 1.0, 0.0, + -70.697, 98.057, 0.0, 1.0, ]); canvas.transform(matrix); - canvas.drawPath(MathTools().regularStarPath(5, 30,Offset(50,50)), painter..color = Colors.blue); + canvas.drawPath(MathTools().regularStarPath(5, 30, Offset(50, 50)), + painter..color = Colors.blue); break; } @@ -248,7 +278,7 @@ class MathTools { static MathTools _mathTools; static bool _flag; - factory MathTools(){ + factory MathTools() { if (_flag == null) { _flag = true; } @@ -259,6 +289,7 @@ class MathTools { return _mathTools; } MathTools._internal(); + /// ///画正n角星的路径: /// @@ -308,14 +339,15 @@ class MathTools { path.moveTo(cos(_rad(degA)) * R + xy.dx, (-sin(_rad(degA)) * R + xy.dy)); for (int i = 0; i < num; i++) { - path.lineTo( - cos(_rad(degA + perDeg * i)) * R + xy.dx, -sin(_rad(degA + perDeg * i)) * R + xy.dy); - path.lineTo( - cos(_rad(degB + perDeg * i)) * r + xy.dx, -sin(_rad(degB + perDeg * i)) * r + xy.dy); + path.lineTo(cos(_rad(degA + perDeg * i)) * R + xy.dx, + -sin(_rad(degA + perDeg * i)) * R + xy.dy); + path.lineTo(cos(_rad(degB + perDeg * i)) * r + xy.dx, + -sin(_rad(degB + perDeg * i)) * r + xy.dy); } path.close(); return path; } + double _rad(double deg) { return deg * pi / 180; } diff --git a/lib/widgets/elements/Media/Canvas/Canvas/index.dart b/lib/widgets/elements/Media/Canvas/Canvas/index.dart index 3e6cda7e..2e64c5f8 100644 --- a/lib/widgets/elements/Media/Canvas/Canvas/index.dart +++ b/lib/widgets/elements/Media/Canvas/Canvas/index.dart @@ -72,23 +72,23 @@ class _DemoState extends State { Text, Text1, Text2, - demoBoxs.CustomViewPage(type:'drawPoints'), + demoBoxs.CustomViewPage(type: 'drawPoints'), Text3, - demoBoxs.CustomViewPage(type:'drawLine'), + demoBoxs.CustomViewPage(type: 'drawLine'), Text4, - demoBoxs.CustomViewPage(type:'rawCircle'), + demoBoxs.CustomViewPage(type: 'rawCircle'), Text5, - demoBoxs.CustomViewPage(type:'drawOval'), + demoBoxs.CustomViewPage(type: 'drawOval'), Text6, - demoBoxs.CustomViewPage(type:'drawArc'), + demoBoxs.CustomViewPage(type: 'drawArc'), Text7, - demoBoxs.CustomViewPage(type:'drawRRect'), + demoBoxs.CustomViewPage(type: 'drawRRect'), Text8, - demoBoxs.CustomViewPage(type:'drawDRRect'), + demoBoxs.CustomViewPage(type: 'drawDRRect'), Text9, - demoBoxs.CustomViewPage(type:'drawImage'), + demoBoxs.CustomViewPage(type: 'drawImage'), Text10, - demoBoxs.CustomViewPage(type:'drawStar'), + demoBoxs.CustomViewPage(type: 'drawStar'), ], docUrl: 'https://docs.flutter.io/flutter/dart-ui/Canvas-class.html', ); diff --git a/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/demo.dart b/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/demo.dart index 432e4f16..5d49fee7 100644 --- a/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/demo.dart +++ b/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/demo.dart @@ -30,7 +30,7 @@ class CustomViewPageState extends State _doubleAnimation = Tween(begin: 0.0, end: 360.0).animate(_controller); _controller.addListener(() { - if(mounted){ + if (mounted) { this.setState(() {}); } }); @@ -40,15 +40,14 @@ class CustomViewPageState extends State @override Widget build(BuildContext context) { return Container( - width: 100.0, - height: 100.0, - margin: EdgeInsets.all(8.0), - child: CustomPaint( - child: Center( - child: Text((_doubleAnimation.value / 3.6).round().toString())), - painter: CircleProgressBarPainter(_doubleAnimation.value) - ), - ); + width: 100.0, + height: 100.0, + margin: EdgeInsets.all(8.0), + child: CustomPaint( + child: Center( + child: Text((_doubleAnimation.value / 3.6).round().toString())), + painter: CircleProgressBarPainter(_doubleAnimation.value)), + ); } void onAnimationStart() { @@ -90,7 +89,8 @@ class CircleProgressBarPainter extends CustomPainter { } @override void paint(Canvas canvas, Size size) { - canvas.drawCircle(Offset(size.width / 2, size.height / 2), size.width / 2,_paintBackground); + canvas.drawCircle(Offset(size.width / 2, size.height / 2), size.width / 2, + _paintBackground); Rect rect = Rect.fromCircle( center: Offset(size.width / 2, size.height / 2), radius: size.width / 2, @@ -102,4 +102,4 @@ class CircleProgressBarPainter extends CustomPainter { bool shouldRepaint(CustomPainter oldDelegate) { return false; } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/index.dart b/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/index.dart index 346a4fdd..b3fb0991 100644 --- a/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/index.dart +++ b/lib/widgets/elements/Media/Canvas/CircleProgressBarPainter/index.dart @@ -12,9 +12,9 @@ const Text1 = ''' - canvas + Animation 实现一个 loading 效果; '''; - class Demo extends StatefulWidget { - static const String routeName = '/element/Media/Canvas/CircleProgressBarPainter'; + static const String routeName = + '/element/Media/Canvas/CircleProgressBarPainter'; _DemoState createState() => _DemoState(); } @@ -25,13 +25,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CircleProgressBarPainter', codeUrl: 'elements/Media/Canvas/CircleProgressBarPainter/demo.dart', - contentList: [ - Text, - Text1, - demoBoxs.CustomViewPage() - ], + contentList: [Text, Text1, demoBoxs.CustomViewPage()], docUrl: 'https://docs.flutter.io/flutter/dart-ui/Canvas-class.html', ); } } - diff --git a/lib/widgets/elements/Media/Canvas/PainterPath/demo.dart b/lib/widgets/elements/Media/Canvas/PainterPath/demo.dart index 3c02dd73..74180709 100644 --- a/lib/widgets/elements/Media/Canvas/PainterPath/demo.dart +++ b/lib/widgets/elements/Media/Canvas/PainterPath/demo.dart @@ -12,9 +12,8 @@ import 'package:flutter/material.dart'; CustomPaint graph; class CustomViewPage extends StatefulWidget { - final String type; - CustomViewPage({this.type='simpleline'}) : super(); + CustomViewPage({this.type = 'simpleline'}) : super(); @override State createState() => CustomViewPageState(); @@ -22,7 +21,6 @@ class CustomViewPage extends StatefulWidget { class CustomViewPageState extends State with SingleTickerProviderStateMixin { - @override void initState() { super.initState(); @@ -30,9 +28,7 @@ class CustomViewPageState extends State @override Widget build(BuildContext context) { - graph = CustomPaint( - painter: DrawPainter(type:widget.type) - ); + graph = CustomPaint(painter: DrawPainter(type: widget.type)); return Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width * 0.6, @@ -40,10 +36,9 @@ class CustomViewPageState extends State //padding: EdgeInsets.all(10.0), child: graph //child:Center(child: graph) - ); + ); } - @override void reassemble() { super.reassemble(); @@ -60,7 +55,7 @@ class DrawPainter extends CustomPainter { Paint painter; final type; - DrawPainter ({this.type}){ + DrawPainter({this.type}) { // Paint painter = Paint() // ..color = Colors.blueAccent //画笔颜色 // ..strokeCap = StrokeCap.round //画笔笔触类型 @@ -79,6 +74,7 @@ class DrawPainter extends CustomPainter { ..strokeWidth = 5.0 ..style = PaintingStyle.stroke; } + ///Flutter中负责View绘制的地方,使用传递来的canvas和size即可完成对目标View的绘制 @override @@ -90,10 +86,14 @@ class DrawPainter extends CustomPainter { canvas.drawPath(path, painter); } - void drawThisPath(Canvas canvas, Size size, Path path,) { - switch(type) { + void drawThisPath( + Canvas canvas, + Size size, + Path path, + ) { + switch (type) { case 'simpleline': - //新建了一个path,然后将路径起始点移动到坐标(100,100)的位置 + //新建了一个path,然后将路径起始点移动到坐标(100,100)的位置 Path path = new Path()..moveTo(0.0, 0.0); path.lineTo(200.0, 200.0); canvas.drawPath(path, painter); @@ -112,8 +112,9 @@ class DrawPainter extends CustomPainter { path.arcTo(rect1, 0.0, 3.14, false); canvas.drawPath(path, painter); - Rect rect2 = Rect.fromCircle(center: Offset(200.0, 100.0), radius: 60.0); - path.arcTo(rect2, 0.0, 3.14*2, true); + Rect rect2 = + Rect.fromCircle(center: Offset(200.0, 100.0), radius: 60.0); + path.arcTo(rect2, 0.0, 3.14 * 2, true); canvas.drawPath(path, painter); break; case 'Besizerline3': @@ -123,9 +124,9 @@ class DrawPainter extends CustomPainter { path.cubicTo((width * 6) / 7, height / 9, (width * 13) / 13, (height * 2) / 5, width / 2, (height * 7) / 12); canvas.drawPath(path, painter - // ..style = PaintingStyle.fill - // ..color = Colors.red - ); + // ..style = PaintingStyle.fill + // ..color = Colors.red + ); Path path2 = new Path(); path2.moveTo(width / 2, height / 4); @@ -134,25 +135,29 @@ class DrawPainter extends CustomPainter { canvas.drawPath(path2, painter); break; case 'drawArc': - // 绘制圆弧 - // Rect来确认圆弧的位置,还需要开始的弧度、结束的弧度、是否使用中心点绘制、以及paint弧度 + // 绘制圆弧 + // Rect来确认圆弧的位置,还需要开始的弧度、结束的弧度、是否使用中心点绘制、以及paint弧度 const PI = 3.1415926; - Rect rect1 = Rect.fromCircle(center: Offset(size.width/2, 0.0), radius: 100.0); - canvas.drawArc(rect1, 0.0, PI / 2, false, painter ..color = Colors.pink); + Rect rect1 = + Rect.fromCircle(center: Offset(size.width / 2, 0.0), radius: 100.0); + canvas.drawArc(rect1, 0.0, PI / 2, false, painter..color = Colors.pink); - Rect rect2 = Rect.fromCircle(center: Offset(size.width/2, 150.0), radius: 100.0); - canvas.drawArc(rect2, 0.0, PI / 2, true, painter ..color = Colors.deepPurple); + Rect rect2 = Rect.fromCircle( + center: Offset(size.width / 2, 150.0), radius: 100.0); + canvas.drawArc( + rect2, 0.0, PI / 2, true, painter..color = Colors.deepPurple); break; case 'drawRRect': - /// fromPoints(Offset a, Offset b) - /// 使用左上和右下角坐标来确定矩形的大小和位置 - /// fromCircle({ Offset center, double radius }) - /// 使用圆的圆心点坐标和半径和确定外切矩形的大小和位置 - /// fromLTRB(double left, double top, double right, double bottom) - /// 使用矩形左边的X坐标、矩形顶部的Y坐标、矩形右边的X坐标、矩形底部的Y坐标来确定矩形的大小和位置 - /// fromLTWH(double left, double top, double width, double height) - /// 使用矩形左边的X坐标、矩形顶部的Y坐标矩形的宽高来确定矩形的大小和位置 - // 用Rect构建一个边长50,中心点坐标为50,100的矩形 + + /// fromPoints(Offset a, Offset b) + /// 使用左上和右下角坐标来确定矩形的大小和位置 + /// fromCircle({ Offset center, double radius }) + /// 使用圆的圆心点坐标和半径和确定外切矩形的大小和位置 + /// fromLTRB(double left, double top, double right, double bottom) + /// 使用矩形左边的X坐标、矩形顶部的Y坐标、矩形右边的X坐标、矩形底部的Y坐标来确定矩形的大小和位置 + /// fromLTWH(double left, double top, double width, double height) + /// 使用矩形左边的X坐标、矩形顶部的Y坐标矩形的宽高来确定矩形的大小和位置 + // 用Rect构建一个边长50,中心点坐标为50,100的矩形 Rect rect1 = Rect.fromCircle(center: Offset(50.0, 50.0), radius: 50.0); Rect rect2 = Rect.fromCircle(center: Offset(200.0, 50.0), radius: 50.0); // 根据上面的矩形,构建一个圆角矩形 @@ -162,13 +167,15 @@ class DrawPainter extends CustomPainter { canvas.drawRRect(rrect2, painter); break; case 'drawDRRect': - //绘制两个矩形 - Rect rect1 = Rect.fromCircle(center: Offset(size.width/2, 100.0), radius: 60.0); - Rect rect2 = Rect.fromCircle(center: Offset(size.width/2, 100.0), radius: 40.0); + //绘制两个矩形 + Rect rect1 = Rect.fromCircle( + center: Offset(size.width / 2, 100.0), radius: 60.0); + Rect rect2 = Rect.fromCircle( + center: Offset(size.width / 2, 100.0), radius: 40.0); //分别绘制外部圆角矩形和内部的圆角矩形 RRect outer = RRect.fromRectAndRadius(rect1, Radius.circular(30.0)); RRect inner = RRect.fromRectAndRadius(rect2, Radius.circular(5.0)); - canvas.drawDRRect(outer, inner, painter ..color = Colors.lime); + canvas.drawDRRect(outer, inner, painter..color = Colors.lime); break; } } diff --git a/lib/widgets/elements/Media/Canvas/PainterPath/index.dart b/lib/widgets/elements/Media/Canvas/PainterPath/index.dart index ab64fadb..78545088 100644 --- a/lib/widgets/elements/Media/Canvas/PainterPath/index.dart +++ b/lib/widgets/elements/Media/Canvas/PainterPath/index.dart @@ -34,7 +34,6 @@ const Text5 = ''' > 三阶贝塞尔曲线 '''; - class Demo extends StatefulWidget { static const String routeName = '/element/Media/Canvas/PainterPath'; @@ -51,13 +50,13 @@ class _DemoState extends State { Text, Text1, Text2, - demoBoxs.CustomViewPage(type:'simpleline'), + demoBoxs.CustomViewPage(type: 'simpleline'), Text3, - demoBoxs.CustomViewPage(type:'polyline'), + demoBoxs.CustomViewPage(type: 'polyline'), Text4, - demoBoxs.CustomViewPage(type:'Besizerline2'), + demoBoxs.CustomViewPage(type: 'Besizerline2'), Text5, - demoBoxs.CustomViewPage(type:'Besizerline3'), + demoBoxs.CustomViewPage(type: 'Besizerline3'), ], docUrl: 'https://docs.flutter.io/flutter/dart-ui/Paint-class.html', ); diff --git a/lib/widgets/elements/Media/Canvas/PainterSketch/demo.dart b/lib/widgets/elements/Media/Canvas/PainterSketch/demo.dart index af67fae6..66455c82 100644 --- a/lib/widgets/elements/Media/Canvas/PainterSketch/demo.dart +++ b/lib/widgets/elements/Media/Canvas/PainterSketch/demo.dart @@ -18,14 +18,13 @@ class PainterSketchDome extends StatefulWidget { } class _PainterSketchDomeState extends State { - List lines = []; List nowPoints = []; Color nowColor = Colors.redAccent; - void moveGestureDetector(DragUpdateDetails detail){ + void moveGestureDetector(DragUpdateDetails detail) { RenderBox box = context.findRenderObject(); - final Offset xy = box.globalToLocal(detail.globalPosition);// 重要需要转换以下坐标位置 + 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); if (mounted) { @@ -42,7 +41,7 @@ class _PainterSketchDomeState extends State { nowPoints.clear(); } RenderBox box = context.findRenderObject(); - final Offset xy = box.globalToLocal(detail.globalPosition);// 重要需要转换以下坐标位置 + 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); if (mounted) { @@ -52,7 +51,7 @@ class _PainterSketchDomeState extends State { } } - void changeColor (Color c){ + void changeColor(Color c) { if (nowPoints.length != 0) { LinePoints l = LinePoints(new List.from(nowPoints), nowColor); lines.add(l); @@ -75,9 +74,10 @@ class _PainterSketchDomeState extends State { Colors.deepPurpleAccent, Colors.lightBlueAccent, Colors.lightGreenAccent, - Colors.cyanAccent,]; + Colors.cyanAccent, + ]; - void _tapClear(){ + void _tapClear() { if (mounted) { setState(() { lines.clear(); @@ -91,62 +91,59 @@ class _PainterSketchDomeState extends State { List pallet = []; for (int i = 0; i < colors.length; i++) { Color c = colors[i]; - pallet.add(ColorPallet(color: c,changeColor: changeColor,isSelect: c==nowColor,)); + pallet.add(ColorPallet( + color: c, + changeColor: changeColor, + isSelect: c == nowColor, + )); } return SizedBox( - width: MediaQuery.of(context).size.width * 0.9, - height: MediaQuery.of(context).size.height * 0.6, - child:new Scaffold( - primary: false, - body: new Container( - decoration: BoxDecoration( - color: Colors.white - ), - child:new Flex( - direction: Axis.vertical, - children: [ - Container( - decoration:BoxDecoration( - color: Colors.black12 - ), - child: ListView( - scrollDirection: Axis.horizontal, - children: pallet - , - ), - height: 60.0, + width: MediaQuery.of(context).size.width * 0.9, + height: MediaQuery.of(context).size.height * 0.6, + child: new Scaffold( + primary: false, + body: new Container( + decoration: BoxDecoration(color: Colors.white), + child: new Flex( + direction: Axis.vertical, + children: [ + Container( + decoration: BoxDecoration(color: Colors.black12), + child: ListView( + scrollDirection: Axis.horizontal, + children: pallet, ), - Expanded( - child: AspectRatio( - aspectRatio: 1.0, - child: GestureDetector( - child: CustomPaint( - painter: PaintCanvas(lines,nowPoints,nowColor), - ), - onHorizontalDragUpdate: moveGestureDetector, - onVerticalDragUpdate: moveGestureDetector, - onHorizontalDragStart: newGestureDetector, - onVerticalDragStart: newGestureDetector, + height: 60.0, + ), + Expanded( + child: AspectRatio( + aspectRatio: 1.0, + child: GestureDetector( + child: CustomPaint( + painter: PaintCanvas(lines, nowPoints, nowColor), ), + onHorizontalDragUpdate: moveGestureDetector, + onVerticalDragUpdate: moveGestureDetector, + onHorizontalDragStart: newGestureDetector, + onVerticalDragStart: newGestureDetector, ), - ) - ], - ), + ), + ) + ], ), - floatingActionButton: FloatingActionButton( - onPressed: _tapClear, - backgroundColor: Colors.redAccent, - foregroundColor: Colors.white, - child: Icon(Icons.delete), - ), - ) - ); + ), + floatingActionButton: FloatingActionButton( + onPressed: _tapClear, + backgroundColor: Colors.redAccent, + foregroundColor: Colors.white, + child: Icon(Icons.delete), + ), + )); } } -class PaintCanvas extends CustomPainter{ - +class PaintCanvas extends CustomPainter { final List lines; final List nowPoints; final Color nowColor; @@ -162,14 +159,14 @@ class PaintCanvas extends CustomPainter{ canvas.save(); for (int i = 0; i < lines.length; i++) { LinePoints l = lines[i]; - for (int j = 1; j < l.points.length; j++){ + for (int j = 1; j < l.points.length; j++) { Offset p1 = l.points[j - 1]; Offset p2 = l.points[j]; p.color = l.lineColor; canvas.drawLine(p1, p2, p); } } - for (int i = 1; i < nowPoints.length; i++){ + for (int i = 1; i < nowPoints.length; i++) { Offset p1 = nowPoints[i - 1]; Offset p2 = nowPoints[i]; p.color = nowColor; @@ -178,13 +175,14 @@ class PaintCanvas extends CustomPainter{ canvas.restore(); } + @override bool shouldRepaint(CustomPainter oldDelegate) { return true; } } -class LinePoints{ +class LinePoints { final List points; final Color lineColor; LinePoints(this.points, this.lineColor); @@ -193,10 +191,11 @@ class LinePoints{ class ColorPallet extends StatelessWidget { final Color color; final Function changeColor; - const ColorPallet({Key key, this.color, this.changeColor, this.isSelect}) : super(key: key); + const ColorPallet({Key key, this.color, this.changeColor, this.isSelect}) + : super(key: key); final bool isSelect; - void onPressed(){ + void onPressed() { changeColor(color); } @@ -204,16 +203,16 @@ class ColorPallet extends StatelessWidget { Widget build(BuildContext context) { return new RawMaterialButton( onPressed: onPressed, - constraints: BoxConstraints(minWidth: 60.0,minHeight: 50.0), + constraints: BoxConstraints(minWidth: 60.0, minHeight: 50.0), child: new Container( - margin: EdgeInsets.only(top: 5.0,bottom: 5.0), + margin: EdgeInsets.only(top: 5.0, bottom: 5.0), width: 50.0, height: 50.0, decoration: BoxDecoration( color: color, borderRadius: BorderRadius.all(Radius.circular(25.0)), - border: Border.all(color: Colors.white,width: isSelect?3.0:0.0) - ), - )) ; + border: + Border.all(color: Colors.white, width: isSelect ? 3.0 : 0.0)), + )); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Canvas/PainterSketch/index.dart b/lib/widgets/elements/Media/Canvas/PainterSketch/index.dart index 1288eb9f..15bfbe0f 100644 --- a/lib/widgets/elements/Media/Canvas/PainterSketch/index.dart +++ b/lib/widgets/elements/Media/Canvas/PainterSketch/index.dart @@ -13,7 +13,6 @@ const Text1 = ''' - canvas + paint + GestureDetector 实现一个 简易的画板; '''; - class Demo extends StatefulWidget { static const String routeName = '/element/Media/Canvas/PainterSketch'; @@ -26,13 +25,8 @@ class _DemoState extends State { return WidgetDemo( title: 'PainterSketch', codeUrl: 'elements/Media/Canvas/PainterSketch/demo.dart', - contentList: [ - Text, - Text1, - demoBoxs.PainterSketchDome() - ], + contentList: [Text, Text1, demoBoxs.PainterSketchDome()], docUrl: 'https://docs.flutter.io/flutter/dart-ui/Paint-class.html', ); } } - diff --git a/lib/widgets/elements/Media/Canvas/index.dart b/lib/widgets/elements/Media/Canvas/index.dart index d3c73227..78d48188 100644 --- a/lib/widgets/elements/Media/Canvas/index.dart +++ b/lib/widgets/elements/Media/Canvas/index.dart @@ -6,7 +6,6 @@ import 'Canvas/index.dart' as Canvas; import 'PainterPath/index.dart' as PainterPath; import 'CircleProgressBarPainter/index.dart' as CircleProgressBarPainter; - List widgetPoints = [ WidgetPoint( name: 'PainterSketch', diff --git a/lib/widgets/elements/Media/Icon/Icon/demo.dart b/lib/widgets/elements/Media/Icon/Icon/demo.dart index 3fca415b..5bc716c2 100644 --- a/lib/widgets/elements/Media/Icon/Icon/demo.dart +++ b/lib/widgets/elements/Media/Icon/Icon/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-15 15:10:34 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-17 11:09:17 +/// Author: xiaojia.dxj +/// Date: 2018-12-15 15:10:34 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-17 11:09:17 import 'package:flutter/material.dart'; class IconDemo extends StatelessWidget { @@ -13,7 +13,7 @@ class IconDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - child: Icon( + child: Icon( Icons.favorite, color: this.curColor, size: 30.0, diff --git a/lib/widgets/elements/Media/Icon/IconData/demo.dart b/lib/widgets/elements/Media/Icon/IconData/demo.dart index a9706e45..db66937d 100644 --- a/lib/widgets/elements/Media/Icon/IconData/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconData/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-15 10:15:34 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-17 11:38:50 +/// Author: xiaojia.dxj +/// Date: 2018-12-15 10:15:34 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-17 11:38:50 import 'package:flutter/material.dart'; class IconDataDemo extends StatelessWidget { @@ -13,10 +13,9 @@ class IconDataDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - child: Icon( + child: Icon( //参考 icon constans - IconData(0xe567, - fontFamily: 'MaterialIcons', matchTextDirection: true), + IconData(0xe567, fontFamily: 'MaterialIcons', matchTextDirection: true), color: this.curColor, size: 30.0, ), diff --git a/lib/widgets/elements/Media/Icon/IconData/index.dart b/lib/widgets/elements/Media/Icon/IconData/index.dart index 9017a35f..56512990 100644 --- a/lib/widgets/elements/Media/Icon/IconData/index.dart +++ b/lib/widgets/elements/Media/Icon/IconData/index.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart'; - const Text = ''' ### **简介** > 字体表示符合表示的图标说明 diff --git a/lib/widgets/elements/Media/Icon/IconTheme/demo.dart b/lib/widgets/elements/Media/Icon/IconTheme/demo.dart index c27da87f..0ea9ea05 100644 --- a/lib/widgets/elements/Media/Icon/IconTheme/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconTheme/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-15 16:07:59 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-15 16:49:17 +/// Author: xiaojia.dxj +/// Date: 2018-12-15 16:07:59 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-15 16:49:17 import 'package:flutter/material.dart'; class IconThemeDemo extends StatelessWidget { @@ -14,8 +14,8 @@ class IconThemeDemo extends StatelessWidget { Widget build(BuildContext context) { return AppBar( actions: [ - IconTheme( - data: IconThemeData(color: curColor, opacity: 3.0), + IconTheme( + data: IconThemeData(color: curColor, opacity: 3.0), child: Container( padding: EdgeInsets.all(20.0), child: Icon(Icons.equalizer), @@ -36,8 +36,8 @@ class IconThemeDemo2 extends StatelessWidget { Widget build(BuildContext context) { return AppBar( actions: [ - IconTheme( - data: IconThemeData(color: curColor, opacity: 3.0), + IconTheme( + data: IconThemeData(color: curColor, opacity: 3.0), child: Row( children: [ Icon( diff --git a/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart b/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart index 67d852d6..c21a55e8 100644 --- a/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-17 09:46:31 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-17 15:53:42 +/// Author: xiaojia.dxj +/// Date: 2018-12-17 09:46:31 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-17 15:53:42 import 'package:flutter/material.dart'; @@ -15,13 +15,13 @@ class IconThemeDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - child: IconTheme( + child: IconTheme( //opacity: 设置透明 - data: IconThemeData( + data: IconThemeData( color: curColor, opacity: curOpacity, ), - child: Icon(Icons.favorite), + child: Icon(Icons.favorite), ), ); } @@ -37,8 +37,8 @@ class IconThemeDemo2 extends StatelessWidget { Widget build(BuildContext context) { return AppBar( actions: [ - IconTheme( - data: IconThemeData(color: curColor, opacity: 1.0), + IconTheme( + data: IconThemeData(color: curColor, opacity: 1.0), child: Row( children: [ Icon(Icons.favorite_border), diff --git a/lib/widgets/elements/Media/Icon/ImageIcon/demo.dart b/lib/widgets/elements/Media/Icon/ImageIcon/demo.dart index 0345c3b6..8c971f8e 100644 --- a/lib/widgets/elements/Media/Icon/ImageIcon/demo.dart +++ b/lib/widgets/elements/Media/Icon/ImageIcon/demo.dart @@ -1,9 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2018-12-15 15:19:41 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2018-12-17 10:07:19 - +/// Author: xiaojia.dxj +/// Date: 2018-12-15 15:19:41 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2018-12-17 10:07:19 import 'package:flutter/material.dart'; @@ -11,8 +10,8 @@ class ImageIconDemo extends StatelessWidget { @override Widget build(BuildContext context) { //注意:当你用一个图片的时候,这个图片会被整个覆盖,只保留图片的形状,填充你设置的颜色 - return ImageIcon( - AssetImage('assets/images/btn_icon_dingyuehao_normal.png'), + return ImageIcon( + AssetImage('assets/images/btn_icon_dingyuehao_normal.png'), color: Colors.red, size: 50.0, ); diff --git a/lib/widgets/elements/Media/Image/AssetImage/assetImage_demo.dart b/lib/widgets/elements/Media/Image/AssetImage/assetImage_demo.dart index 940b4cd7..83e412ec 100644 --- a/lib/widgets/elements/Media/Image/AssetImage/assetImage_demo.dart +++ b/lib/widgets/elements/Media/Image/AssetImage/assetImage_demo.dart @@ -4,18 +4,18 @@ class AssetImageDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Column( - children: [ - CircleAvatar( - backgroundImage: AssetImage('assets/images/food01.jpeg'), + children: [ + CircleAvatar( + backgroundImage: AssetImage('assets/images/food01.jpeg'), + ), + Container( + child: Image( + image: AssetImage('assets/images/food02.jpeg'), + height: 300.0, + width: 300.0, ), - Container( - child: Image( - image: AssetImage('assets/images/food02.jpeg'), - height: 300.0, - width: 300.0, - ), - ) - ], - ); + ) + ], + ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/AssetImage/index.dart b/lib/widgets/elements/Media/Image/AssetImage/index.dart index b33a0db6..d5705677 100644 --- a/lib/widgets/elements/Media/Image/AssetImage/index.dart +++ b/lib/widgets/elements/Media/Image/AssetImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-16 15:09:12 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:12 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Image/DecorationImage/index.dart b/lib/widgets/elements/Media/Image/DecorationImage/index.dart index d2f638e5..32f15514 100644 --- a/lib/widgets/elements/Media/Image/DecorationImage/index.dart +++ b/lib/widgets/elements/Media/Image/DecorationImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-16 15:12:39 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:12:39 import 'package:flutter/material.dart'; @@ -14,7 +14,7 @@ const contentText0 = ''' > 修饰Box的图片 '''; -const contentText1= ''' +const contentText1 = ''' ### **基本用法** > demo演示作为背景图片的样例 diff --git a/lib/widgets/elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart b/lib/widgets/elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart index c1b4ae0f..b0fe6042 100644 --- a/lib/widgets/elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart +++ b/lib/widgets/elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart @@ -3,15 +3,12 @@ import 'package:flutter/material.dart'; class DecorationImagePainterDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - - ); + return Container(); } } // class ImagePainter extends CustomPainter{ - // Future getImage(String path) async { // ByteData data = await rootBundle.load(path); // ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List()); @@ -35,4 +32,4 @@ class DecorationImagePainterDemo extends StatelessWidget { // // TODO: implement shouldRepaint // return false; // } -// } \ No newline at end of file +// } diff --git a/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart b/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart index 4550381a..e743ddc8 100644 --- a/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart +++ b/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-16 15:09:12 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:12 import 'package:flutter/material.dart'; @@ -20,11 +20,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [], - docUrl: 'https://docs.flutter.io/flutter/painting/DecorationImagePainter-class.html', - codeUrl: 'elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart', - title:'DecorationImagePainter' - ); + contentList: [], + docUrl: + 'https://docs.flutter.io/flutter/painting/DecorationImagePainter-class.html', + codeUrl: + 'elements/Media/Image/DecorationImagePainter/decoration_image_painter_demo.dart', + title: 'DecorationImagePainter'); } } - diff --git a/lib/widgets/elements/Media/Image/ExactAssetImage/index.dart b/lib/widgets/elements/Media/Image/ExactAssetImage/index.dart index 9b7a5c36..fdc6a09a 100644 --- a/lib/widgets/elements/Media/Image/ExactAssetImage/index.dart +++ b/lib/widgets/elements/Media/Image/ExactAssetImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 13:29:34 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 14:12:21 +/// @Author: 一凨 +/// @Date: 2018-12-08 13:29:34 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 14:12:21 import 'package:flutter/material.dart'; @@ -36,9 +36,11 @@ class _DemoState extends State { contentText1, ExactAssetImageDemo(), ], - title:'ExactAssetImage', - codeUrl: 'elements/Media/Image/ExactAssetImage/exact_asset_image_demo.dart', - docUrl: 'https://docs.flutter.io/flutter/painting/ExactAssetImage-class.html', + title: 'ExactAssetImage', + codeUrl: + 'elements/Media/Image/ExactAssetImage/exact_asset_image_demo.dart', + docUrl: + 'https://docs.flutter.io/flutter/painting/ExactAssetImage-class.html', ); } } diff --git a/lib/widgets/elements/Media/Image/FadeInImage/fade_in_image_demo.dart b/lib/widgets/elements/Media/Image/FadeInImage/fade_in_image_demo.dart index e0eccc6e..cf55c8ff 100644 --- a/lib/widgets/elements/Media/Image/FadeInImage/fade_in_image_demo.dart +++ b/lib/widgets/elements/Media/Image/FadeInImage/fade_in_image_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 16:08:41 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 16:22:50 +/// @Author: 一凨 +/// @Date: 2018-12-08 16:08:41 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 16:22:50 import 'package:flutter/material.dart'; @@ -10,8 +10,8 @@ class FadeInImageDemo extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - ClipOval( - child: FadeInImage.assetNetwork( + ClipOval( + child: FadeInImage.assetNetwork( placeholder: "assets/images/normal_user_icon.png", //预览图 fit: BoxFit.fitWidth, image: @@ -23,10 +23,10 @@ class FadeInImageDemo extends StatelessWidget { SizedBox( height: 20.0, ), - CircleAvatar( - backgroundImage: NetworkImage( + CircleAvatar( + backgroundImage: NetworkImage( "https://img.alicdn.com/tfs/TB148sWfMHqK1RjSZFgXXa7JXXa-536-482.png"), - child: Text("一凨"), //可以在图片上添加文字等等 + child: Text("一凨"), //可以在图片上添加文字等等 ), ], ); diff --git a/lib/widgets/elements/Media/Image/FadeInImage/index.dart b/lib/widgets/elements/Media/Image/FadeInImage/index.dart index ffcf1d16..4ae7fdbd 100644 --- a/lib/widgets/elements/Media/Image/FadeInImage/index.dart +++ b/lib/widgets/elements/Media/Image/FadeInImage/index.dart @@ -1,14 +1,13 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 14:26:00 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 16:10:55 +/// @Author: 一凨 +/// @Date: 2018-12-08 14:26:00 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 16:10:55 import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './fade_in_image_demo.dart'; - const contentText0 = ''' ### **简介** > placeHodler image到目标图片的一种过渡widget @@ -25,7 +24,6 @@ const contentText1 = ''' '''; - class Demo extends StatefulWidget { static const String routeName = '/element/Media/Image/FadeInImage'; _DemoState createState() => _DemoState(); @@ -37,7 +35,7 @@ class _DemoState extends State { return WidgetDemo( codeUrl: 'elements/Media/Image/FadeInImage/fade_in_image_demo.dart', docUrl: 'https://docs.flutter.io/flutter/widgets/FadeInImage-class.html', - title:'FadeInImage', + title: 'FadeInImage', contentList: [ contentText0, contentText1, diff --git a/lib/widgets/elements/Media/Image/FileImage/file_image_demo.dart b/lib/widgets/elements/Media/Image/FileImage/file_image_demo.dart index f0638e39..684dd47b 100644 --- a/lib/widgets/elements/Media/Image/FileImage/file_image_demo.dart +++ b/lib/widgets/elements/Media/Image/FileImage/file_image_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 16:20:17 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:18:39 +/// @Author: 一凨 +/// @Date: 2018-12-08 16:20:17 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:18:39 import 'dart:async'; import 'dart:io'; @@ -11,7 +11,7 @@ import 'package:image_picker/image_picker.dart'; class FileImageDemo extends StatefulWidget { @override - _FileImageDemoState createState() => _FileImageDemoState(); + _FileImageDemoState createState() => _FileImageDemoState(); } class _FileImageDemoState extends State { @@ -29,16 +29,22 @@ class _FileImageDemoState extends State { Widget build(BuildContext context) { return Column( children: [ - Center( + Center( child: _image == null - ? Text('您还未选择任何图片.') - : Image.file(_image,scale: 0.5,fit: BoxFit.cover,), + ? Text('您还未选择任何图片.') + : Image.file( + _image, + scale: 0.5, + fit: BoxFit.cover, + ), ), FlatButton( - onPressed: getImage, - child: Text('点击选择图片',style: TextStyle(color: Colors.white),), - color: Colors.lightBlue - ) + onPressed: getImage, + child: Text( + '点击选择图片', + style: TextStyle(color: Colors.white), + ), + color: Colors.lightBlue) ], ); } diff --git a/lib/widgets/elements/Media/Image/FileImage/index.dart b/lib/widgets/elements/Media/Image/FileImage/index.dart index ff20b410..18d8fe8a 100644 --- a/lib/widgets/elements/Media/Image/FileImage/index.dart +++ b/lib/widgets/elements/Media/Image/FileImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 16:20:33 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 19:24:33 +/// @Author: 一凨 +/// @Date: 2018-12-08 16:20:33 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 19:24:33 import 'package:flutter/material.dart'; @@ -32,7 +32,7 @@ class _DemoState extends State { return WidgetDemo( codeUrl: 'elements/Media/Image/FileImage/file_image_demo.dart', docUrl: 'https://docs.flutter.io/flutter/painting/FileImage-class.html', - title:'FileImage', + title: 'FileImage', contentList: [ contentText0, contentText1, diff --git a/lib/widgets/elements/Media/Image/Image/demo.dart b/lib/widgets/elements/Media/Image/Image/demo.dart index 64a053b7..fb2afb8d 100644 --- a/lib/widgets/elements/Media/Image/Image/demo.dart +++ b/lib/widgets/elements/Media/Image/Image/demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2019-01-07 15:33:49 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-07 15:45:29 +/// @Author: 一凨 +/// @Date: 2019-01-07 15:33:49 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-07 15:45:29 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Image/Image/index.dart b/lib/widgets/elements/Media/Image/Image/index.dart index c0f13f70..1281949f 100644 --- a/lib/widgets/elements/Media/Image/Image/index.dart +++ b/lib/widgets/elements/Media/Image/Image/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2019-01-07 15:33:42 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2019-01-07 15:42:54 +/// @Author: 一凨 +/// @Date: 2019-01-07 15:33:42 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2019-01-07 15:42:54 import 'package:flutter/material.dart'; @@ -34,14 +34,14 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - title: 'Image', - codeUrl: 'elements/Media/Image/Image/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/dart-ui/Image-class.html', - contentList: [ - content0, - content1, - ImageDemo(), - ], + title: 'Image', + codeUrl: 'elements/Media/Image/Image/demo.dart', + docUrl: 'https://docs.flutter.io/flutter/dart-ui/Image-class.html', + contentList: [ + content0, + content1, + ImageDemo(), + ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/MemoryImage/index.dart b/lib/widgets/elements/Media/Image/MemoryImage/index.dart index b89aefbd..b70f2107 100644 --- a/lib/widgets/elements/Media/Image/MemoryImage/index.dart +++ b/lib/widgets/elements/Media/Image/MemoryImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:48:28 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:48:28 import 'package:flutter/material.dart'; @@ -27,7 +27,6 @@ class Demo extends StatefulWidget { } class _DemoState extends State { - @override Widget build(BuildContext context) { return WidgetDemo( @@ -39,8 +38,7 @@ class _DemoState extends State { title: 'MemoryImage', // desc: 'MemoryImage 使用介绍', docUrl: 'https://docs.flutter.io/flutter/painting/MemoryImage-class.html', - codeUrl: - 'elements/Media/Image/MemoryImage/index.dart', + codeUrl: 'elements/Media/Image/MemoryImage/index.dart', ); } } diff --git a/lib/widgets/elements/Media/Image/MemoryImage/memory_image_demo.dart b/lib/widgets/elements/Media/Image/MemoryImage/memory_image_demo.dart index 6abe4acc..9b12c559 100644 --- a/lib/widgets/elements/Media/Image/MemoryImage/memory_image_demo.dart +++ b/lib/widgets/elements/Media/Image/MemoryImage/memory_image_demo.dart @@ -1,14 +1,13 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:49:19 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:46:37 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:49:19 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:46:37 import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; - class MemoryImageDemo extends StatefulWidget { _MemoryImageDemoState createState() => _MemoryImageDemoState(); } @@ -29,17 +28,17 @@ class _MemoryImageDemoState extends State { @override Widget build(BuildContext context) { - final decoration = BoxDecoration( + final decoration = BoxDecoration( image: bytes == null ? null - : DecorationImage( - image: MemoryImage(bytes,scale: 1.0), + : DecorationImage( + image: MemoryImage(bytes, scale: 1.0), ), ); return Container( - width: 300.0, - height: 300.0, - decoration: decoration, + width: 300.0, + height: 300.0, + decoration: decoration, ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/NetworkImage/index.dart b/lib/widgets/elements/Media/Image/NetworkImage/index.dart index b3e4e72e..6d885096 100644 --- a/lib/widgets/elements/Media/Image/NetworkImage/index.dart +++ b/lib/widgets/elements/Media/Image/NetworkImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:32:57 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:32:57 import 'package:flutter/material.dart'; @@ -35,7 +35,8 @@ class _DemoState extends State { NetworkImageDemo(), ], codeUrl: 'elements/Media/Image/NetworkImage/network_image_demo.dart', - docUrl: 'https://docs.flutter.io/flutter/painting/NetworkImage-class.html', + docUrl: + 'https://docs.flutter.io/flutter/painting/NetworkImage-class.html', title: 'NetworkImage', ); } diff --git a/lib/widgets/elements/Media/Image/NetworkImage/network_image_demo.dart b/lib/widgets/elements/Media/Image/NetworkImage/network_image_demo.dart index 42f001c7..85b5d945 100644 --- a/lib/widgets/elements/Media/Image/NetworkImage/network_image_demo.dart +++ b/lib/widgets/elements/Media/Image/NetworkImage/network_image_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:20:37 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:35:36 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:20:37 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:35:36 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Image/RawImage/index.dart b/lib/widgets/elements/Media/Image/RawImage/index.dart index a96e002a..e4a07c78 100644 --- a/lib/widgets/elements/Media/Image/RawImage/index.dart +++ b/lib/widgets/elements/Media/Image/RawImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:11:44 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:11:44 import 'package:flutter/material.dart'; @@ -21,7 +21,7 @@ const contentText1 = ''' '''; -const contentText2= ''' +const contentText2 = ''' ### **高级用法** > 关于更多详细介绍,请看paintImage的属性说明 '''; diff --git a/lib/widgets/elements/Media/Image/RawImage/raw_image_demo.dart b/lib/widgets/elements/Media/Image/RawImage/raw_image_demo.dart index 3aa1caba..b3dd2dce 100644 --- a/lib/widgets/elements/Media/Image/RawImage/raw_image_demo.dart +++ b/lib/widgets/elements/Media/Image/RawImage/raw_image_demo.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:47:25 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:09:32 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:47:25 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:09:32 import 'dart:async'; import 'dart:typed_data'; diff --git a/lib/widgets/elements/Media/Image/index.dart b/lib/widgets/elements/Media/Image/index.dart index 3ff15ba3..9e36aa98 100644 --- a/lib/widgets/elements/Media/Image/index.dart +++ b/lib/widgets/elements/Media/Image/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-11-16 15:09:19 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:19 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-07 15:37:07 @@ -19,7 +19,6 @@ import './precacheImage/index.dart' as precacheImage; import './RawImage/index.dart' as RawImage; import './Image/index.dart' as Image; - List widgetPoints = [ WidgetPoint( name: 'AssetImage', @@ -81,4 +80,4 @@ List widgetPoints = [ routerName: Image.Demo.routeName, buildRouter: (BuildContext context) => Image.Demo(), ), -]; \ No newline at end of file +]; diff --git a/lib/widgets/elements/Media/Image/paintImage/index.dart b/lib/widgets/elements/Media/Image/paintImage/index.dart index 38721433..99f62fb3 100644 --- a/lib/widgets/elements/Media/Image/paintImage/index.dart +++ b/lib/widgets/elements/Media/Image/paintImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 20:19:01 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 20:19:01 import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Image/paintImage/paint_image_demo.dart b/lib/widgets/elements/Media/Image/paintImage/paint_image_demo.dart index 24347bcc..d09cf682 100644 --- a/lib/widgets/elements/Media/Image/paintImage/paint_image_demo.dart +++ b/lib/widgets/elements/Media/Image/paintImage/paint_image_demo.dart @@ -1,15 +1,13 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:46:57 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:46:57 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:46:57 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:46:57 import 'package:flutter/material.dart'; class PaintImageDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - - ); + return Container(); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/precacheImage/index.dart b/lib/widgets/elements/Media/Image/precacheImage/index.dart index 8e586ff9..5b7aeebe 100644 --- a/lib/widgets/elements/Media/Image/precacheImage/index.dart +++ b/lib/widgets/elements/Media/Image/precacheImage/index.dart @@ -1,7 +1,7 @@ - /// @Author: 一凨 - /// @Date: 2018-11-16 15:09:12 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-11-16 15:09:12 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:12 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:12 import 'package:flutter/material.dart'; @@ -14,7 +14,7 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return Container( - child: null, + child: null, ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/Image/precacheImage/precache_image_demo.dart b/lib/widgets/elements/Media/Image/precacheImage/precache_image_demo.dart index 4464e624..23de6bd7 100644 --- a/lib/widgets/elements/Media/Image/precacheImage/precache_image_demo.dart +++ b/lib/widgets/elements/Media/Image/precacheImage/precache_image_demo.dart @@ -1,15 +1,13 @@ - /// @Author: 一凨 - /// @Date: 2018-12-08 17:47:57 - /// @Last Modified by: 一凨 - /// @Last Modified time: 2018-12-08 17:48:20 +/// @Author: 一凨 +/// @Date: 2018-12-08 17:47:57 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-08 17:48:20 import 'package:flutter/material.dart'; class PrecacheImageDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - - ); + return Container(); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Media/index.dart b/lib/widgets/elements/Media/index.dart index 488d1f67..a7c68ec4 100644 --- a/lib/widgets/elements/Media/index.dart +++ b/lib/widgets/elements/Media/index.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-11-16 15:09:27 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-11-16 15:09:27 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:27 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:27 import 'Image/index.dart' as Image; import 'Icon/index.dart' as Icon; @@ -13,4 +13,4 @@ List getWidgets() { result.addAll(Icon.widgetPoints); result.addAll(Canvas.widgetPoints); return result; -} \ No newline at end of file +} diff --git a/lib/widgets/elements/index.dart b/lib/widgets/elements/index.dart index d3362d59..a4f3e71f 100644 --- a/lib/widgets/elements/index.dart +++ b/lib/widgets/elements/index.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-11-16 15:09:31 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-11-16 15:09:31 +/// @Author: 一凨 +/// @Date: 2018-11-16 15:09:31 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-11-16 15:09:31 import 'Form/index.dart' as Form; import 'Frame/index.dart' as Frame; @@ -13,4 +13,4 @@ List getWidgets() { result.addAll(Frame.getWidgets()); result.addAll(Media.getWidgets()); return result; -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoApp/demo.dart b/lib/widgets/themes/Cupertino/CupertinoApp/demo.dart index ddd7888a..70d266a8 100644 --- a/lib/widgets/themes/Cupertino/CupertinoApp/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoApp/demo.dart @@ -33,8 +33,8 @@ class _CupertinoAppFullDefault extends State { (___, Animation animation, ____, Widget child) { return FadeTransition( opacity: animation, - child: ScaleTransition( - scale: Tween(begin: 0.5, end: 1.0).animate(animation), + child: ScaleTransition( + scale: Tween(begin: 0.5, end: 1.0).animate(animation), child: child, ), ); @@ -144,7 +144,8 @@ class _CupertinoAppFullDefault extends State { backgroundColor: CupertinoColors.destructiveRed, middle: Text('这里是标题', style: TextStyle(color: Colors.white)), ), - child: Center(child: Text('这里是内容', style: TextStyle(color: Colors.black))), + child: Center( + child: Text('这里是内容', style: TextStyle(color: Colors.black))), backgroundColor: CupertinoColors.inactiveGray, ); }); diff --git a/lib/widgets/themes/Cupertino/CupertinoApp/index.dart b/lib/widgets/themes/Cupertino/CupertinoApp/index.dart index e1efb44d..1ae50897 100644 --- a/lib/widgets/themes/Cupertino/CupertinoApp/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoApp/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:22 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:22 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-07 15:52:45 @@ -40,14 +40,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - demoBox.CupertinoAppFullDefault() - ], + contentList: [content0, content1, demoBox.CupertinoAppFullDefault()], title: 'CupertinoApp', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoApp-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoApp-class.html', codeUrl: 'themes/Cupertino/CupertinoApp/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoButton/demo.dart b/lib/widgets/themes/Cupertino/CupertinoButton/demo.dart index 806704df..47dc60a7 100644 --- a/lib/widgets/themes/Cupertino/CupertinoButton/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoButton/demo.dart @@ -8,7 +8,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - // Checkbox 默认按钮的实例 // index 当前checkbox 的索引值 class CupertinoButtonFullDefault extends StatefulWidget { @@ -18,10 +17,8 @@ class CupertinoButtonFullDefault extends StatefulWidget { State createState() => _CupertinoButtonFullDefault(); } - // CupertinoButton 默认的实例,有状态 class _CupertinoButtonFullDefault extends State { - @override Widget build(BuildContext context) { return CupertinoButton( @@ -29,9 +26,9 @@ class _CupertinoButtonFullDefault extends State { onPressed: () { print('on Pressed!'); }, - pressedOpacity:0.5,// 按下后的按钮不透明度 - color:CupertinoColors.inactiveGray, + pressedOpacity: 0.5, // 按下后的按钮不透明度 + color: CupertinoColors.inactiveGray, child: new Text('CupertinoButton'), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoButton/index.dart b/lib/widgets/themes/Cupertino/CupertinoButton/index.dart index 03b691f3..2dd1c485 100644 --- a/lib/widgets/themes/Cupertino/CupertinoButton/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoButton/index.dart @@ -31,14 +31,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - demoBox.CupertinoButtonFullDefault() - ], + contentList: [content0, content1, demoBox.CupertinoButtonFullDefault()], title: 'CupertinoButton', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoButton-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoButton-class.html', codeUrl: 'themes/Cupertino/CupertinoButton/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoColors/demo.dart b/lib/widgets/themes/Cupertino/CupertinoColors/demo.dart index 926fbcc1..40ad5a9e 100644 --- a/lib/widgets/themes/Cupertino/CupertinoColors/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoColors/demo.dart @@ -19,27 +19,27 @@ class CupertinoColorsFullDefault extends StatefulWidget { // CupertinoColors 默认的实例,有状态 class _CupertinoColorsFullDefault extends State { - - Widget setColorsView(cupertinoColors,String colorName){ + Widget setColorsView(cupertinoColors, String colorName) { return Container( - width: MediaQuery.of(context).size.width-100, + width: MediaQuery.of(context).size.width - 100, padding: const EdgeInsets.all(10.0), - child:Text(colorName,style:TextStyle(color:Colors.white)), - decoration:BoxDecoration(color: cupertinoColors) - ); + child: Text(colorName, style: TextStyle(color: Colors.white)), + decoration: BoxDecoration(color: cupertinoColors)); } + @override Widget build(BuildContext context) { return Column( children: [ - setColorsView(CupertinoColors.activeBlue,'activeBlue'), - setColorsView(CupertinoColors.activeGreen,'activeGreen'), - setColorsView(CupertinoColors.black,'black'), - setColorsView(CupertinoColors.destructiveRed,'destructiveRed'), - setColorsView(CupertinoColors.inactiveGray,'inactiveGray'), - setColorsView(CupertinoColors.lightBackgroundGray,'lightBackgroundGray'), - setColorsView(CupertinoColors.white,'white') + setColorsView(CupertinoColors.activeBlue, 'activeBlue'), + setColorsView(CupertinoColors.activeGreen, 'activeGreen'), + setColorsView(CupertinoColors.black, 'black'), + setColorsView(CupertinoColors.destructiveRed, 'destructiveRed'), + setColorsView(CupertinoColors.inactiveGray, 'inactiveGray'), + setColorsView( + CupertinoColors.lightBackgroundGray, 'lightBackgroundGray'), + setColorsView(CupertinoColors.white, 'white') ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoColors/index.dart b/lib/widgets/themes/Cupertino/CupertinoColors/index.dart index 4953ba79..2a32adf3 100644 --- a/lib/widgets/themes/Cupertino/CupertinoColors/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoColors/index.dart @@ -29,14 +29,11 @@ class _DemoState extends State { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - demoBox.CupertinoColorsFullDefault() - ], + contentList: [content0, content1, demoBox.CupertinoColorsFullDefault()], title: 'CupertinoColors', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoColors-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoColors-class.html', codeUrl: 'themes/Cupertino/CupertinoColors/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoIcons/demo.dart b/lib/widgets/themes/Cupertino/CupertinoIcons/demo.dart index 10c01ad6..55449e56 100644 --- a/lib/widgets/themes/Cupertino/CupertinoIcons/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoIcons/demo.dart @@ -20,11 +20,10 @@ class CupertinoIconsFullDefault extends StatefulWidget { // CupertinoIcons 默认的实例,有状态 class _CupertinoIconsFullDefault extends State { - final colorsList = []; final List widgetList = []; - Widget rowView(IconData itA,IconData itB){ + Widget rowView(IconData itA, IconData itB) { //print('itA=====>${itA.fontPackage}'); return Row( //mainAxisSize:MainAxisSize.max, @@ -32,28 +31,30 @@ class _CupertinoIconsFullDefault extends State { //mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( - flex:1, - child: CupertinoButton( - padding: EdgeInsets.only(left: 0), - onPressed: () { }, - child:FlatButton.icon( - label: Text('默认按钮', semanticsLabel: 'Add'), - icon:Icon(itA, - semanticLabel: 'Add', - ), - onPressed: () { }, - ))), - Expanded( - flex:1, + flex: 1, child: CupertinoButton( - padding: EdgeInsets.zero, - onPressed: () { }, - child:FlatButton.icon( + padding: EdgeInsets.only(left: 0), + onPressed: () {}, + child: FlatButton.icon( label: Text('默认按钮', semanticsLabel: 'Add'), - icon:Icon(itB, + icon: Icon( + itA, semanticLabel: 'Add', ), - onPressed: () { }, + onPressed: () {}, + ))), + Expanded( + flex: 1, + child: CupertinoButton( + padding: EdgeInsets.zero, + onPressed: () {}, + child: FlatButton.icon( + label: Text('默认按钮', semanticsLabel: 'Add'), + icon: Icon( + itB, + semanticLabel: 'Add', + ), + onPressed: () {}, ))), ], ); @@ -64,22 +65,21 @@ class _CupertinoIconsFullDefault extends State { super.initState(); final names = icon_names.CupertinoIIconNames.names; - for(var i=0;i { @override Widget build(BuildContext context) { return WidgetDemo( - contentList: [ - content0, - content1, - demoBox.CupertinoIconsFullDefault() - ], - title: 'CupertinoIcons', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoIcons-class.html', - codeUrl: 'themes/Cupertino/CupertinoIcons/demo.dart' - ); + contentList: [content0, content1, demoBox.CupertinoIconsFullDefault()], + title: 'CupertinoIcons', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoIcons-class.html', + codeUrl: 'themes/Cupertino/CupertinoIcons/demo.dart'); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoNavigationBar/demo.dart b/lib/widgets/themes/Cupertino/CupertinoNavigationBar/demo.dart index aa62be92..8873c634 100644 --- a/lib/widgets/themes/Cupertino/CupertinoNavigationBar/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoNavigationBar/demo.dart @@ -18,115 +18,118 @@ class CupertinoNavigationBarFullDefault extends StatefulWidget { // CupertinoNavigationBar 默认的实例,有状态 class _CupertinoNavigationBarFullDefault extends State { - Widget build2(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - //height: 500.0, - child:CupertinoApp( - home: CupertinoTabScaffold( - tabBar: CupertinoTabBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.share), - title: Text('Tab 1'), - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.share), - title: Text('Tab 2'), - ), - ], - ), - tabBuilder: (BuildContext context, int index) { - // For 1-indexed readability. - ++index; - return CupertinoTabView( - builder: (BuildContext context) { - return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 1 of tab $index'), + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + //height: 500.0, + child: CupertinoApp( + home: CupertinoTabScaffold( + tabBar: CupertinoTabBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.share), + title: Text('Tab 1'), ), - child: Center( - child: CupertinoButton( - child: const Text('Next'), - onPressed: () { - Navigator.of(context).push( - CupertinoPageRoute( - builder: (BuildContext context) { - return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 2 of tab $index'), - ), - child: Center( - child: CupertinoButton( - child: const Text('Back'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - ); - }, - ), - ); - }, - ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.share), + title: Text('Tab 2'), ), + ], + ), + tabBuilder: (BuildContext context, int index) { + // For 1-indexed readability. + ++index; + return CupertinoTabView( + builder: (BuildContext context) { + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tab $index'), + ), + child: Center( + child: CupertinoButton( + child: const Text('Next'), + onPressed: () { + Navigator.of(context).push( + CupertinoPageRoute( + builder: (BuildContext context) { + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text('Page 2 of tab $index'), + ), + child: Center( + child: CupertinoButton( + child: const Text('Back'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ); + }, + ), + ); + }, + ), + ), + ); + }, ); }, - ); - }, - ), - ) - ); + ), + )); } @override Widget build(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height/1.5, - child: navigationBar(context) - ); + height: MediaQuery.of(context).size.height / 1.5, + child: navigationBar(context)); } Widget navigationBar(BuildContext context) { - return CupertinoPageScaffold( // 进入程序后显示的第一个页面,传入的是一个Widget,但实际上这个Widget需要包裹一个Scaffold + return CupertinoPageScaffold( + // 进入程序后显示的第一个页面,传入的是一个Widget,但实际上这个Widget需要包裹一个Scaffold navigationBar: CupertinoNavigationBar( - leading: Icon(CupertinoIcons.back),// 放置在导航栏的开头。通常是正常页面的后退按钮或完整页面对话框的取消按钮 - middle: Text('Title'),// 放置在导航栏的中间。通常是标题或分段控件 - trailing: Icon(CupertinoIcons.share),// 放置在导航栏的末尾。通常在页面上执行其他操作,例如搜索或编辑功能 - actionsForegroundColor:CupertinoColors.white,// 用于 导航栏中前导和尾随小部件的文本和图标的默认颜色。 - backgroundColor:CupertinoColors.activeGreen,// 导航栏的背景颜色。如果它包含透明度,标签栏将自动对其背后的内容产生模糊效果 - border:Border( // 边框样式 - bottom: BorderSide(color: CupertinoColors.inactiveGray, width: 1.0), - ), - //heroTag :null, - previousPageTitle:'???',// 自动隐含前导按钮时手动指定上一个路线的标题 - transitionBetweenRoutes:true // 是否在导航栏之间转换 - ), + leading: + Icon(CupertinoIcons.back), // 放置在导航栏的开头。通常是正常页面的后退按钮或完整页面对话框的取消按钮 + middle: Text('Title'), // 放置在导航栏的中间。通常是标题或分段控件 + trailing: + Icon(CupertinoIcons.share), // 放置在导航栏的末尾。通常在页面上执行其他操作,例如搜索或编辑功能 + actionsForegroundColor: + CupertinoColors.white, // 用于 导航栏中前导和尾随小部件的文本和图标的默认颜色。 + backgroundColor: CupertinoColors + .activeGreen, // 导航栏的背景颜色。如果它包含透明度,标签栏将自动对其背后的内容产生模糊效果 + border: Border( + // 边框样式 + bottom: BorderSide(color: CupertinoColors.inactiveGray, width: 1.0), + ), + //heroTag :null, + previousPageTitle: '???', // 自动隐含前导按钮时手动指定上一个路线的标题 + transitionBetweenRoutes: true // 是否在导航栏之间转换 + ), child: Center( - child: Text('这里是内容', style: TextStyle(color: Colors.black)) - ), // 应用程序默认路由,(Navigator.defaultRouteName,即/) + child: Text('这里是内容', + style: TextStyle( + color: Colors + .black))), // 应用程序默认路由,(Navigator.defaultRouteName,即/) ); } - Widget tabBar(BuildContext context){ - return CupertinoTabBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.home), - title: Text('Home'), - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.conversation_bubble), - title: Text('Support'), - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.profile_circled), - title: Text('Profile'), - ), - ] - ); + Widget tabBar(BuildContext context) { + return CupertinoTabBar(items: const [ + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.home), + title: Text('Home'), + ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.conversation_bubble), + title: Text('Support'), + ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.profile_circled), + title: Text('Profile'), + ), + ]); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoNavigationBar/index.dart b/lib/widgets/themes/Cupertino/CupertinoNavigationBar/index.dart index 8dfa5198..786c4b90 100644 --- a/lib/widgets/themes/Cupertino/CupertinoNavigationBar/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoNavigationBar/index.dart @@ -44,11 +44,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoNavigationBarFullDefault(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoNavigationBar', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoNavigationBar-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoNavigationBar-class.html', codeUrl: 'themes/Cupertino/CupertinoNavigationBar/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoPageRoute/demo.dart b/lib/widgets/themes/Cupertino/CupertinoPageRoute/demo.dart index e09a6d56..2519cb3d 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPageRoute/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPageRoute/demo.dart @@ -18,73 +18,69 @@ class CupertinoPageRouteFullDefault extends StatefulWidget { // CupertinoPageRoute 默认的实例,有状态 class _CupertinoPageRouteFullDefault extends State { - - Widget pageRoute(BuildContext context,int index){ + Widget pageRoute(BuildContext context, int index) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 2 of tab $index'), - ), - child: Center( - child: CupertinoButton( - child: const Text('Back'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - ); + navigationBar: CupertinoNavigationBar( + middle: Text('Page 2 of tab $index'), + ), + child: Center( + child: CupertinoButton( + child: const Text('Back'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ); } @override Widget build(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - //height: 500.0, - child:CupertinoApp( - home: CupertinoTabScaffold( - tabBar: CupertinoTabBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.share), - title: Text('无滑动的切换1'), - ), - BottomNavigationBarItem( - icon: Icon(CupertinoIcons.share), - title: Text('无滑动的切换2'), - ), - ], - ), - tabBuilder: (BuildContext context, int index) { - // For 1-indexed readability. - ++index; - return CupertinoTabView( - builder: (BuildContext context) { - return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 1 of tab $index'), + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + //height: 500.0, + child: CupertinoApp( + home: CupertinoTabScaffold( + tabBar: CupertinoTabBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.share), + title: Text('无滑动的切换1'), ), - child: Center( - child: CupertinoButton( - child: const Text('点击我,看滑动动画'), - onPressed: () { - Navigator.of(context).push( - CupertinoPageRoute( - maintainState:false, // 是否前一个路由将保留在内存中 - builder: (BuildContext context) { // 生成器 - return pageRoute(context,index); - } - ) - ); - }, - ), + BottomNavigationBarItem( + icon: Icon(CupertinoIcons.share), + title: Text('无滑动的切换2'), ), + ], + ), + tabBuilder: (BuildContext context, int index) { + // For 1-indexed readability. + ++index; + return CupertinoTabView( + builder: (BuildContext context) { + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tab $index'), + ), + child: Center( + child: CupertinoButton( + child: const Text('点击我,看滑动动画'), + onPressed: () { + Navigator.of(context).push(CupertinoPageRoute( + maintainState: false, // 是否前一个路由将保留在内存中 + builder: (BuildContext context) { + // 生成器 + return pageRoute(context, index); + })); + }, + ), + ), + ); + }, ); }, - ); - }, - ), - ) - ); + ), + )); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoPageRoute/index.dart b/lib/widgets/themes/Cupertino/CupertinoPageRoute/index.dart index ba91f779..20821b18 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPageRoute/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPageRoute/index.dart @@ -37,11 +37,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoPageRouteFullDefault(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoPageRoute', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoPageRoute-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoPageRoute-class.html', codeUrl: 'themes/Cupertino/CupertinoPageRoute/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoPageScaffold/demo.dart b/lib/widgets/themes/Cupertino/CupertinoPageScaffold/demo.dart index bc92622c..43cf7d5a 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPageScaffold/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPageScaffold/demo.dart @@ -21,23 +21,27 @@ class _CupertinoPageScaffoldFullDefault extends State { @override Widget build(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height/1.5, - child: navigationBar(context) - ); + height: MediaQuery.of(context).size.height / 1.5, + child: navigationBar(context)); } Widget navigationBar(BuildContext context) { - return CupertinoPageScaffold( // 进入程序后显示的第一个页面,传入的是一个Widget,但实际上这个Widget需要包裹一个Scaffold - backgroundColor:CupertinoColors.inactiveGray,// 整个脚手架下面的 widget 的颜色 + return CupertinoPageScaffold( + // 进入程序后显示的第一个页面,传入的是一个Widget,但实际上这个Widget需要包裹一个Scaffold + backgroundColor: CupertinoColors.inactiveGray, // 整个脚手架下面的 widget 的颜色 navigationBar: CupertinoNavigationBar( - leading: Icon(CupertinoIcons.back),// 放置在导航栏的开头。通常是正常页面的后退按钮或完整页面对话框的取消按钮 - middle: Text('这里是标题'),// 放置在导航栏的中间。通常是标题或分段控件 - trailing: Icon(CupertinoIcons.share),// 放置在导航栏的末尾。通常在页面上执行其他操作,例如搜索或编辑功能 - ), - child: Center( - child: Text('这里是内容', style: TextStyle(color: Colors.black)) - ), // 应用程序默认路由,(Navigator.defaultRouteName,即/) - resizeToAvoidBottomInset:false // child 是否应该调整自己的大小以避免窗口的底部插入 - ); + leading: + Icon(CupertinoIcons.back), // 放置在导航栏的开头。通常是正常页面的后退按钮或完整页面对话框的取消按钮 + middle: Text('这里是标题'), // 放置在导航栏的中间。通常是标题或分段控件 + trailing: + Icon(CupertinoIcons.share), // 放置在导航栏的末尾。通常在页面上执行其他操作,例如搜索或编辑功能 + ), + child: Center( + child: Text('这里是内容', + style: TextStyle( + color: Colors + .black))), // 应用程序默认路由,(Navigator.defaultRouteName,即/) + resizeToAvoidBottomInset: false // child 是否应该调整自己的大小以避免窗口的底部插入 + ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoPageScaffold/index.dart b/lib/widgets/themes/Cupertino/CupertinoPageScaffold/index.dart index 98a41a64..5df53852 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPageScaffold/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPageScaffold/index.dart @@ -34,11 +34,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoPageScaffoldFullDefault(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoPageScaffold', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoPageScaffold-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoPageScaffold-class.html', codeUrl: 'themes/Cupertino/CupertinoPageScaffold/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoPicker/demo.dart b/lib/widgets/themes/Cupertino/CupertinoPicker/demo.dart index 26c6df4b..dbc4e099 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPicker/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPicker/demo.dart @@ -8,15 +8,33 @@ import 'package:flutter/cupertino.dart'; import 'package:intl/intl.dart'; - const double _kPickerSheetHeight = 216.0; const double _kPickerItemHeight = 32.0; const List coolColorNames = [ - 'Sarcoline', 'Coquelicot', 'Smaragdine', 'Mikado', 'Glaucous', 'Wenge', - 'Fulvous', 'Xanadu', 'Falu', 'Eburnean', 'Amaranth', 'Australien', - 'Banan', 'Falu', 'Gingerline', 'Incarnadine', 'Labrador', 'Nattier', - 'Pervenche', 'Sinoper', 'Verditer', 'Watchet', 'Zaffre', + 'Sarcoline', + 'Coquelicot', + 'Smaragdine', + 'Mikado', + 'Glaucous', + 'Wenge', + 'Fulvous', + 'Xanadu', + 'Falu', + 'Eburnean', + 'Amaranth', + 'Australien', + 'Banan', + 'Falu', + 'Gingerline', + 'Incarnadine', + 'Labrador', + 'Nattier', + 'Pervenche', + 'Sinoper', + 'Verditer', + 'Watchet', + 'Zaffre', ]; class CupertinoPickerDemo extends StatefulWidget { @@ -43,7 +61,7 @@ class _CupertinoPickerDemoState extends State { Widget _buildMenu(List children) { return Container( decoration: BoxDecoration( - color:CupertinoColors.inactiveGray, + color: CupertinoColors.inactiveGray, border: const Border( top: BorderSide(color: Color(0xFFBCBBC1), width: 0.0), bottom: BorderSide(color: Color(0xFFBCBBC1), width: 0.0), @@ -88,7 +106,7 @@ class _CupertinoPickerDemoState extends State { Widget _buildColorPicker(BuildContext context) { final FixedExtentScrollController scrollController = - FixedExtentScrollController(initialItem: _selectedColorIndex); + FixedExtentScrollController(initialItem: _selectedColorIndex); return GestureDetector( onTap: () async { @@ -97,23 +115,26 @@ class _CupertinoPickerDemoState extends State { builder: (BuildContext context) { return _buildBottomPicker( CupertinoPicker( - magnification:1.0, // 整体放大率 - //offAxisFraction:10.0,// 球面效果的透视系数,消失点位置 - scrollController: scrollController,// 用于读取和控制当前项的FixedxtentScrollController - itemExtent: _kPickerItemHeight,// 所以子节点 统一高度 - backgroundColor: CupertinoColors.white,// 所有子节点下面的背景颜色 - useMagnifier:true,// 是否使用放大效果 - onSelectedItemChanged: (int index) { // 当正中间选项改变时的回调 - if (mounted) { - setState(() => _selectedColorIndex = index); - } - }, - children: List.generate(coolColorNames.length, (int index) { - return Center(child: - Text(coolColorNames[index]), - ); - }), - ), + magnification: 1.0, // 整体放大率 + //offAxisFraction:10.0,// 球面效果的透视系数,消失点位置 + scrollController: + scrollController, // 用于读取和控制当前项的FixedxtentScrollController + itemExtent: _kPickerItemHeight, // 所以子节点 统一高度 + backgroundColor: CupertinoColors.white, // 所有子节点下面的背景颜色 + useMagnifier: true, // 是否使用放大效果 + onSelectedItemChanged: (int index) { + // 当正中间选项改变时的回调 + if (mounted) { + setState(() => _selectedColorIndex = index); + } + }, + children: + List.generate(coolColorNames.length, (int index) { + return Center( + child: Text(coolColorNames[index]), + ); + }), + ), ); }, ); @@ -123,9 +144,7 @@ class _CupertinoPickerDemoState extends State { const Text('Favorite Color'), Text( coolColorNames[_selectedColorIndex], - style: const TextStyle( - color: CupertinoColors.inactiveGray - ), + style: const TextStyle(color: CupertinoColors.inactiveGray), ), ], ), @@ -156,8 +175,8 @@ class _CupertinoPickerDemoState extends State { const Text('Countdown Timer'), Text( '${timer.inHours}:' - '${(timer.inMinutes % 60).toString().padLeft(2,'0')}:' - '${(timer.inSeconds % 60).toString().padLeft(2,'0')}', + '${(timer.inMinutes % 60).toString().padLeft(2, '0')}:' + '${(timer.inSeconds % 60).toString().padLeft(2, '0')}', style: const TextStyle(color: CupertinoColors.inactiveGray), ), ], @@ -185,15 +204,13 @@ class _CupertinoPickerDemoState extends State { }, ); }, - child: _buildMenu( - [ - const Text('Date'), - Text( - DateFormat.yMMMMd().format(date), - style: const TextStyle(color: CupertinoColors.inactiveGray), - ), - ] - ), + child: _buildMenu([ + const Text('Date'), + Text( + DateFormat.yMMMMd().format(date), + style: const TextStyle(color: CupertinoColors.inactiveGray), + ), + ]), ); } @@ -264,32 +281,28 @@ class _CupertinoPickerDemoState extends State { @override Widget build(BuildContext context) { return SizedBox( - height:MediaQuery.of(context).size.height, - child:CupertinoPageScaffold( + height: MediaQuery.of(context).size.height, + child: CupertinoPageScaffold( // navigationBar: CupertinoNavigationBar( // middle: const Text('Picker'), // previousPageTitle: 'Cupertino' // ), child: DefaultTextStyle( - style: TextStyle(), - child: DecoratedBox( - decoration: BoxDecoration( - color: CupertinoColors.inactiveGray - ), - child: ListView( - children: [ - const Padding(padding: EdgeInsets.only(top: 32.0)), - _buildColorPicker(context), - _buildCountdownTimerPicker(context), - _buildDatePicker(context), - _buildTimePicker(context), - _buildDateAndTimePicker(context), - ], + style: TextStyle(), + child: DecoratedBox( + decoration: BoxDecoration(color: CupertinoColors.inactiveGray), + child: ListView( + children: [ + const Padding(padding: EdgeInsets.only(top: 32.0)), + _buildColorPicker(context), + _buildCountdownTimerPicker(context), + _buildDatePicker(context), + _buildTimePicker(context), + _buildDateAndTimePicker(context), + ], + ), ), ), - ), - ) - ); - + )); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoPicker/index.dart b/lib/widgets/themes/Cupertino/CupertinoPicker/index.dart index 40de0df9..6dbf3a0c 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPicker/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPicker/index.dart @@ -35,11 +35,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoPickerDemo(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoPicker', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoPicker-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoPicker-class.html', codeUrl: 'themes/Cupertino/CupertinoPicker/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoPopupSurface/demo.dart b/lib/widgets/themes/Cupertino/CupertinoPopupSurface/demo.dart index a878fec5..7175d3d7 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPopupSurface/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPopupSurface/demo.dart @@ -21,19 +21,20 @@ class _CupertinoPopupSurfaceFullDefault extends State { @override Widget build(BuildContext context) { return SizedBox( - height: MediaQuery.of(context).size.height/5, - child: cupertinoPopupSurfaceBar(context) - ); + height: MediaQuery.of(context).size.height / 5, + child: cupertinoPopupSurfaceBar(context)); } Widget cupertinoPopupSurfaceBar(BuildContext context) { return CupertinoPopupSurface( - isSurfacePainted:false, + isSurfacePainted: false, child: Container( color: CupertinoColors.inactiveGray, alignment: Alignment.center, - child: Text('这里是内容', style: TextStyle(color: Colors.white)) - ), // 应用程序默认路由,(Navigator.defaultRouteName,即/) + child: Text('这里是内容', + style: TextStyle( + color: Colors + .white))), // 应用程序默认路由,(Navigator.defaultRouteName,即/) ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoPopupSurface/index.dart b/lib/widgets/themes/Cupertino/CupertinoPopupSurface/index.dart index 87392b90..75ad5a97 100644 --- a/lib/widgets/themes/Cupertino/CupertinoPopupSurface/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoPopupSurface/index.dart @@ -4,7 +4,7 @@ /// Time: 下午10:57 /// email: zhu.yan@alibaba-inc.com /// target: CupertinoPopupSurface 的示例 - + import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import './demo.dart' as demoBox; @@ -33,11 +33,12 @@ class _DemoState extends State { content0, content1, demoBox.CupertinoPopupSurfaceFullDefault(), - SizedBox(height:50) + SizedBox(height: 50) ], title: 'CupertinoPopupSurface', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoPopupSurface-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoPopupSurface-class.html', codeUrl: 'themes/Cupertino/CupertinoPopupSurface/demo.dart', ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoScrollbar/demo.dart b/lib/widgets/themes/Cupertino/CupertinoScrollbar/demo.dart index 35abb32e..9e4dffc5 100644 --- a/lib/widgets/themes/Cupertino/CupertinoScrollbar/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoScrollbar/demo.dart @@ -22,7 +22,8 @@ class _Demo extends State { height: 300, child: ListView.custom( scrollDirection: Axis.vertical, - childrenDelegate:SliverChildBuilderDelegate((BuildContext context, int index) { + childrenDelegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { return Container( height: 50.0, alignment: Alignment.center, @@ -30,9 +31,7 @@ class _Demo extends State { child: Text('list item $index'), ); }, childCount: 10), - ) - ) - ), + ))), Center( child: Text("CupertinoScrollbar效果"), ) @@ -41,7 +40,6 @@ class _Demo extends State { } } - class NoCupertinoScrollbarDemo extends StatefulWidget { _NoCupertinoScrollbarDemo createState() => _NoCupertinoScrollbarDemo(); } @@ -55,7 +53,8 @@ class _NoCupertinoScrollbarDemo extends State { height: 300, child: ListView.custom( scrollDirection: Axis.vertical, - childrenDelegate:SliverChildBuilderDelegate((BuildContext context, int index) { + childrenDelegate: + SliverChildBuilderDelegate((BuildContext context, int index) { return Container( height: 50.0, alignment: Alignment.center, @@ -63,8 +62,7 @@ class _NoCupertinoScrollbarDemo extends State { child: Text('list item $index'), ); }, childCount: 10), - ) - ), + )), Center( child: Text("无CupertinoScrollbar效果"), ) diff --git a/lib/widgets/themes/Cupertino/CupertinoScrollbar/index.dart b/lib/widgets/themes/Cupertino/CupertinoScrollbar/index.dart index 93f14914..979e4cbe 100644 --- a/lib/widgets/themes/Cupertino/CupertinoScrollbar/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoScrollbar/index.dart @@ -30,7 +30,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoScrollbar', codeUrl: 'themes/Cupertino/CupertinoScrollbar/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/material/MaterialAccentColor-class.html', + docUrl: + 'https://docs.flutter.io/flutter/material/MaterialAccentColor-class.html', contentList: [ Text0, Text1, diff --git a/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/demo.dart b/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/demo.dart index 20aeac97..768a45c1 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/demo.dart @@ -1,4 +1,3 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -10,10 +9,10 @@ class _Demo extends State { String value = 'a'; @override Widget build(BuildContext context) { - return CupertinoSegmentedControl( + return CupertinoSegmentedControl( onValueChanged: (v) { this.setState(() { - value = v; + value = v; }); }, pressedColor: Color(0xff7c1c25), @@ -22,15 +21,10 @@ class _Demo extends State { groupValue: value, children: { 'a': Container( - alignment: Alignment.center, - width: 130.0, - child: Text('a') - ), + alignment: Alignment.center, width: 130.0, child: Text('a')), 'c': Text('C'), 'b': Text('B'), }, ); } - } - diff --git a/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/index.dart b/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/index.dart index 5063c7d2..f731c0e3 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSegmentedControl/index.dart @@ -20,7 +20,6 @@ const Text0 = ''' 样式支持用户自定义. '''; - class Demo extends StatefulWidget { static const String routeName = '/element/themes/Cupertino/CupertinoSegmentedControl'; @@ -35,7 +34,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoSegmentedControl', codeUrl: '/hemes/Cupertino/CupertinoSegmentedControl/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoSegmentedControl-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoSegmentedControl-class.html', contentList: [ Text0, CupertinoSegmentedControlDemo(), diff --git a/lib/widgets/themes/Cupertino/CupertinoSlider/demo.dart b/lib/widgets/themes/Cupertino/CupertinoSlider/demo.dart index 1ddded71..fe36bc93 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSlider/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSlider/demo.dart @@ -16,19 +16,17 @@ class _Demo extends State { double value = 0.0; @override Widget build(BuildContext context) { - return CupertinoSlider( - value: value,//实际进度的位置 + return CupertinoSlider( + value: value, //实际进度的位置 min: 0.0, max: 100.0, divisions: 100, - activeColor: Colors.blue,//进度中活动部分的颜色 - onChanged: (double){ + activeColor: Colors.blue, //进度中活动部分的颜色 + onChanged: (double) { setState(() { value = double.roundToDouble(); }); }, ); } - } - diff --git a/lib/widgets/themes/Cupertino/CupertinoSlider/index.dart b/lib/widgets/themes/Cupertino/CupertinoSlider/index.dart index 8d993208..af0b7a10 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSlider/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSlider/index.dart @@ -15,8 +15,7 @@ CupertinoSlider 是ios风格的Slide组件,用来选择连续性的或者非连 '''; class Demo extends StatefulWidget { - static const String routeName = - '/element/themes/Cupertino/CupertinoSlider'; + static const String routeName = '/element/themes/Cupertino/CupertinoSlider'; @override State createState() => _DemoState(); @@ -28,7 +27,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoSlider', codeUrl: 'themes/Cupertino/CupertinoSlider/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoSlider-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoSlider-class.html', contentList: [ Text0, CupertinoSliderDemo(), diff --git a/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/demo.dart b/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/demo.dart index 5e272294..922334da 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/demo.dart @@ -18,44 +18,46 @@ class _Demo extends State { Widget build(BuildContext context) { return CupertinoPageScaffold( child: DecoratedBox( - decoration: const BoxDecoration(color: Color(0xFFEFEFF4)), - child: Container( - height: 600.0, - child: CustomScrollView( - slivers: [ - CupertinoSliverNavigationBar( - largeTitle: const Text('demo', maxLines: 1,), - previousPageTitle: 'Cupertino', - trailing: Icon(Icons.perm_camera_mic) - ), - CupertinoSliverRefreshControl( + decoration: const BoxDecoration(color: Color(0xFFEFEFF4)), + child: Container( + height: 600.0, + child: CustomScrollView( + slivers: [ + CupertinoSliverNavigationBar( + largeTitle: const Text( + 'demo', + maxLines: 1, + ), + previousPageTitle: 'Cupertino', + trailing: Icon(Icons.perm_camera_mic)), + CupertinoSliverRefreshControl( // onRefresh: () { // // }, - ), - SliverSafeArea( - top: false, // Top safe area is consumed by the navigation bar. - sliver: SliverList( - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { - return _ListItem(name: 'name$index',place: 'place$index', date: 'date', called: true); - }, - childCount: 20, + ), + SliverSafeArea( + top: + false, // Top safe area is consumed by the navigation bar. + sliver: SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return _ListItem( + name: 'name$index', + place: 'place$index', + date: 'date', + called: true); + }, + childCount: 20, + ), ), ), - ), - ], - ), - ) - ), + ], + ), + )), ); } - } - - - class _ListItem extends StatelessWidget { const _ListItem({ this.name, @@ -82,13 +84,13 @@ class _ListItem extends StatelessWidget { margin: EdgeInsets.only(top: 10), child: called ? const Align( - alignment: Alignment.topCenter, - child: Icon( - CupertinoIcons.phone_solid, - color: CupertinoColors.inactiveGray, - size: 28.0, - ), - ) + alignment: Alignment.topCenter, + child: Icon( + CupertinoIcons.phone_solid, + color: CupertinoColors.inactiveGray, + size: 28.0, + ), + ) : null, ), Expanded( @@ -98,7 +100,8 @@ class _ListItem extends StatelessWidget { bottom: BorderSide(color: Color(0xFFBCBBC1), width: 0.0), ), ), - padding: const EdgeInsets.only(left: 1.0, bottom: 9.0, right: 10.0), + padding: + const EdgeInsets.only(left: 1.0, bottom: 9.0, right: 10.0), child: Row( children: [ Expanded( @@ -138,10 +141,8 @@ class _ListItem extends StatelessWidget { ), const Padding( padding: EdgeInsets.only(left: 9.0), - child: Icon( - CupertinoIcons.info, - color: CupertinoColors.activeBlue - ), + child: Icon(CupertinoIcons.info, + color: CupertinoColors.activeBlue), ), ], ), diff --git a/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/index.dart b/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/index.dart index 3cd0ffc8..1c012d6b 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSliverNavigationBar/index.dart @@ -12,7 +12,6 @@ const Text0 = ''' > 该组件使用时. 必须做为含有slivers属性的滚动列表的子组件中,例如CustomScrollView '''; - class Demo extends StatefulWidget { static const String routeName = '/element/themes/Cupertino/CupertinoSliverNavigationBar'; @@ -27,7 +26,8 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoSlider', codeUrl: 'themes/Cupertino/CupertinoSliverNavigationBar/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoSliverNavigationBar-class.html', + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoSliverNavigationBar-class.html', contentList: [ Text0, CupertinoSliverNavigationBarDemo(), diff --git a/lib/widgets/themes/Cupertino/CupertinoSwitch/demo.dart b/lib/widgets/themes/Cupertino/CupertinoSwitch/demo.dart index d677dd0a..a2b6c7aa 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSwitch/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSwitch/demo.dart @@ -22,12 +22,18 @@ class _Demo extends State { trailing: CupertinoSwitch( activeColor: Colors.yellow, value: _lights, - onChanged: (bool value) { setState(() { _lights = value; }); }, + onChanged: (bool value) { + setState(() { + _lights = value; + }); + }, ), - onTap: () { setState(() { _lights = !_lights; }); }, + onTap: () { + setState(() { + _lights = !_lights; + }); + }, ), ); } - } - diff --git a/lib/widgets/themes/Cupertino/CupertinoSwitch/index.dart b/lib/widgets/themes/Cupertino/CupertinoSwitch/index.dart index 94b9ac68..e8bd1447 100644 --- a/lib/widgets/themes/Cupertino/CupertinoSwitch/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoSwitch/index.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart'; + const Text0 = ''' ### **简介** > ios风格下的Switch组件, 用法与Switch组件相同 @@ -12,10 +13,8 @@ const Text0 = ''' > 基本用法与Switch基本相同. 不同点在于, 该组件仅支持自定义activeColor, 也就是支持自定义当按钮处于true状态下,按钮的背景色. '''; - class Demo extends StatefulWidget { - static const String routeName = - '/element/themes/Cupertino/CupertinoSwitch'; + static const String routeName = '/element/themes/Cupertino/CupertinoSwitch'; @override State createState() => _DemoState(); @@ -27,11 +26,9 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoSlider', codeUrl: 'themes/Cupertino/CupertinoSwitch/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoSwitch-class.html', - contentList: [ - Text0, - CupertinoSwitchDemo() - ], + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoSwitch-class.html', + contentList: [Text0, CupertinoSwitchDemo()], ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoTabBar/demo.dart b/lib/widgets/themes/Cupertino/CupertinoTabBar/demo.dart index c6794121..eaeedd0f 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabBar/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabBar/demo.dart @@ -20,13 +20,15 @@ class _Demo extends State { index = _index; }); } + @override Widget build(BuildContext context) { return Container( height: 500, child: Scaffold( appBar: AppBar(title: const Text('CupertinoTabBarDemo')), - floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + floatingActionButtonLocation: + FloatingActionButtonLocation.centerDocked, body: Center( child: Text('CupertinoTabBarDemo in bottom'), ), @@ -42,11 +44,9 @@ class _Demo extends State { icon: Icon(Icons.add), ), BottomNavigationBarItem( - title: Text("2"), - icon: Icon(Icons.delete) - )], - ) - ), + title: Text("2"), icon: Icon(Icons.delete)) + ], + )), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoTabBar/index.dart b/lib/widgets/themes/Cupertino/CupertinoTabBar/index.dart index c2cd0106..4c99c8e3 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabBar/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabBar/index.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart'; + const Text0 = ''' ### **简介** > ios风格下底部导航组件. @@ -20,10 +21,8 @@ const Text0 = ''' 本人试了很多次. 也没有发现这个Blur Effect是怎么触发的, 如果有人了解, 欢迎提PR. '''; - class Demo extends StatefulWidget { - static const String routeName = - '/element/themes/Cupertino/CupertinoTabBar'; + static const String routeName = '/element/themes/Cupertino/CupertinoTabBar'; @override State createState() => _DemoState(); @@ -35,11 +34,9 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoTabBar', codeUrl: 'themes/Cupertino/CupertinoTabBar/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoTabBar-class.html', - contentList: [ - Text0, - CupertinoTabBarDemo() - ], + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoTabBar-class.html', + contentList: [Text0, CupertinoTabBarDemo()], ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoTabScaffold/demo.dart b/lib/widgets/themes/Cupertino/CupertinoTabScaffold/demo.dart index fde03721..b1770173 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabScaffold/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabScaffold/demo.dart @@ -20,13 +20,14 @@ class _Demo extends State { index = _index; }); } + @override Widget build(BuildContext context) { return SizedBox( height: 500, child: CupertinoTabScaffold( tabBar: CupertinoTabBar( - items: [ + items: [ BottomNavigationBarItem( title: Text("1"), icon: Icon(Icons.add), @@ -58,7 +59,9 @@ class _Demo extends State { child: Center( child: CupertinoButton( child: const Text('Back'), - onPressed: () { Navigator.of(context).pop(); }, + onPressed: () { + Navigator.of(context).pop(); + }, ), ), ); @@ -75,4 +78,4 @@ class _Demo extends State { ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoTabScaffold/index.dart b/lib/widgets/themes/Cupertino/CupertinoTabScaffold/index.dart index fe736adc..f9dcbc77 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabScaffold/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabScaffold/index.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_go/components/widget_demo.dart'; import 'demo.dart'; + const Text0 = ''' ### **简介** @@ -26,7 +27,6 @@ const Text0 = ''' '''; - class Demo extends StatefulWidget { static const String routeName = '/element/themes/Cupertino/CupertinoTabScaffold'; @@ -41,11 +41,9 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoTabScaffold', codeUrl: 'themes/Cupertino/CupertinoTabScaffold/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoTabScaffold-class.html', - contentList: [ - Text0, - CupertinoTabScaffoldDemo() - ], + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoTabScaffold-class.html', + contentList: [Text0, CupertinoTabScaffoldDemo()], ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoTabView/demo.dart b/lib/widgets/themes/Cupertino/CupertinoTabView/demo.dart index a0b61b08..e73153e0 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabView/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabView/demo.dart @@ -20,13 +20,14 @@ class _Demo extends State { index = _index; }); } + @override Widget build(BuildContext context) { return SizedBox( height: 500, child: CupertinoTabScaffold( tabBar: CupertinoTabBar( - items: [ + items: [ BottomNavigationBarItem( title: Text("A"), icon: Icon(Icons.add), @@ -42,9 +43,9 @@ class _Demo extends State { routes: { '/': (context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 1 of tabView $index'), - ), + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tabView $index'), + ), child: Center( child: Text('CupertinoTabView /'), ), @@ -63,9 +64,9 @@ class _Demo extends State { }, builder: (BuildContext context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( - middle: Text('Page 1 of tabView $index'), - ), + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tabView $index'), + ), child: Column( children: [ SizedBox(height: 100), @@ -78,16 +79,16 @@ class _Demo extends State { CupertinoButton( child: Text('Next page is home home page'), onPressed: () { - Navigator.of(context, rootNavigator: true).pushNamed('/home'); + Navigator.of(context, rootNavigator: true) + .pushNamed('/home'); }, ) ], - ) - ); + )); }, ); }, ), ); } -} \ No newline at end of file +} diff --git a/lib/widgets/themes/Cupertino/CupertinoTabView/index.dart b/lib/widgets/themes/Cupertino/CupertinoTabView/index.dart index ad72bb6f..e10c7d9d 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTabView/index.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTabView/index.dart @@ -30,10 +30,8 @@ Navigator.of(context, rootNavigator: true) '''; - class Demo extends StatefulWidget { - static const String routeName = - '/element/themes/Cupertino/CupertinoTabView'; + static const String routeName = '/element/themes/Cupertino/CupertinoTabView'; @override State createState() => _DemoState(); @@ -45,11 +43,9 @@ class _DemoState extends State { return WidgetDemo( title: 'CupertinoTabView', codeUrl: 'themes/Cupertino/CupertinoTabView/demo.dart', - docUrl: 'https://docs.flutter.io/flutter/cupertino/CupertinoTabView-class.html', - contentList: [ - Text0, - CupertinoTabScaffoldDemo() - ], + docUrl: + 'https://docs.flutter.io/flutter/cupertino/CupertinoTabView-class.html', + contentList: [Text0, CupertinoTabScaffoldDemo()], ); } } diff --git a/lib/widgets/themes/Cupertino/CupertinoTimerPicker/demo.dart b/lib/widgets/themes/Cupertino/CupertinoTimerPicker/demo.dart index fdd8d3f1..748aae0d 100644 --- a/lib/widgets/themes/Cupertino/CupertinoTimerPicker/demo.dart +++ b/lib/widgets/themes/Cupertino/CupertinoTimerPicker/demo.dart @@ -8,8 +8,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - - class CupertinoTimerPickerDemo extends StatefulWidget { _Demo createState() => _Demo(); } @@ -39,6 +37,7 @@ class _Demo extends State { ), ); } + @override Widget build(BuildContext context) { return GestureDetector( diff --git a/lib/widgets/themes/Cupertino/index.dart b/lib/widgets/themes/Cupertino/index.dart index 2f8b8cbc..e9cd56aa 100644 --- a/lib/widgets/themes/Cupertino/index.dart +++ b/lib/widgets/themes/Cupertino/index.dart @@ -13,7 +13,8 @@ import './CupertinoPopupSurface/index.dart' as CupertinoPopupSurface; import './CupertinoScrollbar/index.dart' as CupertinoScrollbar; import './CupertinoSlider/index.dart' as CupertinoSlider; import './CupertinoSegmentedControl/index.dart' as CupertinoSegmentedControl; -import './CupertinoSliverNavigationBar/index.dart' as CupertinoSliverNavigationBar; +import './CupertinoSliverNavigationBar/index.dart' + as CupertinoSliverNavigationBar; import './CupertinoSwitch/index.dart' as CupertinoSwitch; import './CupertinoTabBar/index.dart' as CupertinoTabBar; import './CupertinoTabScaffold/index.dart' as CupertinoTabScaffold; @@ -117,4 +118,3 @@ List widgetPoints = [ buildRouter: (BuildContext context) => CupertinoTimerPicker.Demo(), ), ]; - diff --git a/lib/widgets/themes/Material/MaterialApp/demo.dart b/lib/widgets/themes/Material/MaterialApp/demo.dart index b06a5f78..61333cb0 100644 --- a/lib/widgets/themes/Material/MaterialApp/demo.dart +++ b/lib/widgets/themes/Material/MaterialApp/demo.dart @@ -1,8 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:25 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-27 16:25:25 - +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:25 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-27 16:25:25 // !!! 代码示例,并非Demo // import 'package:flutter/material.dart'; diff --git a/lib/widgets/themes/Material/MaterialApp/index.dart b/lib/widgets/themes/Material/MaterialApp/index.dart index 0285bc1d..a3a2af72 100644 --- a/lib/widgets/themes/Material/MaterialApp/index.dart +++ b/lib/widgets/themes/Material/MaterialApp/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:22 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:22 /// @Last Modified by: 一凨 /// @Last Modified time: 2019-01-07 15:52:45 diff --git a/lib/widgets/themes/Material/MaterialButton/demo.dart b/lib/widgets/themes/Material/MaterialButton/demo.dart index baa68e36..3cbfb5f7 100644 --- a/lib/widgets/themes/Material/MaterialButton/demo.dart +++ b/lib/widgets/themes/Material/MaterialButton/demo.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:25 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-27 16:25:25 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:25 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-27 16:25:25 import 'package:flutter/material.dart'; diff --git a/lib/widgets/themes/Material/MaterialButton/index.dart b/lib/widgets/themes/Material/MaterialButton/index.dart index 3fb955b3..d0f86620 100644 --- a/lib/widgets/themes/Material/MaterialButton/index.dart +++ b/lib/widgets/themes/Material/MaterialButton/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:22 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:22 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 16:35:39 diff --git a/lib/widgets/themes/Material/MaterialColor/demo.dart b/lib/widgets/themes/Material/MaterialColor/demo.dart index ff466379..b9664f2e 100644 --- a/lib/widgets/themes/Material/MaterialColor/demo.dart +++ b/lib/widgets/themes/Material/MaterialColor/demo.dart @@ -1,7 +1,7 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:25 -/// @Last Modified by: 一凨 -/// @Last Modified time: 2018-12-27 16:25:25 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:25 +/// @Last Modified by: 一凨 +/// @Last Modified time: 2018-12-27 16:25:25 import 'package:flutter/material.dart'; diff --git a/lib/widgets/themes/Material/MaterialColor/index.dart b/lib/widgets/themes/Material/MaterialColor/index.dart index 79117f93..a6f056d8 100644 --- a/lib/widgets/themes/Material/MaterialColor/index.dart +++ b/lib/widgets/themes/Material/MaterialColor/index.dart @@ -1,5 +1,5 @@ -/// @Author: 一凨 -/// @Date: 2018-12-27 16:25:22 +/// @Author: 一凨 +/// @Date: 2018-12-27 16:25:22 /// @Last Modified by: 一凨 /// @Last Modified time: 2018-12-27 16:35:39 diff --git a/lib/widgets/themes/Material/MaterialPageRoute/demo.dart b/lib/widgets/themes/Material/MaterialPageRoute/demo.dart index 726dd428..ba120f31 100644 --- a/lib/widgets/themes/Material/MaterialPageRoute/demo.dart +++ b/lib/widgets/themes/Material/MaterialPageRoute/demo.dart @@ -14,18 +14,18 @@ class FirstPage extends StatefulWidget { } class _FirstPageState extends State { - var _usernameController = TextEditingController(); - var _emailController = TextEditingController(); + var _usernameController = TextEditingController(); + var _emailController = TextEditingController(); @override Widget build(BuildContext context) { return Column( children: [ Padding( - child: Text( + child: Text( "账号登录", textAlign: TextAlign.center, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), padding: EdgeInsets.only(bottom: 10.0), ), @@ -37,11 +37,11 @@ class _FirstPageState extends State { decoration: InputDecoration(labelText: "email"), controller: _emailController, ), - RaisedButton( + RaisedButton( child: Text("点击跳转"), onPressed: () { - var route = MaterialPageRoute( - builder: (BuildContext context) => SecondPage( + var route = MaterialPageRoute( + builder: (BuildContext context) => SecondPage( value: User( account: _usernameController.text, email: _emailController.text)), @@ -65,21 +65,21 @@ class SecondPage extends StatefulWidget { class _SecondPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( + return Scaffold( + appBar: AppBar( title: Text("MaterialPageRoute2"), ), - body: Container( - child: Center( + body: Container( + child: Center( child: Column( children: [ Container( padding: EdgeInsets.only(top: 30.0), - child: Text("登陆成功!!!", + child: Text("登陆成功!!!", style: TextStyle( fontSize: 28, fontWeight: FontWeight.bold))), Padding( - child: Text( + child: Text( 'account:${widget.value.account}', textAlign: TextAlign.center, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), @@ -87,7 +87,7 @@ class _SecondPageState extends State { padding: EdgeInsets.only(bottom: 20.0, top: 40.0), ), Padding( - child: Text( + child: Text( 'email:${widget.value.email}', textAlign: TextAlign.center, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), diff --git a/lib/widgets/themes/Material/MergeableMaterialItem/demo.dart b/lib/widgets/themes/Material/MergeableMaterialItem/demo.dart index e5d0b3aa..185485e4 100644 --- a/lib/widgets/themes/Material/MergeableMaterialItem/demo.dart +++ b/lib/widgets/themes/Material/MergeableMaterialItem/demo.dart @@ -1,9 +1,8 @@ - - /// Author: xiaojia.dxj - /// Date: 2019-01-08 11:33:21 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 15:24:14 +/// Author: xiaojia.dxj +/// Date: 2019-01-08 11:33:21 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 15:24:14 import 'package:flutter/material.dart'; @@ -28,17 +27,17 @@ class _MergeableMaterialItemState extends State { items.add( //class MaterialSlice extends MergeableMaterialItem - MaterialSlice( - key: ValueKey(currIndexNum), - child: Column(children: [ + MaterialSlice( + key: ValueKey(currIndexNum), + child: Column(children: [ // header, - AnimatedCrossFade( - firstChild: Container( + AnimatedCrossFade( + firstChild: Container( height: 20.0, width: 20.0, color: Colors.green, ), - secondChild: Container( + secondChild: Container( height: 20.0, width: 20.0, color: Colors.red, @@ -57,8 +56,8 @@ class _MergeableMaterialItemState extends State { return Column( children: [ - MergeableMaterial(hasDividers: true, children: items), - RaisedButton( + MergeableMaterial(hasDividers: true, children: items), + RaisedButton( child: Text("点击添加"), onPressed: () { _isChildExpanded(); diff --git a/lib/widgets/themes/Material/MergeableMaterialItem/index.dart b/lib/widgets/themes/Material/MergeableMaterialItem/index.dart index fafc2240..5e4a8a6e 100644 --- a/lib/widgets/themes/Material/MergeableMaterialItem/index.dart +++ b/lib/widgets/themes/Material/MergeableMaterialItem/index.dart @@ -1,8 +1,8 @@ - /// Author: xiaojia.dxj - /// Date: 2019-01-07 16:36:43 - /// Email: xiaojia.dxj@alibaba-inc.com - /// Last Modified by: xiaojia.dxj - /// Last Modified time: 2019-01-08 14:12:32 +/// Author: xiaojia.dxj +/// Date: 2019-01-07 16:36:43 +/// Email: xiaojia.dxj@alibaba-inc.com +/// Last Modified by: xiaojia.dxj +/// Last Modified time: 2019-01-08 14:12:32 import 'package:flutter/material.dart'; diff --git a/lib/widgets/themes/Material/index.dart b/lib/widgets/themes/Material/index.dart index 2ef1f607..b405e045 100644 --- a/lib/widgets/themes/Material/index.dart +++ b/lib/widgets/themes/Material/index.dart @@ -8,7 +8,6 @@ import 'MaterialButton/index.dart' as MaterialButton; import 'MaterialColor/index.dart' as MaterialColor; import 'MergeableMaterialItem/index.dart' as MergeableMaterialItem; - List widgetPoints = [ WidgetPoint( name: 'MaterialPageRoute', @@ -30,8 +29,7 @@ List widgetPoints = [ routerName: MaterialButton.Demo.routeName, buildRouter: (BuildContext context) => MaterialButton.Demo(), ), - -WidgetPoint( + WidgetPoint( name: 'MaterialAccentColor', routerName: MaterialAccentColor.Demo.routeName, buildRouter: (BuildContext context) => MaterialAccentColor.Demo(), @@ -41,5 +39,4 @@ WidgetPoint( routerName: MergeableMaterialItem.Demo.routeName, buildRouter: (BuildContext context) => MergeableMaterialItem.Demo(), ), - ]; diff --git a/lib/widgets/themes/index.dart b/lib/widgets/themes/index.dart index b263753b..350b683c 100644 --- a/lib/widgets/themes/index.dart +++ b/lib/widgets/themes/index.dart @@ -1,7 +1,7 @@ /// @Author: xiaojia.dxj -/// @Date: 2018-12-24 16:31:09 +/// @Date: 2018-12-24 16:31:09 /// @Last Modified by: xiaojia.dxj -/// @Last Modified time: 2018-12-24 16:31:09 +/// @Last Modified time: 2018-12-24 16:31:09 import './Material/index.dart' as Material; import './Cupertino/index.dart' as Cupertino; @@ -11,4 +11,4 @@ List getWidgets() { result.addAll(Material.widgetPoints); result.addAll(Cupertino.widgetPoints); return result; -} \ No newline at end of file +}