diff --git a/README.md b/README.md index ebbf363a..0973799f 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ iphone下载地址: ### 背景 -#### Flutter 是什么 +#### Flutter 是什么? 2018年6月21日Google发布Flutter首个release预览版,作为Google 大力推出的一种全新的响应式,跨平台,高性能的移动开发框架。Flutter是一个跨平台的移动UI框架,旨在帮助开发者使用一套代码开发高性能、高保真的Android和iOS应用。 diff --git a/android/build.gradle b/android/build.gradle index d4225c79..e81b1a1d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' + classpath 'com.android.tools.build:gradle:3.2.0' } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 9372d0f3..03824124 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jun 23 08:50:38 CEST 2017 +#Thu Jan 10 15:37:36 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/assets/images/nothing.png b/assets/images/nothing.png new file mode 100644 index 00000000..1279985f Binary files /dev/null and b/assets/images/nothing.png differ diff --git a/lib/common/iconNames.dart b/lib/common/iconNames.dart index a9d0f02a..e8ce0e71 100644 --- a/lib/common/iconNames.dart +++ b/lib/common/iconNames.dart @@ -6,7 +6,6 @@ * email: zhu.yan@alibaba-inc.com * tartget: FlatButton 的示例 */ -import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; diff --git a/lib/common/list_view_item.dart b/lib/common/list_view_item.dart new file mode 100644 index 00000000..cef7d7a4 --- /dev/null +++ b/lib/common/list_view_item.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class ListViewItem extends StatelessWidget { + final String itemUrl; + final String itemTitle; + final String data; + + const ListViewItem({Key key, this.itemUrl, this.itemTitle, this.data}) + : super(key: key); + + void _launchURL(String url, BuildContext context) async { + + if (await canLaunch(url)) { + await launch(url); + } else { + throw 'Could not launch $url'; + } + + } + + @override + Widget build(BuildContext context) { + return Card( + color: Colors.white, + elevation: 4.0, + margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0), + child: ListTile( + onTap: () { + _launchURL(itemUrl, context); + }, + title: Padding( + child: Text( + itemTitle, + style: TextStyle(color: Colors.black, fontSize: 15.0), + ), + padding: EdgeInsets.only(top: 10.0), + ), + subtitle: Row( + children: [ + Padding( + child: Text(data, + style: TextStyle(color: Colors.black54, fontSize: 10.0)), + padding: EdgeInsets.only(top: 10.0, bottom: 10.0), + ) + ], + ), + trailing: + Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0), + ), + ); + } +} diff --git a/lib/common/myListView.dart b/lib/common/myListView.dart deleted file mode 100644 index ac50f3d2..00000000 --- a/lib/common/myListView.dart +++ /dev/null @@ -1,70 +0,0 @@ - -import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class MyListView extends StatelessWidget { - -final String currCodeUrl; -final String currTitle; -final String developer; - -const MyListView({ Key key,this.currCodeUrl, this.currTitle, this.developer}): -super(key:key); - - - void _launchURL(String url) async { - if (await canLaunch(url)) { - await launch(url); - } else { - throw 'Could not launch $url'; - } - } - - @override - Widget build(BuildContext context) { - return Card( - //color: Colors.primaries[index % Colors.primaries.length], - color: Colors.white, - elevation: 4.0, - margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0), - child:ListTile( - onTap:(){ - print('codeUrl:${currCodeUrl}'); - _launchURL(currCodeUrl); - }, - // contentPadding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 1.0), - // leading: Container( - // padding: EdgeInsets.only(right: 12.0), - // decoration: new BoxDecoration( - // border: new Border( - // right: new BorderSide(width: 1.0, color: Colors.grey))), - // child: Icon(smallParts_icon, color: smallParts_Color), - // ), - title: Padding( - child: Text( - - currTitle, - style: TextStyle(color: Colors.black,fontSize:15.0), - - ), - padding: EdgeInsets.only(top: 10.0), - ), - // subtitle: Text("Intermediate", style: TextStyle(color: Colors.white)), - - subtitle: Row( - - children: [ - Padding( - child: Text( developer, style: TextStyle(color: Colors.black54,fontSize:10.0) - ), - padding:EdgeInsets.only(top: 10.0,bottom: 10.0), - ) - //Icon(Icons.linear_scale, color: smallParts_Color), - - ], - ), - trailing: Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0) - ) - ); - } -} \ No newline at end of file diff --git a/lib/common/provider.dart b/lib/common/provider.dart index d178c46c..8540d671 100644 --- a/lib/common/provider.dart +++ b/lib/common/provider.dart @@ -14,18 +14,21 @@ class Provider { //Get a location using getDatabasesPath String databasesPath = await getDatabasesPath(); String path = join(databasesPath, 'flutter.db'); - List list; - // try { - // db = await openDatabase(path, readOnly: true); - - // } catch (e) { - // print("Error $e"); - // } + List tables; + try { + db = await openDatabase(path); + tables = await db + .rawQuery('SELECT name FROM sqlite_master WHERE type = "table"'); + print('${tables.length} 7891'); + } catch (e) { + print("Error $e"); + } - if (db == null) { + if (tables.length < 3) { // Delete the database await deleteDatabase(path); - + // 关闭上面打开的db,否则无法执行open + db.close(); ByteData data = await rootBundle.load(join("assets", "app.db")); List bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); diff --git a/lib/common/sql.dart b/lib/common/sql.dart index 5bb10f69..b6dd620a 100644 --- a/lib/common/sql.dart +++ b/lib/common/sql.dart @@ -69,7 +69,7 @@ class Sql extends BaseModel { /// @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(); } @@ -88,7 +88,7 @@ class Sql extends BaseModel { } if (index >= 0 && index < conditions.length -1) { - stringConditions = '$stringConditions $Mods'; + stringConditions = '$stringConditions $mods'; } index++; }); diff --git a/lib/common/widget-demo.dart b/lib/common/widget-demo.dart index 7c82237e..b359e4d3 100644 --- a/lib/common/widget-demo.dart +++ b/lib/common/widget-demo.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; -import '../routers/application.dart'; class WidgetDemo extends StatelessWidget { final Widget child; diff --git a/lib/common/widget_demo.dart b/lib/common/widget_demo.dart index 9747dd43..34aaaec2 100644 --- a/lib/common/widget_demo.dart +++ b/lib/common/widget_demo.dart @@ -10,6 +10,8 @@ import '../components/markdown.dart'; import '../model/collection.dart'; import '../widgets/index.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import '../event/event-bus.dart'; +import '../event/event-model.dart'; class WidgetDemo extends StatefulWidget { final List contentList; @@ -31,7 +33,6 @@ class WidgetDemo extends StatefulWidget { class _WidgetDemoState extends State { bool _hasCollected = false; CollectionControlModel _collectionControl = new CollectionControlModel(); - Collection _collection; Color _collectionColor; List widgetDemosList = new WidgetDemoList().getDemos(); String _router = ''; @@ -84,9 +85,11 @@ class _WidgetDemoState extends State { _router = item.routerName; } }); - setState(() { - _hasCollected = list.length > 0; - }); + if (this.mounted) { + setState(() { + _hasCollected = list.length > 0; + }); + } }); } @@ -100,6 +103,11 @@ class _WidgetDemoState extends State { _hasCollected = false; }); showInSnackBar('已取消收藏'); + + if (ApplicationEvent.event != null) { + ApplicationEvent.event + .fire(CollectionEvent(widget.title, _router, true)); + } return; } print('删除错误'); @@ -113,37 +121,41 @@ class _WidgetDemoState extends State { setState(() { _hasCollected = true; }); + + if (ApplicationEvent.event != null) { + ApplicationEvent.event + .fire(CollectionEvent(widget.title, _router, false)); + } + showInSnackBar('收藏成功'); } }); } } + void _selectValue(value){ + if(value == 'doc'){ + _launchURL(widget.docUrl); + }else if(value =='code'){ + _launchURL(Application.github['widgetsURL'] + widget.codeUrl); + }else{ + _getCollection(); + } + } + @override Widget build(BuildContext context) { if (_hasCollected) { - _collectionColor = Colors.yellow; + _collectionColor = Colors.red; + _router='取消收藏'; } else { - _collectionColor = Colors.white; + _collectionColor =null; + _router='组件收藏'; } return Scaffold( appBar: AppBar( title: Text(widget.title), actions: [ - new IconButton( - tooltip: 'widget doc', - onPressed: () { - _launchURL(widget.docUrl); - }, - icon: Icon(Icons.library_books), - ), - new IconButton( - tooltip: 'github code', - onPressed: () { - _launchURL(Application.github['widgetsURL'] + widget.codeUrl); - }, - icon: Icon(Icons.code), - ), new IconButton( tooltip: 'goBack home', onPressed: () { @@ -151,6 +163,35 @@ class _WidgetDemoState extends State { }, icon: Icon(Icons.home), ), + PopupMenuButton( + onSelected: _selectValue, + itemBuilder: (BuildContext context) => >[ + const PopupMenuItem( + value: 'doc', + child: ListTile( + leading: Icon(Icons.library_books,size: 22.0,), + title: Text('查看文档'), + ), + ), + const PopupMenuDivider(), + const PopupMenuItem( + value: 'code', + child: ListTile( + leading: Icon(Icons.code,size: 22.0,), + title: Text('查看Demo'), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + value: 'collection', + child: ListTile( + leading: Icon(Icons.star,size: 22.0,color: _collectionColor,), + title: Text(_router), + + ), + ), + ], + ), ], ), body: Container( @@ -165,15 +206,6 @@ class _WidgetDemoState extends State { ], ), ), - floatingActionButton: FloatingActionButton( - onPressed: _getCollection, - tooltip: '收藏', - child: Icon( - Icons.star, - color: _collectionColor, - ), - backgroundColor: Theme.of(context).primaryColor, - ), ); } } diff --git a/lib/components/CompList.dart b/lib/components/CompList.dart index 864e6db8..580c41da 100644 --- a/lib/components/CompList.dart +++ b/lib/components/CompList.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_rookie_book/views/Detail.dart'; + + class CompList extends StatefulWidget { @override State createState() { - // TODO: implement createState return new ListState(); } } diff --git a/lib/components/ListRefresh.dart b/lib/components/ListRefresh.dart index dd6a2466..32c11d71 100644 --- a/lib/components/ListRefresh.dart +++ b/lib/components/ListRefresh.dart @@ -7,20 +7,18 @@ * tartget: FlatButton 的示例 */ import 'package:flutter/material.dart'; -import 'dart:math'; - class ListRefresh extends StatefulWidget { final renderItem; final requestApi; - const ListRefresh([this.requestApi,this.renderItem]) : super(); + const ListRefresh([this.requestApi, this.renderItem]) : super(); @override - State createState() => listRefresh(); + State createState() => _ListRefreshState(); } -class listRefresh extends State { +class _ListRefreshState extends State { bool isLoading = false; // 是否正在请求数据中 bool _hasMore = true; // 是否还有更多数据可加载 int _pageIndex = 0; // 页面的索引 @@ -34,7 +32,8 @@ class listRefresh extends State { _getMoreData(); _scrollController.addListener(() { // 如果下拉的当前位置到scroll的最下面 - if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) { + if (_scrollController.position.pixels == + _scrollController.position.maxScrollExtent) { _getMoreData(); } }); @@ -43,7 +42,7 @@ class listRefresh extends State { /* * 回弹效果 * */ - backElasticEffect(){ + backElasticEffect() { // double edge = 50.0; // double offsetFromBottom = _scrollController.position.maxScrollExtent - _scrollController.position.pixels; // if (offsetFromBottom < edge) { // 添加一个动画没有更多数据的时候 ListView 向下移动覆盖正在加载更多数据的标志 @@ -58,18 +57,22 @@ class listRefresh extends State { * list探底,执行的具体事件 * */ Future _getMoreData() async { - if (!isLoading && _hasMore) { // 如果上一次异步请求数据完成 同时有数据可以加载 + if (!isLoading && _hasMore) { + // 如果上一次异步请求数据完成 同时有数据可以加载 setState(() => isLoading = true); //if(_hasMore){ // 还有数据可以拉新 List newEntries = await mokeHttpRequest(); //if (newEntries.isEmpty) { _hasMore = (_pageIndex <= _pageTotal); - setState(() { - items.addAll(newEntries); - isLoading = false; - }); + if (this.mounted) { + setState(() { + items.addAll(newEntries); + isLoading = false; + }); + } backElasticEffect(); - }else if (!isLoading && !_hasMore){ // 这样判断,减少以后的绘制 + } else if (!isLoading && !_hasMore) { + // 这样判断,减少以后的绘制 _pageIndex = 0; backElasticEffect(); } @@ -79,12 +82,12 @@ class listRefresh extends State { * 伪装吐出新数据 * */ Future mokeHttpRequest() async { - if(widget.requestApi is Function){ - final listObj = await widget.requestApi({'pageIndex':_pageIndex}); + if (widget.requestApi is Function) { + final listObj = await widget.requestApi({'pageIndex': _pageIndex}); _pageIndex = listObj['pageIndex']; _pageTotal = listObj['total']; return listObj['list']; - }else { + } else { return Future.delayed(Duration(seconds: 2), () { return []; }); @@ -97,20 +100,23 @@ class listRefresh extends State { * */ Future _handleRefresh() async { List newEntries = await mokeHttpRequest(); - setState(() { - items.clear(); - items.addAll(newEntries); - isLoading = false; - _hasMore = true; - return null; - }); + if (this.mounted) { + setState(() { + items.clear(); + items.addAll(newEntries); + isLoading = false; + _hasMore = true; + return null; + }); + } } /* * 加载中的提示 * */ Widget _buildLoadText() { - return Container(child: Padding( + return Container( + child: Padding( padding: const EdgeInsets.all(18.0), child: Center( child: Text("数据没有更多了!!!"), @@ -122,23 +128,28 @@ class listRefresh extends State { * 上提加载loading的widget,如果数据到达极限,显示没有更多 * */ Widget _buildProgressIndicator() { - if(_hasMore){ + if (_hasMore) { return new Padding( padding: const EdgeInsets.all(8.0), child: new Center( - child:Column( - children: [ - new Opacity( - opacity: isLoading ? 1.0 : 0.0, - child: new CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(Colors.blue)), - ), - SizedBox(height:20.0), - Text('稍等片刻更精彩...',style: TextStyle(fontSize: 14.0),) - ],) - //child: - ), + child: Column( + children: [ + new Opacity( + opacity: isLoading ? 1.0 : 0.0, + child: new CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation(Colors.blue)), + ), + SizedBox(height: 20.0), + Text( + '稍等片刻更精彩...', + style: TextStyle(fontSize: 14.0), + ) + ], + ) + //child: + ), ); - }else { + } else { return _buildLoadText(); } } @@ -152,11 +163,11 @@ class listRefresh extends State { @override Widget build(BuildContext context) { return new RefreshIndicator( - child:ListView.builder( + child: ListView.builder( itemCount: items.length + 1, itemBuilder: (context, index) { - if(index == 0 && index != items.length){ - return Container(height:0); + if (index == 0 && index != items.length) { + return Container(height: 0); } if (index == items.length) { //return _buildLoadText(); @@ -165,7 +176,7 @@ class listRefresh extends State { //print('itemsitemsitemsitems:${items[index].title}'); //return ListTile(title: Text("Index${index}:${items[index].title}")); if (widget.renderItem is Function) { - return widget.renderItem(index,items[index]); + return widget.renderItem(index, items[index]); } //return makeCard(index,items[index]); } @@ -175,4 +186,4 @@ class listRefresh extends State { onRefresh: _handleRefresh, ); } -} \ No newline at end of file +} diff --git a/lib/components/Pagination.dart b/lib/components/Pagination.dart index 86b16b88..61b3b5d4 100644 --- a/lib/components/Pagination.dart +++ b/lib/components/Pagination.dart @@ -8,7 +8,7 @@ import '../model/story.dart'; import 'package:url_launcher/url_launcher.dart'; class Pagination extends StatelessWidget { - static const String routeName = '/material/page-selector'; + static final String routeName = '/material/page-selector'; static final List icons = [ const Icon(Icons.event, semanticLabel: 'Event'), const Icon(Icons.home, semanticLabel: 'Home'), @@ -18,9 +18,9 @@ class Pagination extends StatelessWidget { const Icon(Icons.language, semanticLabel: 'Language'), ]; - List bannerStories = []; + final List bannerStories = []; - List arr = [ + 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)'}, @@ -35,7 +35,7 @@ class Pagination extends StatelessWidget { } } - List _PageSelector(BuildContext context) { + List _pageSelector(BuildContext context) { List list = []; /// super.initState(); arr.forEach((item) { @@ -57,7 +57,7 @@ class Pagination extends StatelessWidget { Column( //physics: AlwaysScrollableScrollPhysics(), //padding: EdgeInsets.only(), - children: _PageSelector(context) + children: _pageSelector(context) ); } } diff --git a/lib/components/SearchInput.dart b/lib/components/SearchInput.dart index 638ce4d1..36155575 100644 --- a/lib/components/SearchInput.dart +++ b/lib/components/SearchInput.dart @@ -138,7 +138,6 @@ class _MaterialSearchState extends State { _loading = true; }); - //TODO: debounce widget.results too var results = await widget.getResults(_criteria); if (!mounted) { diff --git a/lib/components/markdown.dart b/lib/components/markdown.dart index 0983f7a8..ba7ea5d3 100644 --- a/lib/components/markdown.dart +++ b/lib/components/markdown.dart @@ -8,7 +8,6 @@ final hightlighter = new HighLight(); class HighLight extends md.SyntaxHighlighter { @override TextSpan format(String source) { - // TODO: implement format final SyntaxHighlighterStyle style = SyntaxHighlighterStyle.lightThemeStyle(); return TextSpan( style: const TextStyle(fontSize: 10.0), @@ -22,11 +21,10 @@ class HighLight extends md.SyntaxHighlighter { class MarkdownBody extends StatelessWidget { - String data; + final String data; MarkdownBody(this.data); @override Widget build(BuildContext context) { - // TODO: implement build return md.MarkdownBody(data: data, syntaxHighlighter: new HighLight()); } } \ No newline at end of file diff --git a/lib/components/widget_item.dart b/lib/components/widget_item.dart index 8968e68c..20648fa0 100644 --- a/lib/components/widget_item.dart +++ b/lib/components/widget_item.dart @@ -72,16 +72,16 @@ class WidgetItem extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 30.0, horizontal: 10.0), height: 150.0, child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - widgetIcon, - SizedBox( - height: 8.0, - ), - Text(_widgetName), - ], - ) , + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + widgetIcon, + SizedBox( + height: 8.0, + ), + Text(_widgetName), + ], + ), ), ); } diff --git a/lib/components/widget_item_container.dart b/lib/components/widget_item_container.dart index 5f56a66b..2ddf3029 100644 --- a/lib/components/widget_item_container.dart +++ b/lib/components/widget_item_container.dart @@ -8,7 +8,7 @@ class WidgetItemContainer extends StatelessWidget { final List categories; final bool isWidgetPoint; // 所有的可用demos; - List widgetDemosList = new WidgetDemoList().getDemos(); + final List widgetDemosList = new WidgetDemoList().getDemos(); WidgetItemContainer( {Key key, @@ -41,7 +41,7 @@ class WidgetItemContainer extends StatelessWidget { targetRouter = item.routerName; } }); - Application.router.navigateTo(context, "${targetRouter}"); + Application.router.navigateTo(context, "$targetRouter"); } else { Application.router .navigateTo(context, "/category/${item.name}"); diff --git a/lib/event/event-bus.dart b/lib/event/event-bus.dart new file mode 100644 index 00000000..ce2123df --- /dev/null +++ b/lib/event/event-bus.dart @@ -0,0 +1,5 @@ +import 'package:event_bus/event_bus.dart'; + +class ApplicationEvent{ + static EventBus event; +} \ No newline at end of file diff --git a/lib/event/event-model.dart b/lib/event/event-model.dart new file mode 100644 index 00000000..f72f0cb6 --- /dev/null +++ b/lib/event/event-model.dart @@ -0,0 +1,7 @@ +class CollectionEvent{ + final String widgetName; + final String router; + final bool isRemove; + // token uid... + CollectionEvent(this.widgetName,this.router,this.isRemove); +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 0eff5e0f..40191ce5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,7 +4,6 @@ import 'package:flutter/rendering.dart'; import 'views/FirstPage.dart'; import 'views/widgetPage.dart'; -import 'views/ThirdPage.dart'; import 'views/FourthPage.dart'; import 'views/collection_page.dart'; import 'routers/routers.dart'; @@ -14,6 +13,8 @@ import 'model/widget.dart'; import './widgets/index.dart'; import 'package:flutter_rookie_book/components/SearchInput.dart'; + + const int ThemeColor = 0xFFC91B3A; class MyApp extends StatelessWidget { @@ -81,7 +82,6 @@ class _MyHomePageState extends State @override void initState() { - // TODO: implement initState super.initState(); controller = new TabController( initialIndex: 0, vsync: this, length: 4); // 这里的length 决定有多少个底导 submenus @@ -111,7 +111,7 @@ class _MyHomePageState extends State targetRouter = item.routerName; } }); - Application.router.navigateTo(context, "${targetRouter}"); + Application.router.navigateTo(context, "$targetRouter"); } Widget buildSearchInput(BuildContext context) { @@ -184,11 +184,11 @@ class _MyHomePageState extends State } } - void _onDataChange(val) { - if (this.mounted) { - setState(() { - data = val; - }); - } - } + // void _onDataChange(val) { + // if (this.mounted) { + // setState(() { + // data = val; + // }); + // } + // } } diff --git a/lib/model/base.dart b/lib/model/base.dart index ad1ff092..cff6fb06 100644 --- a/lib/model/base.dart +++ b/lib/model/base.dart @@ -1,5 +1,5 @@ import 'package:sqflite/sqflite.dart'; -import 'dart:async'; + class BaseModel{ Database db; diff --git a/lib/model/cat.dart b/lib/model/cat.dart index 7ec34431..bf86764d 100644 --- a/lib/model/cat.dart +++ b/lib/model/cat.dart @@ -1,6 +1,5 @@ -import 'base.dart'; + import 'dart:async'; -import 'dart:convert'; import '../common/sql.dart'; abstract class CatInterface{ diff --git a/lib/model/widget.dart b/lib/model/widget.dart index 606f9d84..db9afcc4 100644 --- a/lib/model/widget.dart +++ b/lib/model/widget.dart @@ -1,4 +1,4 @@ -import 'base.dart'; + import 'dart:async'; import '../common/sql.dart'; import "package:flutter/material.dart"; diff --git a/lib/routers/application.dart b/lib/routers/application.dart index 05cba554..0005b856 100644 --- a/lib/routers/application.dart +++ b/lib/routers/application.dart @@ -1,6 +1,5 @@ import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; -import '../widgets/index.dart'; class Application { static Router router; static TabController controller; diff --git a/lib/routers/routers.dart b/lib/routers/routers.dart index 7e0bc2da..4848a990 100644 --- a/lib/routers/routers.dart +++ b/lib/routers/routers.dart @@ -2,7 +2,6 @@ import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import '../widgets/index.dart'; -import '../model/widget.dart'; import './router_handler.dart'; class Routes { diff --git a/lib/views/FirstPage.dart b/lib/views/FirstPage.dart index 75fb6438..81032349 100644 --- a/lib/views/FirstPage.dart +++ b/lib/views/FirstPage.dart @@ -1,30 +1,24 @@ import 'dart:async'; - import 'package:flutter/material.dart'; -import 'package:flutter_rookie_book/common/myListView.dart'; -//import 'package:flutter_rookie_book/components/CompList.dart'; +import 'package:flutter_rookie_book/common/list_view_item.dart'; import 'package:flutter_rookie_book/components/ListRefresh.dart' as listComp; import 'package:flutter_rookie_book/components/Pagination.dart'; - import './widgetFeature/FirstPageItem.dart'; import '../common/net_utils.dart'; -import 'package:flutter_rookie_book/common/iconNames.dart'; -import '../common/sql.dart'; -import 'dart:async'; - -import 'package:url_launcher/url_launcher.dart'; - class FirstPage extends StatefulWidget { @override FirstPageState createState() => new FirstPageState(); } -class FirstPageState extends State { +class FirstPageState extends State with AutomaticKeepAliveClientMixin{ + + + @override + bool get wantKeepAlive => true; @override void initState() { - // TODO: implement initState super.initState(); } @@ -54,20 +48,17 @@ class FirstPageState extends State { } Widget makeCard(index,item){ - const emojis = ['👲']; - var smallParts_Color = Colors.primaries[index % Colors.primaries.length]; - var smallParts_icon = IconNames.Names[index % IconNames.Names.length]; - var smallParts_emojis = IconNames.Names[index % IconNames.Names.length]; var myTitle = '${item.title}'; var myUsername = '${'👲'}: ${item.username} '; var codeUrl = '${item.detailUrl}'; - return new MyListView(currCodeUrl:codeUrl,currTitle: myTitle,developer: myUsername,); + return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,); } @override Widget build(BuildContext context) { + super.build(context); return new Column( children: [ new Container( diff --git a/lib/views/FourthPage.dart b/lib/views/FourthPage.dart index 37aa6cd4..c4c44af3 100644 --- a/lib/views/FourthPage.dart +++ b/lib/views/FourthPage.dart @@ -1,4 +1,4 @@ -import 'dart:async'; + import 'package:flutter/material.dart'; import '../components/CompList.dart'; diff --git a/lib/views/ThirdPage.dart b/lib/views/ThirdPage.dart deleted file mode 100644 index 3b49594f..00000000 --- a/lib/views/ThirdPage.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; -import '../common/eventBus.dart'; - -class ThirdPage extends StatefulWidget { - ThirdPage({Key key, this.data2ThirdPage, this.callback}) : super(key: key); - final callback; - String data2ThirdPage; - - @override - ThirdPageState createState() => new ThirdPageState(); -} - -class ThirdPageState extends State { - - String data = ''; - String inputTxt; - TextEditingController controller = new TextEditingController(); - - void initState() { - //print('data4Two' + widget.data2ThirdPage); - data = widget.data2ThirdPage; - } - - void firedA() { - widget.callback('$inputTxt'); - } - - void firedB() { - eventBus.fire(new MyEvent('$inputTxt')); - } - - void _onChanged(String value) { - setState(() { - inputTxt = value; - }); - } - - - @override - Widget build(BuildContext context) { - return new Center( - child: new Column(children: [ - new Container( - padding: new EdgeInsets.only(bottom: 15.0), - child: new Text('子组件2'), - ), - new Container( - padding: new EdgeInsets.only(bottom: 10.0), - child: new Text('父传子:' + data), - ), - new Container( - margin: new EdgeInsets.only(bottom: 40.0), - child: new TextField( - controller: controller, - onChanged: _onChanged, - decoration: (new InputDecoration(labelText: '请输入你要发送的值')))), - new Container( - child: new RaisedButton( - onPressed: firedA, child: new Text('to父组件'))), - new Container( - child: new RaisedButton( - onPressed: firedB, child: new Text('to兄弟组件'))) - ] - ) - ); - } -} diff --git a/lib/views/category.dart b/lib/views/category.dart index 1faa7e5c..0bcd850e 100644 --- a/lib/views/category.dart +++ b/lib/views/category.dart @@ -61,7 +61,6 @@ class _CategoryHome extends State { // 假设进入这个界面的parent一定存在 Cat parentCat = catHistory.last; - int depth = catHistory.length; // 继续搜索显示下一级depth: depth + 1, parentId: parentCat.id List _categories = @@ -92,7 +91,7 @@ class _CategoryHome extends State { targetRouter = item.routerName; } }); - Application.router.navigateTo(context, "${targetRouter}"); + Application.router.navigateTo(context, "$targetRouter"); } Widget _buildContent() { diff --git a/lib/views/collection_page.dart b/lib/views/collection_page.dart index 55dc5ea8..6e99f80e 100644 --- a/lib/views/collection_page.dart +++ b/lib/views/collection_page.dart @@ -6,30 +6,128 @@ */ import 'package:flutter/material.dart'; import '../model/collection.dart'; +import '../routers/application.dart'; +import '../event/event-bus.dart'; +import '../event/event-model.dart'; +import 'package:event_bus/event_bus.dart'; class CollectionPage extends StatefulWidget { _CollectionPageState createState() => _CollectionPageState(); } -class _CollectionPageState extends State { +class _CollectionPageState extends State + with AutomaticKeepAliveClientMixin { + _CollectionPageState() { + final eventBus = new EventBus(); + ApplicationEvent.event = eventBus; + } CollectionControlModel _collectionControl = new CollectionControlModel(); List _collectionList = []; + ScrollController _scrollController = new ScrollController(); + + @override + bool get wantKeepAlive => true; + @override void initState() { - // TODO: implement initState super.initState(); + _getList(); + ApplicationEvent.event.on().listen((event) { + _getList(); + }); } @override - Widget build(BuildContext context) { + void dispose() { + _scrollController.dispose(); + super.dispose(); + } + + void _getList() { + _collectionList.clear(); _collectionControl.getAllCollection().then((resultList) { - _collectionList = resultList; - _collectionList.forEach((item){ - print(item.toMap()); + resultList.forEach((item) { + _collectionList.add(item); }); + if (this.mounted) { + setState(() { + _collectionList = _collectionList; + }); + } }); + } + + Widget _renderList(context, index) { + if (index == 0) { + return Container( + height: 40.0, + padding: const EdgeInsets.only(left: 10.0), + child: Row( + children: [ + Icon( + Icons.warning, + size: 22.0, + ), + SizedBox( + width: 5.0, + ), + Text('模拟器重新运行会丢失收藏'), + ], + ), + ); + } return Container( - child: Text('敬请期待'), + padding: const EdgeInsets.all(10.0), + margin: const EdgeInsets.only(bottom: 7.0), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + new BoxShadow( + color: const Color(0xFFd0d0d0), + blurRadius: 1.0, + spreadRadius: 2.0, + offset: Offset(3.0, 2.0), + ), + ], + ), + child: ListTile( + title: Text( + _collectionList[index - 1].name, + style: TextStyle(fontSize: 17.0), + ), + trailing: + Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0), + onTap: () { + Application.router + .navigateTo(context, "${_collectionList[index - 1].router}"); + }, + ), + ); + } + + @override + Widget build(BuildContext context) { + super.build(context); + if (_collectionList.length == 0) { + return ListView( + children: [ + Column( + children: [ + Image.asset( + 'assets/images/nothing.png', + fit: BoxFit.contain, + width: MediaQuery.of(context).size.width / 2, + ), + Text('暂无收藏,赶紧去收藏一个吧!'), + ], + ), + ], + ); + } + return ListView.builder( + itemBuilder: _renderList, + itemCount: _collectionList.length + 1, + controller: _scrollController, ); } } diff --git a/lib/views/widgetPage.dart b/lib/views/widgetPage.dart index d87d4bef..c1382258 100644 --- a/lib/views/widgetPage.dart +++ b/lib/views/widgetPage.dart @@ -1,3 +1,9 @@ +/* + * @Author: 一凨 + * @Date: 2019-01-11 14:39:48 + * @Last Modified by: 一凨 + * @Last Modified time: 2019-01-11 14:40:09 + */ import 'package:flutter/material.dart'; import 'widgetPage/cate_card.dart'; import '../model/cat.dart'; @@ -13,7 +19,7 @@ class WidgetPage extends StatefulWidget { SecondPageState createState() => new SecondPageState(catModel); } -class SecondPageState extends State { +class SecondPageState extends State with AutomaticKeepAliveClientMixin{ CatControlModel catModel; SecondPageState(this.catModel) : super(); @@ -23,6 +29,10 @@ class SecondPageState extends State { List categories = []; + @override + bool get wantKeepAlive => true; + + @override void initState() { super.initState(); renderCats(); @@ -41,7 +51,6 @@ class SecondPageState extends State { Widget buildGrid() { // 存放最后的widget List tiles = []; - Widget content; for (Cat item in categories) { tiles.add(new CateCard(category: item)); } @@ -52,6 +61,7 @@ class SecondPageState extends State { @override Widget build(BuildContext context) { + super.build(context); if (categories.length == 0) { return ListView( children: [new Container()], @@ -63,10 +73,4 @@ class SecondPageState extends State { ); } - void _onChanged(String value) { - setState(() { - active = value; - data = '90'; - }); - } } diff --git a/lib/widgets/components/Bar/AppBar/demo.dart b/lib/widgets/components/Bar/AppBar/demo.dart index d9bf58e8..d737f8d9 100644 --- a/lib/widgets/components/Bar/AppBar/demo.dart +++ b/lib/widgets/components/Bar/AppBar/demo.dart @@ -7,7 +7,6 @@ * tartget: AppBar 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* diff --git a/lib/widgets/components/Bar/AppBar/index.dart b/lib/widgets/components/Bar/AppBar/index.dart index 06da2b87..372dc873 100644 --- a/lib/widgets/components/Bar/AppBar/index.dart +++ b/lib/widgets/components/Bar/AppBar/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -55,7 +54,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 AppBar widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Bar/BottomAppBar/demo.dart b/lib/widgets/components/Bar/BottomAppBar/demo.dart index b9ebd18c..cea79ea4 100644 --- a/lib/widgets/components/Bar/BottomAppBar/demo.dart +++ b/lib/widgets/components/Bar/BottomAppBar/demo.dart @@ -7,7 +7,6 @@ * tartget: BottomAppBar 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* diff --git a/lib/widgets/components/Bar/BottomAppBar/index.dart b/lib/widgets/components/Bar/BottomAppBar/index.dart index 74c17c2f..4efdd279 100644 --- a/lib/widgets/components/Bar/BottomAppBar/index.dart +++ b/lib/widgets/components/Bar/BottomAppBar/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -26,11 +25,6 @@ const String _Text1 = > 通常与Scaffold和FloatingActionButton一起使用。 """; -const String _Text2 = -"""### **进阶用法** -> BottomAppBar -- -"""; class Demo extends StatefulWidget { static const String routeName = '/components//Bar/BottomAppBar'; @@ -51,7 +45,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 BottomAppBar widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Bar/ButtonBar/demo.dart b/lib/widgets/components/Bar/ButtonBar/demo.dart index 74cf15b7..d7234140 100644 --- a/lib/widgets/components/Bar/ButtonBar/demo.dart +++ b/lib/widgets/components/Bar/ButtonBar/demo.dart @@ -7,7 +7,6 @@ * tartget: ButtonBar 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* diff --git a/lib/widgets/components/Bar/ButtonBar/index.dart b/lib/widgets/components/Bar/ButtonBar/index.dart index 753cd3be..d57f9a11 100644 --- a/lib/widgets/components/Bar/ButtonBar/index.dart +++ b/lib/widgets/components/Bar/ButtonBar/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -27,11 +26,6 @@ const String _Text1 = - 当Directionality为TextDirection.ltr时,按钮栏的子项右对齐,最后一个子项成为最右边的子项。当Directionality TextDirection.rtl时,子项被左对齐,最后一个子项成为最左边的子项。 """; -const String _Text2 = -"""### **进阶用法** -> ButtonBar -- -"""; class Demo extends StatefulWidget { static const String routeName = '/components/Bar/ButtonBar'; @@ -53,7 +47,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 ButtonBar widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Bar/FlexibleSpaceBar/demo.dart b/lib/widgets/components/Bar/FlexibleSpaceBar/demo.dart index cd4218a9..2b9c7d17 100644 --- a/lib/widgets/components/Bar/FlexibleSpaceBar/demo.dart +++ b/lib/widgets/components/Bar/FlexibleSpaceBar/demo.dart @@ -7,7 +7,7 @@ * tartget: FlexibleSpaceBar 的示例 */ -import 'dart:math'; + import 'package:flutter/material.dart'; /* diff --git a/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart b/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart index 87e43280..ff80c04d 100644 --- a/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart +++ b/lib/widgets/components/Bar/FlexibleSpaceBar/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -28,11 +27,6 @@ const String _Text1 = - 要调整 AppBar 大小,必须将其包装在 FlexibleSpaceBar.createSettings 返回的 widget 中 ,以将大小调整信息传递给 FlexibleSpaceBar。 """; -const String _Text2 = -"""### **进阶用法** -> FlexibleSpaceBar -- -"""; class Demo extends StatefulWidget { static const String routeName = '/components//Bar/FlexibleSpaceBar'; @@ -54,7 +48,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 FlexibleSpaceBar widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Bar/SliverAppBar/demo.dart b/lib/widgets/components/Bar/SliverAppBar/demo.dart index e201af73..f843b00d 100644 --- a/lib/widgets/components/Bar/SliverAppBar/demo.dart +++ b/lib/widgets/components/Bar/SliverAppBar/demo.dart @@ -7,7 +7,6 @@ * tartget: SliverAppBar 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* @@ -139,27 +138,3 @@ class ListItemWidget extends StatelessWidget { } } -class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { - _SliverAppBarDelegate(this._tabBar); - - final TabBar _tabBar; - - @override - double get minExtent => _tabBar.preferredSize.height; - - @override - double get maxExtent => _tabBar.preferredSize.height; - - @override - Widget build( - BuildContext context, double shrinkOffset, bool overlapsContent) { - return new Container( - child: _tabBar, - ); - } - - @override - bool shouldRebuild(_SliverAppBarDelegate oldDelegate) { - return false; - } -} \ No newline at end of file diff --git a/lib/widgets/components/Bar/SliverAppBar/index.dart b/lib/widgets/components/Bar/SliverAppBar/index.dart index ef6de401..acd001cf 100644 --- a/lib/widgets/components/Bar/SliverAppBar/index.dart +++ b/lib/widgets/components/Bar/SliverAppBar/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -48,7 +47,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 SliverAppBar widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Bar/SnackBar/demo.dart b/lib/widgets/components/Bar/SnackBar/demo.dart index 6b0e9c5b..82451572 100644 --- a/lib/widgets/components/Bar/SnackBar/demo.dart +++ b/lib/widgets/components/Bar/SnackBar/demo.dart @@ -7,31 +7,9 @@ * tartget: SnackBar 的示例 */ -import 'dart:math'; -import 'package:flutter/material.dart'; - -/* -* Checkbox 默认按钮的实例 -* index 当前checkbox 的索引值 -* */ -class SnackBarFullDefault extends StatefulWidget { - const SnackBarFullDefault() : super(); - @override - State createState() => _SnackBarFullDefault(); -} +import 'package:flutter/material.dart'; -/* -* SnackBar 默认的实例,有状态 -* */ -class _SnackBarFullDefault extends State { - @override - Widget build(BuildContext context) { - return SnackBar( - // ... // 如果没有,就是不需要有状态的 StatefulWidget - ); - } -} /* * SnackBar 默认的实例,无状态 diff --git a/lib/widgets/components/Bar/SnackBar/index.dart b/lib/widgets/components/Bar/SnackBar/index.dart index 3595af12..6b9ac9c9 100644 --- a/lib/widgets/components/Bar/SnackBar/index.dart +++ b/lib/widgets/components/Bar/SnackBar/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -28,11 +27,6 @@ const String _Text1 = - 要控制SnackBar保持可见的时间,请指定持续时间。 """; -const String _Text2 = -"""### **进阶用法** -> SnackBar -- -"""; class Demo extends StatefulWidget { static const String routeName = '/components//Bar/SnackBar'; @@ -53,7 +47,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 SnackBar widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Bar/SnackBarAction/demo.dart b/lib/widgets/components/Bar/SnackBarAction/demo.dart index 56251f56..e4c4547f 100644 --- a/lib/widgets/components/Bar/SnackBarAction/demo.dart +++ b/lib/widgets/components/Bar/SnackBarAction/demo.dart @@ -7,10 +7,8 @@ * tartget: SnackBarAction 的示例 */ -import 'dart:math'; -import 'dart:async'; import 'package:flutter/material.dart'; -import 'demo.dart'; + class SnackBarActionDemo extends StatefulWidget { _Demo createState() => _Demo(); diff --git a/lib/widgets/components/Bar/SnackBarAction/index.dart b/lib/widgets/components/Bar/SnackBarAction/index.dart index 30d2fbe6..bd4f62a0 100644 --- a/lib/widgets/components/Bar/SnackBarAction/index.dart +++ b/lib/widgets/components/Bar/SnackBarAction/index.dart @@ -7,11 +7,7 @@ * tartget: SnackBarAction 的示例 */ import '../../../../common/widget_demo.dart'; -import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; - -import '../../../../components/markdown.dart'; import './demo.dart' as SnackBarDemo; const String _Text0 = """ diff --git a/lib/widgets/components/Bar/TabBar/demo.dart b/lib/widgets/components/Bar/TabBar/demo.dart index 208ca175..83caba93 100644 --- a/lib/widgets/components/Bar/TabBar/demo.dart +++ b/lib/widgets/components/Bar/TabBar/demo.dart @@ -7,7 +7,6 @@ * tartget: TabBar 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; class TabBarDemo extends StatefulWidget { diff --git a/lib/widgets/components/Bar/TabBar/index.dart b/lib/widgets/components/Bar/TabBar/index.dart index 23dcd527..78270cad 100644 --- a/lib/widgets/components/Bar/TabBar/index.dart +++ b/lib/widgets/components/Bar/TabBar/index.dart @@ -7,8 +7,6 @@ * tartget: SnackBarAction 的示例 */ import '../../../../common/widget_demo.dart'; - -import 'dart:math'; import 'package:flutter/material.dart'; import './demo.dart'; diff --git a/lib/widgets/components/Card/Card/demo.dart b/lib/widgets/components/Card/Card/demo.dart index 7d4b4b3c..b15a94a1 100644 --- a/lib/widgets/components/Card/Card/demo.dart +++ b/lib/widgets/components/Card/Card/demo.dart @@ -7,7 +7,6 @@ * tartget: Card 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* diff --git a/lib/widgets/components/Card/Card/index.dart b/lib/widgets/components/Card/Card/index.dart index 3867447d..e9d5fc70 100644 --- a/lib/widgets/components/Card/Card/index.dart +++ b/lib/widgets/components/Card/Card/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -26,11 +25,6 @@ const String _Text1 = > 此示例显示了创建卡片窗口组件,其中显示了相册信息和两个操作 """; -const String _Text2 = -"""### **进阶用法** -> Card -- -"""; class Demo extends StatefulWidget { static const String routeName = '/components/Card/Card'; @@ -52,7 +46,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 Card widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Chip/RawChip/demo.dart b/lib/widgets/components/Chip/RawChip/demo.dart index 7c1ca948..a6d5d6ad 100644 --- a/lib/widgets/components/Chip/RawChip/demo.dart +++ b/lib/widgets/components/Chip/RawChip/demo.dart @@ -27,8 +27,7 @@ final List _lists=[ const InputEntry('web', 'W'), ]; -List _inputs=[]; -Iterable get RawChipWidget sync*{ +Iterable get _rawChipWidget sync*{ for(InputEntry value in _lists){ yield Padding( padding: const EdgeInsets.all(4.0), @@ -57,7 +56,7 @@ Iterable get RawChipWidget sync*{ return Column( children: [ Wrap( - children: RawChipWidget.toList(), + children: _rawChipWidget.toList(), ), ], diff --git a/lib/widgets/components/Dialog/AboutDialog/demo.dart b/lib/widgets/components/Dialog/AboutDialog/demo.dart index 1720af86..df03d3a2 100644 --- a/lib/widgets/components/Dialog/AboutDialog/demo.dart +++ b/lib/widgets/components/Dialog/AboutDialog/demo.dart @@ -7,8 +7,6 @@ * tartget: xxx */ -import 'dart:math'; -import 'dart:async'; import 'package:flutter/material.dart'; diff --git a/lib/widgets/components/Dialog/AlertDialog/demo.dart b/lib/widgets/components/Dialog/AlertDialog/demo.dart index 99373b37..8d68c838 100644 --- a/lib/widgets/components/Dialog/AlertDialog/demo.dart +++ b/lib/widgets/components/Dialog/AlertDialog/demo.dart @@ -7,8 +7,6 @@ * tartget: xxx */ -import 'dart:math'; -import 'dart:async'; import 'package:flutter/material.dart'; diff --git a/lib/widgets/components/Dialog/Dialog/demo.dart b/lib/widgets/components/Dialog/Dialog/demo.dart index 006e8b65..b2911327 100644 --- a/lib/widgets/components/Dialog/Dialog/demo.dart +++ b/lib/widgets/components/Dialog/Dialog/demo.dart @@ -7,8 +7,6 @@ * tartget: xxx */ -import 'dart:math'; -import 'dart:async'; import 'package:flutter/material.dart'; @@ -72,7 +70,7 @@ class _DialogMoreDemo extends State { value += 1; }); }, - child: Text("我是一个Dialog, 点我更新value: ${value}"), + child: Text("我是一个Dialog, 点我更新value: $value"), ) ); } @@ -105,3 +103,4 @@ class _DialogMoreDemo extends State { ); } } + diff --git a/lib/widgets/components/Dialog/SimpleDialog/demo.dart b/lib/widgets/components/Dialog/SimpleDialog/demo.dart index 29d689f7..9e9b002a 100644 --- a/lib/widgets/components/Dialog/SimpleDialog/demo.dart +++ b/lib/widgets/components/Dialog/SimpleDialog/demo.dart @@ -7,8 +7,6 @@ * tartget: xxx */ -import 'dart:math'; -import 'dart:async'; import 'package:flutter/material.dart'; diff --git a/lib/widgets/components/Grid/GridTile/demo.dart b/lib/widgets/components/Grid/GridTile/demo.dart index bb5d62dc..2936e155 100644 --- a/lib/widgets/components/Grid/GridTile/demo.dart +++ b/lib/widgets/components/Grid/GridTile/demo.dart @@ -7,8 +7,6 @@ * tartget: xxx */ -import 'dart:math'; -import 'dart:async'; import 'package:flutter/material.dart'; diff --git a/lib/widgets/components/Grid/GridTileBar/demo.dart b/lib/widgets/components/Grid/GridTileBar/demo.dart index 640511b2..adf85f36 100644 --- a/lib/widgets/components/Grid/GridTileBar/demo.dart +++ b/lib/widgets/components/Grid/GridTileBar/demo.dart @@ -7,8 +7,6 @@ * tartget: xxx */ -import 'dart:math'; -import 'dart:async'; import 'package:flutter/material.dart'; diff --git a/lib/widgets/components/Grid/GridView/demo.dart b/lib/widgets/components/Grid/GridView/demo.dart index 640511b2..adf85f36 100644 --- a/lib/widgets/components/Grid/GridView/demo.dart +++ b/lib/widgets/components/Grid/GridView/demo.dart @@ -7,8 +7,6 @@ * tartget: xxx */ -import 'dart:math'; -import 'dart:async'; import 'package:flutter/material.dart'; diff --git a/lib/widgets/components/LIst/AnimatedList/demo.dart b/lib/widgets/components/LIst/AnimatedList/demo.dart index 74d89522..04617de1 100644 --- a/lib/widgets/components/LIst/AnimatedList/demo.dart +++ b/lib/widgets/components/LIst/AnimatedList/demo.dart @@ -1,4 +1,4 @@ -import 'dart:async'; + import 'package:flutter/material.dart'; import './model.dart'; diff --git a/lib/widgets/components/LIst/AnimatedList/index.dart b/lib/widgets/components/LIst/AnimatedList/index.dart index eba2c0d0..33305765 100644 --- a/lib/widgets/components/LIst/AnimatedList/index.dart +++ b/lib/widgets/components/LIst/AnimatedList/index.dart @@ -40,7 +40,6 @@ class Demo extends StatefulWidget { } class _DemoState extends State { - var animatedList = null; @override Widget build(BuildContext context) { return WidgetDemo( @@ -52,7 +51,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 AnimatedList widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/LIst/ListBody/demo.dart b/lib/widgets/components/LIst/ListBody/demo.dart index 8eae97bc..5e21ba0c 100644 --- a/lib/widgets/components/LIst/ListBody/demo.dart +++ b/lib/widgets/components/LIst/ListBody/demo.dart @@ -7,7 +7,6 @@ * tartget: ListBody 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* diff --git a/lib/widgets/components/LIst/ListBody/index.dart b/lib/widgets/components/LIst/ListBody/index.dart index 1ef2c981..a308ab8c 100644 --- a/lib/widgets/components/LIst/ListBody/index.dart +++ b/lib/widgets/components/LIst/ListBody/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -50,7 +49,7 @@ 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 bdce900b..cbfde28e 100644 --- a/lib/widgets/components/LIst/ListView/demo.dart +++ b/lib/widgets/components/LIst/ListView/demo.dart @@ -7,7 +7,6 @@ * tartget: ListView 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* @@ -87,8 +86,8 @@ class ListViewLessDefault extends StatelessWidget { dense:true, // item 直观感受是整体大小 contentPadding: EdgeInsets.all(10.0),// item 内容内边距 enabled:true, - onTap:(){print('点击:${index}');},// item onTap 点击事件 - onLongPress:(){print('长按:${index}');},// item onLongPress 长按事件 + onTap:(){print('点击:$index');},// item onTap 点击事件 + onLongPress:(){print('长按:$index');},// item onLongPress 长按事件 selected:false, // item 是否选中状态 ); }, @@ -112,8 +111,8 @@ class ListViewLessDefault extends StatelessWidget { dense:true, // item 直观感受是整体大小 contentPadding: EdgeInsets.all(10.0),// item 内容内边距 enabled:true, - onTap:(){print('点击:${index}');},// item onTap 点击事件 - onLongPress:(){print('长按:${index}');},// item onLongPress 长按事件 + onTap:(){print('点击:$index');},// item onTap 点击事件 + onLongPress:(){print('长按:$index');},// item onLongPress 长按事件 selected:false, // item 是否选中状态 ); }, diff --git a/lib/widgets/components/LIst/ListView/index.dart b/lib/widgets/components/LIst/ListView/index.dart index 1416e662..4bf7ab07 100644 --- a/lib/widgets/components/LIst/ListView/index.dart +++ b/lib/widgets/components/LIst/ListView/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -76,7 +75,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 ListView widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart b/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart index acb9f5d3..fe1628fc 100644 --- a/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart +++ b/lib/widgets/components/Menu/CheckedPopupMenuItem/demo.dart @@ -13,7 +13,6 @@ class CheckedPopupMenuItemDemo extends StatefulWidget { } class _CheckedPopupMenuItemDemoState extends State { - final GlobalKey _scaffoldKey = GlobalKey(); List _checkedValues; final String _checkedValue1 = 'One'; diff --git a/lib/widgets/components/Menu/index.dart b/lib/widgets/components/Menu/index.dart index 6c1d4cf3..697fad9d 100644 --- a/lib/widgets/components/Menu/index.dart +++ b/lib/widgets/components/Menu/index.dart @@ -12,7 +12,6 @@ import './DropdownMenuItem/index.dart' as DropdownMenuItem; import './PopupMenuButton/index.dart' as PopupMenuButton; import './PopupMenuDivider/index.dart' as PopupMenuDivider; import './PopupMenuEntry/index.dart' as PopupMenuEntry; -import './PopupMenuItem/index.dart' as PopupMenuItem; import './PopupMenuItemState/index.dart' as PopupMenuItemState; diff --git a/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart b/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart index a4916e74..65061ede 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBar/demo.dart @@ -7,7 +7,6 @@ * tartget: BottomNavigationBar 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* @@ -53,19 +52,3 @@ class _BottomNavigationBarFullDefault extends State { } } -/* -* BottomNavigationBar 默认的实例,无状态 -* */ -class BottomNavigationBarLessDefault extends StatelessWidget { - final widget; - final parent; - - const BottomNavigationBarLessDefault([this.widget, this.parent]) - : super(); - - @override - Widget build(BuildContext context) { - return BottomNavigationBar( - ); - } -} \ No newline at end of file diff --git a/lib/widgets/components/Navigation/BottomNavigationBar/index.dart b/lib/widgets/components/Navigation/BottomNavigationBar/index.dart index 072f03a5..baa6a4e2 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBar/index.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBar/index.dart @@ -8,7 +8,6 @@ */ import '../customDemo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -51,7 +50,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 BottomNavigationBar widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart b/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart index 7f77989c..63555554 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBarItem/demo.dart @@ -7,7 +7,6 @@ * tartget: BottomNavigationBarItem 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* @@ -21,14 +20,7 @@ class BottomNavigationBarItemFullDefault extends StatefulWidget { State createState() => _BottomNavigationBarItemFullDefault(); } -/* -* BottomNavigationBarItem 默认的实例,有状态 -* */ -class _BottomNavigationBarItemFullDefault extends State { - @override - Widget build(BuildContext context) { - } -} + /* * BottomNavigationBarItem 默认的实例,无状态 diff --git a/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart b/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart index 6d8f29ee..0f14bffb 100644 --- a/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart +++ b/lib/widgets/components/Navigation/BottomNavigationBarItem/index.dart @@ -8,7 +8,6 @@ */ import '../../../../common/widget-demo.dart'; import '../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -26,11 +25,6 @@ const String _Text1 = > 这个类很少单独使用。通常嵌入在上面的一个底部 bottom navigation widgets 中。 """; -const String _Text2 = -"""### **进阶用法** -> BottomNavigationBarItem -- -"""; class Demo extends StatefulWidget { static const String routeName = '/components/Navigation/BottomNavigationBarItem'; @@ -51,7 +45,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 BottomNavigationBarItem widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/components/Panel/ExpansionPanelList/demo.dart b/lib/widgets/components/Panel/ExpansionPanelList/demo.dart index 10b12839..278c09bb 100644 --- a/lib/widgets/components/Panel/ExpansionPanelList/demo.dart +++ b/lib/widgets/components/Panel/ExpansionPanelList/demo.dart @@ -15,7 +15,7 @@ enum Location { typedef DemoItemBodyBuilder = Widget Function(DemoItem item); typedef ValueToString = String Function(T value); -/** +/* * google flutter 详情多个例子地址: * https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart */ @@ -135,11 +135,6 @@ class _ExpansionPanelsDemoState extends State { 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) { diff --git a/lib/widgets/components/Pick/DayPicker/demo.dart b/lib/widgets/components/Pick/DayPicker/demo.dart index 1bcea659..36f249d1 100644 --- a/lib/widgets/components/Pick/DayPicker/demo.dart +++ b/lib/widgets/components/Pick/DayPicker/demo.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; class DayPickerDemo extends StatefulWidget { @override - State createState() => _showDialog(); + State createState() => _DayPickerState(); } -class _showDialog extends State { +class _DayPickerState extends State { DateTime _date = new DateTime.now(); TimeOfDay _time = new TimeOfDay.now(); diff --git a/lib/widgets/components/Pick/MonthPicker/demo.dart b/lib/widgets/components/Pick/MonthPicker/demo.dart index 9b2a1a8b..40c053d8 100644 --- a/lib/widgets/components/Pick/MonthPicker/demo.dart +++ b/lib/widgets/components/Pick/MonthPicker/demo.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; class MothPickerDemo extends StatefulWidget { @override - State createState() => _first(); + State createState() => _MothPickerState(); } -class _first extends State { +class _MothPickerState extends State { DateTime _date = new DateTime.now(); Future _selectDate(BuildContext context) async { diff --git a/lib/widgets/components/Pick/ShowdatePicker/demo.dart b/lib/widgets/components/Pick/ShowdatePicker/demo.dart index ee93bded..c18bdded 100644 --- a/lib/widgets/components/Pick/ShowdatePicker/demo.dart +++ b/lib/widgets/components/Pick/ShowdatePicker/demo.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; class ShowDatePickerDemo extends StatefulWidget { @override - State createState() => _showDialog(); + State createState() => _ShowDatePickerState(); } -class _showDialog extends State { +class _ShowDatePickerState extends State { DateTime _date = new DateTime.now(); TimeOfDay _time = new TimeOfDay.now(); diff --git a/lib/widgets/components/Pick/YearPicker/demo.dart b/lib/widgets/components/Pick/YearPicker/demo.dart index 11abcb62..2a9694e7 100644 --- a/lib/widgets/components/Pick/YearPicker/demo.dart +++ b/lib/widgets/components/Pick/YearPicker/demo.dart @@ -1,8 +1,8 @@ /* * @Author: xiaojia.dxj * @Date: 2018-12-17 15:37:32 - * @Last Modified by: xiaojia.dxj - * @Last Modified time: 2018-12-18 19:12:32 + * @Last Modified by: 一凨 + * @Last Modified time: 2019-01-11 15:17:26 */ import 'dart:async'; @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; class YearPickerDemo extends StatefulWidget { @override - State createState() => _showDialog(); + State createState() => _YearPickerDemoState(); } -class _showDialog extends State { +class _YearPickerDemoState extends State { DateTime _date = new DateTime.now(); Future _selectDate(BuildContext context) async { diff --git a/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart b/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart index 16ca025c..a29d07ca 100644 --- a/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart +++ b/lib/widgets/components/Progress/RefreshProgressIndicator/index.dart @@ -6,7 +6,6 @@ */ import 'package:flutter/material.dart'; import '../../../../common/widget_demo.dart'; -import 'demo.dart'; const String content0 = ''' ### **简介** diff --git a/lib/widgets/components/Scroll/ScrollPhysics/index.dart b/lib/widgets/components/Scroll/ScrollPhysics/index.dart index e4430cea..4af9aa12 100644 --- a/lib/widgets/components/Scroll/ScrollPhysics/index.dart +++ b/lib/widgets/components/Scroll/ScrollPhysics/index.dart @@ -5,7 +5,6 @@ * @Last Modified time: 2018-12-15 21:26:11 */ import 'package:flutter/material.dart'; -import 'package:flutter/material.dart'; import '../../../../common/widget_demo.dart'; import './demo.dart'; diff --git a/lib/widgets/elements/Form/Button/DropdownButton/demo.dart b/lib/widgets/elements/Form/Button/DropdownButton/demo.dart index 06eeacd2..2bf5b846 100644 --- a/lib/widgets/elements/Form/Button/DropdownButton/demo.dart +++ b/lib/widgets/elements/Form/Button/DropdownButton/demo.dart @@ -6,7 +6,6 @@ * email: zhu.yan@alibaba-inc.com * tartget: DropdownButton 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* @@ -14,15 +13,15 @@ import 'package:flutter/material.dart'; * isDisabled:是否是禁用,isDisabled 默认为true * */ class DropdownButtonDefault extends StatelessWidget { - List generateItemList() { - List items = new List(); - DropdownMenuItem item1 = new DropdownMenuItem( + List generateItemList() { + final List items = new List(); + final DropdownMenuItem item1 = new DropdownMenuItem( value: '张三', child: new Text('张三')); - DropdownMenuItem item2 = new DropdownMenuItem( + final DropdownMenuItem item2 = new DropdownMenuItem( value: '李四', child: new Text('李四')); - DropdownMenuItem item3 = new DropdownMenuItem( + final DropdownMenuItem item3 = new DropdownMenuItem( value: '王二', child: new Text('王二')); - DropdownMenuItem item4 = new DropdownMenuItem( + final DropdownMenuItem item4 = new DropdownMenuItem( value: '麻子', child: new Text('麻子')); items.add(item1); items.add(item2); diff --git a/lib/widgets/elements/Form/Button/DropdownButton/index.dart b/lib/widgets/elements/Form/Button/DropdownButton/index.dart index 24fc4ce9..8381681b 100644 --- a/lib/widgets/elements/Form/Button/DropdownButton/index.dart +++ b/lib/widgets/elements/Form/Button/DropdownButton/index.dart @@ -9,7 +9,6 @@ */ import '../../../../../common/widget-demo.dart'; import '../../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -58,7 +57,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 DropdownButton 按钮 */ Widget allDropdownButtons(BuildContext context,_DemoState that){ diff --git a/lib/widgets/elements/Form/Button/FlatButton/demo.dart b/lib/widgets/elements/Form/Button/FlatButton/demo.dart index 106bd912..45352b5f 100644 --- a/lib/widgets/elements/Form/Button/FlatButton/demo.dart +++ b/lib/widgets/elements/Form/Button/FlatButton/demo.dart @@ -16,7 +16,7 @@ import 'package:flutter/material.dart'; class FlatButtonDefault extends StatelessWidget { final bool isDisabled; - const FlatButtonDefault([bool this.isDisabled = true]) + const FlatButtonDefault([ this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -39,7 +39,7 @@ class FlatButtonIconDefault extends StatelessWidget { final IconData icon; const FlatButtonIconDefault( - [bool this.isDisabled = true, IconData this.icon = Icons.add_circle]) + [ this.isDisabled = true, this.icon = Icons.add_circle]) : super(); Color _randomColor() { @@ -73,10 +73,10 @@ class FlatButtonCustom extends StatelessWidget { final VoidCallback onPressed; const FlatButtonCustom([ - String this.txt = '自定义按钮', - Color this.color = Colors.blueAccent, - ShapeBorder this.shape, - VoidCallback this.onPressed + this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed ]) :super(); @override diff --git a/lib/widgets/elements/Form/Button/FlatButton/index.dart b/lib/widgets/elements/Form/Button/FlatButton/index.dart index adbb3b5b..1917e63a 100644 --- a/lib/widgets/elements/Form/Button/FlatButton/index.dart +++ b/lib/widgets/elements/Form/Button/FlatButton/index.dart @@ -9,40 +9,11 @@ */ import '../../../../../common/widget-demo.dart'; import '../../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import './demo.dart' as flatButton; -const String _markdownData = """# Markdown Example -Markdown allows you to easily include formatted text, images, and even formatted Dart code in your app. -## Styling -Style text as _italic_, __bold__, or `inline code`. -- Use bulleted lists -- To better clarify -- Your points -## Links -You can use [hyperlinks](hyperlink) in markdown -## Images -You can include images: -![Flutter logo](https://flutter.io/images/flutter-mark-square-100.png#100x100) -## Markdown widget -This is an example of how to create your own Markdown widget: - new Markdown(data: 'Hello _world_!'); -## Code blocks -Formatted Dart code looks really pretty too: -``` -void main() { - runApp(new MaterialApp( - home: new Scaffold( - body: new Markdown(data: markdownData) - ) - )); -} -``` -Enjoy! -"""; const String _flatText0 = @@ -90,7 +61,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 FlatButton 按钮 */ Widget allFlatButtons(BuildContext context){ diff --git a/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart b/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart index ecf373aa..f4188499 100644 --- a/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart +++ b/lib/widgets/elements/Form/Button/FloatingActionButton/demo.dart @@ -6,7 +6,6 @@ * email: zhu.yan@alibaba-inc.com * tartget: OutlineButton 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* @@ -16,7 +15,7 @@ import 'package:flutter/material.dart'; class FloatingActionButtonDefault extends StatelessWidget { final bool isDisabled; - const FloatingActionButtonDefault([bool this.isDisabled = true]) + const FloatingActionButtonDefault([ this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -41,10 +40,10 @@ class FloatingActionButtonCustom extends StatelessWidget { final VoidCallback onPressed; const FloatingActionButtonCustom( - [String this.txt = '自定义按钮', - Color this.color = Colors.orange, - ShapeBorder this.shape, - VoidCallback this.onPressed]) + [ this.txt = '自定义按钮', + this.color = Colors.orange, + this.shape, + this.onPressed]) : super(); @override @@ -93,10 +92,10 @@ class FloatingActionButtonCustom2 extends StatelessWidget { final VoidCallback onPressed; const FloatingActionButtonCustom2( - [String this.txt = '自定义按钮', - Color this.color = Colors.orange, - ShapeBorder this.shape, - VoidCallback this.onPressed]) + [ this.txt = '自定义按钮', + this.color = Colors.orange, + this.shape, + this.onPressed]) : super(); @override diff --git a/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart b/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart index 6afa2f11..9dd616e6 100644 --- a/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart +++ b/lib/widgets/elements/Form/Button/FloatingActionButton/index.dart @@ -15,8 +15,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import './demo.dart' as floatingActionButton; -const String _floatingActionTitle = - 'FloatingAction Button 示例'; const String _floatingActionText0 = """### **简介** @@ -70,7 +68,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 FloatingActionButton 按钮 */ Widget allFloatingActionButtons(BuildContext context,_DemoState that){ @@ -107,26 +105,26 @@ Widget allFloatingActionButtons(BuildContext context,_DemoState that){ * alert 弹框 * context:容器的父级 * */ -void _showMessage(String name, BuildContext context) { - showDialog( - // alert 的父级 - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: new Text('提示'), - content: new Text(name), - actions: [ - new FlatButton( - // alert 的取消按钮 - onPressed: () { - // 取消的事件 - Navigator.of(context).pop(true); - }, - child: new Text('取消')) - ]); - } - ); -} +// void _showMessage(String name, BuildContext context) { +// showDialog( +// // alert 的父级 +// context: context, +// builder: (BuildContext context) { +// return AlertDialog( +// title: new Text('提示'), +// content: new Text(name), +// actions: [ +// new FlatButton( +// // alert 的取消按钮 +// onPressed: () { +// // 取消的事件 +// Navigator.of(context).pop(true); +// }, +// child: new Text('取消')) +// ]); +// } +// ); +// } /* * 带align的text diff --git a/lib/widgets/elements/Form/Button/IconButton/demo.dart b/lib/widgets/elements/Form/Button/IconButton/demo.dart index 62be1b02..8f18ef00 100644 --- a/lib/widgets/elements/Form/Button/IconButton/demo.dart +++ b/lib/widgets/elements/Form/Button/IconButton/demo.dart @@ -19,7 +19,7 @@ final int len = IconNames.Names.length; class IconButtonDefault extends StatelessWidget { final bool isDisabled; - const IconButtonDefault([bool this.isDisabled = true]) + const IconButtonDefault([ this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -43,10 +43,10 @@ class IconButtonCustom extends StatelessWidget { final VoidCallback onPressed; const IconButtonCustom( - [String this.txt = '自定义按钮', - Color this.color = Colors.blueAccent, - ShapeBorder this.shape, - VoidCallback this.onPressed]) + [ this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); getIcons(){ diff --git a/lib/widgets/elements/Form/Button/IconButton/index.dart b/lib/widgets/elements/Form/Button/IconButton/index.dart index 19ffdd5d..d6619004 100644 --- a/lib/widgets/elements/Form/Button/IconButton/index.dart +++ b/lib/widgets/elements/Form/Button/IconButton/index.dart @@ -61,7 +61,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 IconButton 按钮 */ Widget allIconButtons(BuildContext context,_DemoState that){ diff --git a/lib/widgets/elements/Form/Button/OutlineButton/demo.dart b/lib/widgets/elements/Form/Button/OutlineButton/demo.dart index 58212c76..582d7135 100644 --- a/lib/widgets/elements/Form/Button/OutlineButton/demo.dart +++ b/lib/widgets/elements/Form/Button/OutlineButton/demo.dart @@ -16,7 +16,7 @@ import 'package:flutter/material.dart'; class OutlineButtonDefault extends StatelessWidget { final bool isDisabled; - const OutlineButtonDefault([bool this.isDisabled = true]) + const OutlineButtonDefault([ this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -39,7 +39,7 @@ class OutlineButtonIconDefault extends StatelessWidget { final IconData icon; const OutlineButtonIconDefault( - [bool this.isDisabled = true, IconData this.icon = Icons.add_circle]) + [ this.isDisabled = true, this.icon = Icons.add_circle]) : super(); @override @@ -66,10 +66,10 @@ class OutlineButtonCustom extends StatelessWidget { final VoidCallback onPressed; const OutlineButtonCustom( - [String this.txt = '自定义按钮', - Color this.color = Colors.blueAccent, - ShapeBorder this.shape, - VoidCallback this.onPressed]) + [ this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override diff --git a/lib/widgets/elements/Form/Button/OutlineButton/index.dart b/lib/widgets/elements/Form/Button/OutlineButton/index.dart index e44cd71b..aef9a20a 100644 --- a/lib/widgets/elements/Form/Button/OutlineButton/index.dart +++ b/lib/widgets/elements/Form/Button/OutlineButton/index.dart @@ -70,7 +70,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 OutlineButton 按钮 */ Widget allOutlineButtons(BuildContext context,_DemoState that){ @@ -131,26 +131,26 @@ Widget allOutlineButtons(BuildContext context,_DemoState that){ * alert 弹框 * context:容器的父级 * */ -void _showMessage(String name, BuildContext context) { - showDialog( - // alert 的父级 - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: new Text('提示'), - content: new Text(name), - actions: [ - new FlatButton( - // alert 的取消按钮 - onPressed: () { - // 取消的事件 - Navigator.of(context).pop(true); - }, - child: new Text('取消')) - ]); - } - ); -} +// void _showMessage(String name, BuildContext context) { +// showDialog( +// // alert 的父级 +// context: context, +// builder: (BuildContext context) { +// return AlertDialog( +// title: new Text('提示'), +// content: new Text(name), +// actions: [ +// new FlatButton( +// // alert 的取消按钮 +// onPressed: () { +// // 取消的事件 +// Navigator.of(context).pop(true); +// }, +// child: new Text('取消')) +// ]); +// } +// ); +// } /* * 带align的text diff --git a/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart b/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart index 0015ee41..beb27696 100644 --- a/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart +++ b/lib/widgets/elements/Form/Button/PopupMenuButton/demo.dart @@ -6,7 +6,6 @@ * email: zhu.yan@alibaba-inc.com * tartget: RaisedButton 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* @@ -20,7 +19,7 @@ class PopupMenuButtonDefault extends StatelessWidget { final String type; const PopupMenuButtonDefault( - [String this.type = 'default1', bool this.isDisabled = true]) + [ this.type = 'default1', this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -107,7 +106,7 @@ class PopupMenuButtonCustom extends StatelessWidget { label: Text( '自定义按钮', style: TextStyle(color: Colors.white), semanticsLabel: 'FLAT BUTTON'), - // onPressed:(){} // 激活状态按钮 + onPressed:(){} // 激活状态按钮 ), // 打开时放置菜单的z坐标。这可以控制菜单下方阴影的大小。 elevation:10.0, diff --git a/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart b/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart index 719acf4e..dd5df9d7 100644 --- a/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart +++ b/lib/widgets/elements/Form/Button/PopupMenuButton/index.dart @@ -10,7 +10,6 @@ import '../../../../../common/widget-demo.dart'; import '../../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import './demo.dart' as popupMenuButton; @@ -38,8 +37,9 @@ const String _titleText2 = """ class Demo extends StatefulWidget { static const String routeName = '/element/Form/Button/PopupMenuButton'; final Map options = {'defaultSelect': '选项二的内容'}; - @override final _DemoState self = _DemoState(); + + @override _DemoState createState() => self; } diff --git a/lib/widgets/elements/Form/Button/RaisedButton/demo.dart b/lib/widgets/elements/Form/Button/RaisedButton/demo.dart index 45be5193..0ddece9d 100644 --- a/lib/widgets/elements/Form/Button/RaisedButton/demo.dart +++ b/lib/widgets/elements/Form/Button/RaisedButton/demo.dart @@ -16,7 +16,7 @@ import 'package:flutter/material.dart'; class RaisedButtonDefault extends StatelessWidget { final bool isDisabled; - const RaisedButtonDefault([bool this.isDisabled = true]) + const RaisedButtonDefault([ this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -39,7 +39,7 @@ class RaisedButtonIconDefault extends StatelessWidget { final IconData icon; const RaisedButtonIconDefault( - [bool this.isDisabled = true, IconData this.icon = Icons.add_circle]) + [ this.isDisabled = true, this.icon = Icons.add_circle]) : super(); Color _randomColor() { @@ -73,10 +73,10 @@ class RaisedButtonCustom extends StatelessWidget { final VoidCallback onPressed; const RaisedButtonCustom( - [String this.txt = '自定义按钮', - Color this.color = Colors.blueAccent, - ShapeBorder this.shape, - VoidCallback this.onPressed]) + [ this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override diff --git a/lib/widgets/elements/Form/Button/RaisedButton/index.dart b/lib/widgets/elements/Form/Button/RaisedButton/index.dart index 465ad90b..649a083c 100644 --- a/lib/widgets/elements/Form/Button/RaisedButton/index.dart +++ b/lib/widgets/elements/Form/Button/RaisedButton/index.dart @@ -70,7 +70,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 RaisedButton 按钮 */ Widget allRaisedButtons(BuildContext context,_DemoState that){ @@ -131,26 +131,26 @@ Widget allRaisedButtons(BuildContext context,_DemoState that){ * alert 弹框 * context:容器的父级 * */ -void _showMessage(String name, BuildContext context) { - showDialog( - // alert 的父级 - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: new Text('提示'), - content: new Text(name), - actions: [ - new FlatButton( - // alert 的取消按钮 - onPressed: () { - // 取消的事件 - Navigator.of(context).pop(true); - }, - child: new Text('取消')) - ]); - } - ); -} +// void _showMessage(String name, BuildContext context) { +// showDialog( +// // alert 的父级 +// context: context, +// builder: (BuildContext context) { +// return AlertDialog( +// title: new Text('提示'), +// content: new Text(name), +// actions: [ +// new FlatButton( +// // alert 的取消按钮 +// onPressed: () { +// // 取消的事件 +// Navigator.of(context).pop(true); +// }, +// child: new Text('取消')) +// ]); +// } +// ); +// } /* * 带align的text diff --git a/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart b/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart index f2386338..3b309a0b 100644 --- a/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart +++ b/lib/widgets/elements/Form/Button/RawMaterialButton/demo.dart @@ -16,7 +16,7 @@ import 'package:flutter/material.dart'; class RawMaterialButtonDefault extends StatelessWidget { final bool isDisabled; - const RawMaterialButtonDefault([bool this.isDisabled = true]) + const RawMaterialButtonDefault([ this.isDisabled = true]) : assert(isDisabled != null), super(); @@ -39,10 +39,10 @@ class RawMaterialButtonCustom extends StatelessWidget { final VoidCallback onPressed; const RawMaterialButtonCustom( - [String this.txt = '自定义按钮', - Color this.color = Colors.blueAccent, - ShapeBorder this.shape, - VoidCallback this.onPressed]) + [ this.txt = '自定义按钮', + this.color = Colors.blueAccent, + this.shape, + this.onPressed]) : super(); @override diff --git a/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart b/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart index 818aeccc..481fa240 100644 --- a/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart +++ b/lib/widgets/elements/Form/Button/RawMaterialButton/index.dart @@ -59,7 +59,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 RawMaterialButton 按钮 */ Widget allRawMaterialButtons(BuildContext context,_DemoState that){ @@ -103,26 +103,26 @@ Widget allRawMaterialButtons(BuildContext context,_DemoState that){ * alert 弹框 * context:容器的父级 * */ -void _showMessage(String name, BuildContext context) { - showDialog( - // alert 的父级 - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: new Text('提示'), - content: new Text(name), - actions: [ - new FlatButton( - // alert 的取消按钮 - onPressed: () { - // 取消的事件 - Navigator.of(context).pop(true); - }, - child: new Text('取消')) - ]); - } - ); -} +// void _showMessage(String name, BuildContext context) { +// showDialog( +// // alert 的父级 +// context: context, +// builder: (BuildContext context) { +// return AlertDialog( +// title: new Text('提示'), +// content: new Text(name), +// actions: [ +// new FlatButton( +// // alert 的取消按钮 +// onPressed: () { +// // 取消的事件 +// Navigator.of(context).pop(true); +// }, +// child: new Text('取消')) +// ]); +// } +// ); +// } /* * 带align的text diff --git a/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart b/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart index 489225d2..c77c8ac0 100644 --- a/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart +++ b/lib/widgets/elements/Form/CheckBox/Checkbox/demo.dart @@ -16,7 +16,7 @@ import 'package:flutter/material.dart'; class CheckboxDefault extends StatefulWidget{ final int index; final parent; - const CheckboxDefault([this.parent,int this.index = -1]) : super(); + const CheckboxDefault([this.parent, this.index = -1]) : super(); @override State createState() =>_CheckboxDefault(); } @@ -47,7 +47,7 @@ class CheckboxSelect extends StatelessWidget { final widget; final parent; - const CheckboxSelect([this.widget,this.parent,int this.index = -1]) + const CheckboxSelect([this.widget,this.parent, this.index = -1]) : super(); @override diff --git a/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart b/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart index 7410ce50..df98da5c 100644 --- a/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart +++ b/lib/widgets/elements/Form/CheckBox/Checkbox/index.dart @@ -9,7 +9,6 @@ */ import '../../../../../common/widget-demo.dart'; import '../../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -55,7 +54,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 Checkbox 按钮 */ Widget allCheckboxs(BuildContext context,_DemoState that){ diff --git a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart index 5af9a5d3..500b549c 100644 --- a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart +++ b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/demo.dart @@ -7,7 +7,6 @@ * tartget: CheckboxListTile 的示例 */ -import 'dart:math'; import 'package:flutter/material.dart'; /* diff --git a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart index 87a801b4..2754c175 100644 --- a/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart +++ b/lib/widgets/elements/Form/CheckBox/CheckboxListTile/index.dart @@ -8,9 +8,7 @@ */ import '../../../../../common/widget-demo.dart'; import '../../../../../routers/application.dart'; -import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import './demo.dart' as CheckboxListTileDemo; @@ -39,7 +37,7 @@ const String _CheckboxListTileText2 = class Demo extends StatefulWidget { static const String routeName = '/element/Form/Checkbox/CheckboxListTile'; - bool valBool = true; + final bool valBool = true; @override _DemoState createState() => _DemoState(); } @@ -56,7 +54,7 @@ class _DemoState extends State { } } -/** +/* * 所有的 CheckboxListTile widget * context: 运行上下文 * that: 指向有状态的 StatefulWidget diff --git a/lib/widgets/elements/Form/Input/TextField/index.dart b/lib/widgets/elements/Form/Input/TextField/index.dart index 3a4e6550..1b353f52 100644 --- a/lib/widgets/elements/Form/Input/TextField/index.dart +++ b/lib/widgets/elements/Form/Input/TextField/index.dart @@ -10,48 +10,47 @@ import '../../../../../common/widget_demo.dart'; import 'package:flutter/material.dart'; -import './text_field_demo.dart' ; +import './text_field_demo.dart'; - -const String _textFieldText0 = -"""### **简介** -> Text Field “文本字段” -- 文本字段允许用户输入文本,无论是硬件键盘还是屏幕键盘。 -- 每当用户更改字段中的文本时,文本字段就会调用Onchange的回调。 -- 如果用户指示他们在字段中输入完成(例如,通过按软键盘上的按钮),则文本字段调用onSubmitted回调。 +const String _textFieldText0 = """### **简介** +> TextField 最常用的文本输入widget +- 该 widget 作为文本输入框,可以接收用户以屏幕按键或者键盘输入的文本信息,该信息可以用于消息传递,搜索体验等 +- 用户修改文本信息时,Onchange会被调用,获取到最新的文本信息 +- 已知用户输入的字段文本输入完毕时(例如,通过按软键盘上的按钮确认输入完毕),该widget会调用onSubmitted回调 """; -const String _textFieldText1 = -"""### **基本用法** -> 参数的默认的按钮和禁用按钮 -- 默认情况下,文本字段具有在文本字段下方绘制分隔符的修饰。 -- 您可以使用装饰属性来控制装饰,例如通过添加标签或图标。如果将装饰属性设置为空,则将完全删除装饰,包括装饰引入的额外填充,以节省标签的空间。 -- 如果装饰是非null(这是默认的),文本字段需要它的祖先之一是一个材质widget。当文本字段被敲击时,墨水溅到材料上的油漆被触发。 -- 若要将TeXFieldField集成到其他FieldFieldWrices窗体中,请考虑使用TeTFrimeField。"""; +const String _textFieldText1 = """### **基本用法** +> 参数控制默认的按钮和禁用按钮 +- 默认情况下,TextField 下方有一个下划线进行修饰。 +- 您可以使用decoration属性来控制该widget样式,例如通过添加标签或图标。如果将decoration属性设置为空,则将完全删除装饰,包括装饰引入的额外填充,以节省标签的空间。 +- 如果decoration属性是非null(这是默认的),文本字段需要它的父类是一个Material widget。当文本字段被点击时,会出发被点击的效果。 +- 若要将TextField和其他FormFild集成到Form中,请考虑使用TeTFrimeField。"""; -const String _textFieldText2 = -"""### **进阶用法** -> 实现稍微复杂点的效果,键盘就变成了数字优先,为输入框做一些其他的效果,如提示文字,icon、标签文字等 +const String _textFieldText2 = """### **进阶用法** +> 实现稍微复杂点的效果,TextField 的输入以数字优先,为输入框做一些其他的效果,如提示文字,icon、标签文字等 - 增加一个keyboardType属性,把keyboardType设置为 TextInputType.number ,让TextField获得焦点的时候弹出的键盘就变成了数字优先。 - 新增decoration属性,设置相关属性,可以发现当我们的TextField获得焦点时,图标会自动变色,提示文字会自动上移。 -- onChanged是每次输入框内每次文字变更触发的回调,onSubmitted是用户提交而触发的回调。 +- onChanged是输入框内每次文字变更触发的回调方法,onSubmitted是用户提交而触发的回调方法。 - 每当用户改变输入框内的文字,都会在控制台输出现在的字符串.与onSubmitted用法相同。 """; class Demo extends StatefulWidget { static const String routeName = 'elements/Form/Input/TextField'; + @override _DemoState createState() => _DemoState(); } 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( @@ -68,4 +67,3 @@ class _DemoState extends State { ); } } - diff --git a/lib/widgets/elements/Form/Radio/Radio/index.dart b/lib/widgets/elements/Form/Radio/Radio/index.dart index 11e52c41..bfbaf098 100644 --- a/lib/widgets/elements/Form/Radio/Radio/index.dart +++ b/lib/widgets/elements/Form/Radio/Radio/index.dart @@ -9,7 +9,6 @@ import 'package:flutter/material.dart'; import '../../../../../common/widget_demo.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; import 'demo.dart'; const content1 = """ # Radio diff --git a/lib/widgets/elements/Frame/Align/Align/demo.dart b/lib/widgets/elements/Frame/Align/Align/demo.dart index 18067138..288c1003 100644 --- a/lib/widgets/elements/Frame/Align/Align/demo.dart +++ b/lib/widgets/elements/Frame/Align/Align/demo.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/11/22 * Email: xiaojia.dxj@alibaba-inc.com @@ -14,7 +14,7 @@ class AlignAlignment extends StatelessWidget { final Alignment status; final String dec; - const AlignAlignment(Alignment this.status, String this.dec) : super(); + const AlignAlignment( this.status, this.dec) : super(); @override Widget build(BuildContext context) { @@ -39,8 +39,8 @@ class AlignFactor extends StatelessWidget { final double hFactor; final String dec; - const AlignFactor(Alignment this.status, double this.wFactor, - double this.hFactor, String this.dec) + const AlignFactor( this.status, this.wFactor, + this.hFactor, this.dec) : super(); @override diff --git a/lib/widgets/elements/Frame/Align/Align/index.dart b/lib/widgets/elements/Frame/Align/Align/index.dart index 7531bb23..c33438d3 100644 --- a/lib/widgets/elements/Frame/Align/Align/index.dart +++ b/lib/widgets/elements/Frame/Align/Align/index.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import '../../../../../common/widget_demo.dart'; -import './demo.dart' ; - +import './demo.dart'; const String _flatText0 = """ ### **简介** @@ -10,18 +9,16 @@ const String _flatText0 = """ - 根据自己需求,进行控件对齐 ### **基本用法** > alignment → AlignmentGeometry -- 要对齐右下方的框,您将通过此框一个比子的自然大小更大的严格约束,并且对齐Alignment.bottomRight +- 要对齐右下方的框,那么对这个框对要求会比对子控件更加严肃的约束,使用:Alignment.bottomRight - 同理:Alignment.center,Alignment.bottomLeft,Alignment.topLeft等 """; const String _flatText1 = """ > widthFactor / heightFactor → double - 如果widthFactor / heightFactor 为空,并且外部无任何约束,child控件大小默认,那么这个控件将根据自身尺寸最大化 - - 如果widthFactor / heightFactor 不为空,并且外部无约束,align将匹配对应的child尺寸 - ex:widthFactor/ heightFactor 为2.0;那么widget的宽高为child宽高的两倍 -- 如果widthFactor / heightFactor 为空,并且外部无约束,child控件设置自身大小 -- Alignment部分标签失效 +- 如果widthFactor / heightFactor 为空,并且外部无约束,child控件将会设置自身大小 """; class Demo extends StatefulWidget { @@ -36,17 +33,13 @@ class _DemoState extends State { Widget build(BuildContext context) { return WidgetDemo( title: 'Align', - codeUrl:"elements/Frame/Align/Align/demo.dart", + codeUrl: "elements/Frame/Align/Align/demo.dart", docUrl: 'https://docs.flutter.io/flutter/widgets/Align-class.html', - contentList: [ - _flatText0, - _flatText1, - _AlignCreate() - ], + contentList: [_flatText0, _alignCreate()], ); } - Column _AlignCreate() { + Column _alignCreate() { return new Column( children: [ SizedBox(height: 10.0), @@ -55,7 +48,6 @@ class _DemoState extends State { children: [ AlignAlignment(Alignment.center, 'center'), AlignAlignment(Alignment.centerLeft, 'centerLeft'), - ], ), SizedBox(height: 10.0), @@ -65,7 +57,6 @@ class _DemoState extends State { AlignAlignment(Alignment.centerRight, 'centerRight'), AlignAlignment(Alignment.bottomCenter, 'btCenter'), AlignAlignment(Alignment.topCenter, 'topCenter'), - ], ), SizedBox(height: 10.0), @@ -84,13 +75,13 @@ class _DemoState extends State { color: Color(0xffe91e63), child: new Align( alignment: Alignment.topLeft, - child: new Text("Align",style: - TextStyle(color: Color(0xffffffff)),), + child: new 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'), diff --git a/lib/widgets/elements/Frame/Axis/crossAxis/index.dart b/lib/widgets/elements/Frame/Axis/crossAxis/index.dart deleted file mode 100644 index 55dd8402..00000000 --- a/lib/widgets/elements/Frame/Axis/crossAxis/index.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:flutter/material.dart'; -import '../../../../../common/widget-demo.dart'; - -class Demo extends StatefulWidget { - static const String routeName = '/element/Frame/Axis/crossAxis'; - _DemoState createState() => _DemoState(); -} - -class _DemoState extends State { - @override - Widget build(BuildContext context) { - return WidgetDemo( - title: 'crossAxis', - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - ], - ), - docUrl: 'https://docs.flutter.io/flutter/widgets/Padding-class.html', - ); - } -} diff --git a/lib/widgets/elements/Frame/Axis/flipAxis/index.dart b/lib/widgets/elements/Frame/Axis/flipAxis/index.dart deleted file mode 100644 index 78d2fa8d..00000000 --- a/lib/widgets/elements/Frame/Axis/flipAxis/index.dart +++ /dev/null @@ -1,79 +0,0 @@ -import 'package:flutter/material.dart'; -import '../../../../../common/widget-demo.dart'; - -class Demo extends StatefulWidget { - static const String routeName = '/element/Frame/Axis/flipAxis'; - _DemoState createState() => _DemoState(); -} - -class _DemoState extends State { - Axis _direction ; - - @override - void initState() { - // TODO: implement initState - super.initState(); - _direction = Axis.horizontal; - } - - Axis flipAxis() { - assert(_direction != null); - switch (_direction) { - case Axis.horizontal: - return Axis.vertical; - case Axis.vertical: - return Axis.horizontal; - } - return null; - } - - _changeDirection(){ - setState(() { - _direction=flipAxis(); - }); - } - - @override - Widget build(BuildContext context) { - return WidgetDemo( - title: 'flipAxis', - child: Flex( - direction: _direction, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - RaisedButton( - child: Text('change direction'), - onPressed: _changeDirection, - ) - ], - ), - docUrl: 'https://docs.flutter.io/flutter/painting/flipAxis.html', - ); - } -} diff --git a/lib/widgets/elements/Frame/Axis/index.dart b/lib/widgets/elements/Frame/Axis/index.dart deleted file mode 100644 index 1d98fcb5..00000000 --- a/lib/widgets/elements/Frame/Axis/index.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; -import '../../../../model/widget.dart'; - -import './crossAxis/index.dart' as crossAxis; -import './flipAxis/index.dart' as flipAxis; -import './mainAxis/index.dart' as mainAxis; - -List widgetPoints = [ - WidgetPoint( - name: 'crossAxis', - routerName: crossAxis.Demo.routeName, - buildRouter: (BuildContext context) => crossAxis.Demo(), - ), - WidgetPoint( - name: 'flipAxis', - routerName: flipAxis.Demo.routeName, - buildRouter: (BuildContext context) => flipAxis.Demo(), - ), - WidgetPoint( - name: 'mainAxis', - routerName: mainAxis.Demo.routeName, - buildRouter: (BuildContext context) => mainAxis.Demo(), - ), -]; diff --git a/lib/widgets/elements/Frame/Axis/mainAxis/index.dart b/lib/widgets/elements/Frame/Axis/mainAxis/index.dart deleted file mode 100644 index a957f28c..00000000 --- a/lib/widgets/elements/Frame/Axis/mainAxis/index.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:flutter/material.dart'; -import '../../../../../common/widget-demo.dart'; - -class Demo extends StatefulWidget { - static const String routeName = '/element/Frame/Axis/Table'; - _DemoState createState() => _DemoState(); -} - -class _DemoState extends State { - @override - Widget build(BuildContext context) { - return WidgetDemo( - title: 'mainAxis', - child: Flex( - direction: Axis.vertical, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - Container( - height: 20.0, - width: 20.0, - color: Colors.blueAccent, - margin: const EdgeInsets.all(10.0), - ), - ], - ), - docUrl: - 'https://docs.flutter.io/flutter/material/MergeableMaterial/mainAxis.html', - ); - } -} diff --git a/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart b/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart index 5405b6ef..90995e77 100644 --- a/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/ConstrainedBox/demo.dart @@ -1,19 +1,24 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/11/22 * Email: xiaojia.dxj@alibaba-inc.com * LastUpdateTime: 2018/11/22 * LastUpdateBy: xj.deng * - * Describle:Align描述 + * Describle:ConstrainedBox描述 */ -class ConstracubedBox extends StatelessWidget { +class ConstrainedBoxCreate extends StatelessWidget { + final double currWidth; + final String describe; + + const ConstrainedBoxCreate({Key key,this.currWidth,this.describe}): + super(key: key); + @override Widget build(BuildContext context) { - return Column( children: [ ConstrainedBox( @@ -21,20 +26,22 @@ class ConstracubedBox extends StatelessWidget { constraints: const BoxConstraints( minWidth: 100.0, minHeight: 20.0, - maxWidth: 500.0, + maxWidth: 300.0, maxHeight: 50.0, ), child: new Container( margin: const EdgeInsets.only(left: 20.0, right: 20.0), //child 宽高超过制定限制范围失效,效果宽/高=100/20区域 - width: 600.0, + width: currWidth, height: 250.0, - child: new Text('ConstrainedBox',style: TextStyle(color: Colors.white),), - color: Colors.red, + child: new Text( + describe, + style: TextStyle(color: Colors.white), + ), + color: Color(0xfff8bbd0), ), ), - ], ); } -} \ No newline at end of file +} diff --git a/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart b/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart index 79969dd2..b9fbc78c 100644 --- a/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/ConstrainedBox/index.dart @@ -17,7 +17,11 @@ const String _Text = ''' const String _Text1 = ''' ### **基本用法** > 添加额外的限制条件到child上 -- 比如说,你限制child最小高度为50.0像素,就可以用constraints: const BoxConstraints(minHeight:50) +- ex:添加ConstrainedBox约束如下,传入不同Width约束的Container效果 +minWidth: 100.0, +minHeight: 20.0, +maxWidth: 300.0, +maxHeight: 50.0 '''; @@ -36,7 +40,27 @@ class _DemoState extends State { contentList: [ _Text, _Text1, - ConstracubedBox(), + // maxWidth: 300.0, + ConstrainedBoxCreate(currWidth: 500, describe: "currWidth>maxWidth"), + SizedBox( + height: 10.0, + ), + ConstrainedBoxCreate(currWidth: 300, describe: "currWidth=maxWidth"), + SizedBox( + height: 10.0, + ), + ConstrainedBoxCreate(currWidth: 200, describe: "currWidthminWidth"), + SizedBox( + 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 a32fe44a..8539ead3 100644 --- a/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/DecoratedBox/demo.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/11/22 * Email: xiaojia.dxj@alibaba-inc.com @@ -17,15 +17,65 @@ class DecoratedBoxCreate extends StatelessWidget { @override Widget build(BuildContext context) { return DecoratedBox( - position: DecorationPosition.foreground, + position: DecorationPosition.background, decoration: BoxDecoration( - gradient: RadialGradient( - center: const Alignment(-0.5, -0.6), - radius: 0.15, - colors: [const Color(0xFFEEEEEE), Colors.pink.shade600], - stops: [0.9, 1.0], + color: const Color(0xff7c94b6), + //设置图片内容 + image: new DecorationImage( + fit: BoxFit.cover, + image: ExactAssetImage('assets/images/food01.jpeg')), + //外宽边框,可以不设置 + border: Border.all( + color: Colors.blue.shade50, + width: 10.0, ), ), ); } } + +class DecoratedBoxCreateTwo extends StatelessWidget { + DecoratedBoxCreateTwo({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return DecoratedBox( + position: DecorationPosition.background, + decoration: BoxDecoration( + color: const Color(0xff7c94b6), + //设置图片内容 + image: new DecorationImage( + fit: BoxFit.cover, + image: ExactAssetImage('assets/images/food01.jpeg')), + //根据传入的不同大小,呈现图片效弧度不同, + borderRadius: BorderRadius.circular(90.0), + ), + ); + } +} + +class DecoratedBoxCreateShape extends StatelessWidget { + DecoratedBoxCreateShape({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return DecoratedBox( + position: DecorationPosition.background, + decoration: BoxDecoration( + color: const Color(0xff7c94b6), + image: new DecorationImage( + fit: BoxFit.cover, + image: ExactAssetImage('assets/images/food01.jpeg')), + border: Border.all( + color: Colors.blue.shade50, + width: 5.0, + ), + shape: BoxShape.circle, + ), + ); + } +} diff --git a/lib/widgets/elements/Frame/Box/DecoratedBox/index.dart b/lib/widgets/elements/Frame/Box/DecoratedBox/index.dart index 32645d8d..8ad78bbd 100644 --- a/lib/widgets/elements/Frame/Box/DecoratedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/DecoratedBox/index.dart @@ -6,15 +6,21 @@ */ import 'package:flutter/material.dart'; import '../../../../../common/widget_demo.dart'; -import './demo.dart' as decoratedBox; +import './demo.dart'; const String _Text = """### **简介** -> 在绘制前或绘制后,添加额外的限制条件到child上的widget +> 在child绘制前或绘制后,添加额外的限制条件到child上的widget - 根据边界的宽高,对其child进行插入绘制 """; const String _Text1 = """### **基本用法** -> 常用于BoxDecoration +> decoration → Decoration +- 常用于BoxDecoration +- BoxDecoration提供多种方式来绘制以一个框 +- 盒子形状可以是圆形也可以是矩形,用borderRadius属性来绘制角度 + +> position → DecorationPosition +- position: DecorationPosition.foreground, """; class Demo extends StatefulWidget { @@ -32,19 +38,35 @@ class _DemoState extends State { contentList: [ _Text, _Text1, - _DecoratedBoxCreate(), + _decoratedBoxCreate(), ], docUrl: 'https://docs.flutter.io/flutter/widgets/DecoratedBox-class.html', ); } - Column _DecoratedBoxCreate() { + Column _decoratedBoxCreate() { return new Column( children: [ Container( - height: 200.0, - width: 200.0, - child: decoratedBox.DecoratedBoxCreate(), + height: 100.0, + width: 100.0, + child: DecoratedBoxCreate(), + ), + SizedBox( + height: 10.0, + ), + Container( + height: 100.0, + width: 100.0, + child: DecoratedBoxCreateTwo(), + ), + SizedBox( + height: 10.0, + ), + Container( + height: 100.0, + width: 100.0, + child: DecoratedBoxCreateShape(), ) ], ); diff --git a/lib/widgets/elements/Frame/Box/Fittedbox/demo.dart b/lib/widgets/elements/Frame/Box/Fittedbox/demo.dart index b1022cc7..108ad98d 100644 --- a/lib/widgets/elements/Frame/Box/Fittedbox/demo.dart +++ b/lib/widgets/elements/Frame/Box/Fittedbox/demo.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/12/2 * Email: xiaojia.dxj@alibaba-inc.com @@ -13,9 +13,9 @@ import 'package:flutter/widgets.dart'; class FittedBoxDefault extends StatelessWidget { final BoxFit curfit; - String dec; + final String dec; - FittedBoxDefault({Key key, BoxFit this.curfit, this.dec}); + FittedBoxDefault({Key key, this.curfit, this.dec}); @override Widget build(BuildContext context) { @@ -25,16 +25,14 @@ class FittedBoxDefault extends StatelessWidget { //外部有位置约束,内部大小设定失效,保持和外部约束一致 height: 100.0, width: 100.0, - color: Colors.yellow, + color: Color(0xfff8bbd0), child: FittedBox( fit: curfit, // 修改child写入布局时期分配的空间 alignment: Alignment.center, //alignment修改child于父空间对齐方式,默认:Alignment.center, child: Container( -// height: 50.0, -// width: 50.0, - color: Colors.red, + color: Color(0xfff48fb1), child: Text( 'fittedBox', style: TextStyle(color: Colors.white), diff --git a/lib/widgets/elements/Frame/Box/Fittedbox/index.dart b/lib/widgets/elements/Frame/Box/Fittedbox/index.dart index 85160d42..18fac673 100644 --- a/lib/widgets/elements/Frame/Box/Fittedbox/index.dart +++ b/lib/widgets/elements/Frame/Box/Fittedbox/index.dart @@ -22,7 +22,7 @@ const String Text1 = """ > 根据外部约束,调整child - 如果外部没有约束,按照child的大小。 - 如果外部有约束,按照外部约束调整自身大小,然后缩放调整child,根据条件进行放置 -- BoxFix 属性,修改child写入布局时期分配的空间 +- BoxFix 属性,可修改child写入布局时期分配的空间 - alignment修改child于父空间对齐方式,默认:Alignment.center, """; @@ -42,12 +42,12 @@ class _DemoState extends State { contentList: [ Text0, Text1, - _FittedBoxCreate(), + _fittedBoxCreate(), ], ); } - Column _FittedBoxCreate() { + Column _fittedBoxCreate() { return Column( children: [ Row( diff --git a/lib/widgets/elements/Frame/Box/LimitedBox/demo.dart b/lib/widgets/elements/Frame/Box/LimitedBox/demo.dart index d68be211..170c9b7a 100644 --- a/lib/widgets/elements/Frame/Box/LimitedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/LimitedBox/demo.dart @@ -4,14 +4,69 @@ import 'package:flutter/material.dart'; class LimitedBoxDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return LimitedBox( - maxWidth: 50.0, - maxHeight: 150.0, - child: Container( - width: 250.0, - height: 150.0, - color: Colors.red, - ), + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + width: 100, + height: 100, + color: Color(0xfff8bbd0), + child: Text( + "100 * 100", + style: TextStyle(color: Colors.white), + ), + ), + LimitedBox( + maxWidth: 100, + maxHeight: 100, + child: Container( + width: 250, + height: 300, + child: Text( + "250 * 300", + style: TextStyle(color: Colors.white), + ), + color: Color(0xfff48fb1), + ), + ) + ], + ); + } +} + +class LimitedBoxColumnDemo extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + SizedBox( + child: Text("Column 列表下效果"), + ), + Container( + width: 100, + height: 100, + color: Color(0xfff8bbd0), + child: Text( + "100 * 100", + style: TextStyle(color: Colors.white), + ), + ), + SizedBox(height: 10.0), + LimitedBox( + maxWidth: 100, + maxHeight: 100, + child: Container( + width: 250, + height: 300, + child: Text( + "250 * 300", + style: TextStyle(color: Colors.white), + ), + color: Color(0xfff48fb1), + ), + ) + ], ); } } diff --git a/lib/widgets/elements/Frame/Box/LimitedBox/index.dart b/lib/widgets/elements/Frame/Box/LimitedBox/index.dart index c0ea454c..89dfdb58 100644 --- a/lib/widgets/elements/Frame/Box/LimitedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/LimitedBox/index.dart @@ -10,15 +10,17 @@ import './demo.dart'; const String Text0 = """ ### **LimitedBox** -> 对最大宽高进行限制的控件 -- 即:将child限制在指定的最大宽高中,如果LimitedBox外部没有约束,那么最大宽高不受限制,child的宽高受到LimitedBox最大宽高限制 +> 对最大宽高进行限制的控件(前提是LimitedBox不受约束) +- 即:将child限制在指定的最大宽高中 +- 这就使得child自身没有约束大小的时候具有了外部约束,依然控制了其大小 +- 例如:通过给LimitedBox最大高度(maxHeight),widget通常会调整其自身的大小去适应父窗体,但是,当放置在竖直(cloumn)列表中时,它将采用给定的高度 """; const String Text1 = """ ### **基本用法** > widget 限制child最大宽高,如下: -- maxHeight限制最大高度 -- maxWidth限制最大宽 +- 如果LimitedBox外部宽度没有被约束,child的宽受到LimitedBox最大宽度(maxWidth)属性限制 +- 同理,LimitedBox外部高度没有约束,child的高受到LimitedBox最大高度(maxHeight)属性限制 """; @@ -40,6 +42,8 @@ class _DemoState extends State { Text0, Text1, LimitedBoxDemo(), + SizedBox(height: 30), + LimitedBoxColumnDemo(), ], ); } diff --git a/lib/widgets/elements/Frame/Box/OverflowBox/demo.dart b/lib/widgets/elements/Frame/Box/OverflowBox/demo.dart index 8966df6e..f7357a02 100644 --- a/lib/widgets/elements/Frame/Box/OverflowBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/OverflowBox/demo.dart @@ -2,26 +2,26 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; class OverflowBoxDefault extends StatelessWidget { - double curmaxHeight; - double curmaxWidth; - double curHeight; - double curWidth; - AlignmentGeometry curalignment; + final double curmaxHeight; + final double curmaxWidth; + final double curHeight; + final double curWidth; + final AlignmentGeometry curalignment; OverflowBoxDefault( {Key key, - double this.curmaxHeight, - double this.curmaxWidth, - double this.curWidth, - double this.curHeight, - AlignmentGeometry this.curalignment}) + this.curmaxHeight, + this.curmaxWidth, + this.curWidth, + this.curHeight, + this.curalignment}) : super(key: key); @override Widget build(BuildContext context) { return OverflowBox( - minHeight: 50.0, - minWidth: 50.0, + minHeight: 80.0, + minWidth: 80.0, //设置最大宽,高 maxWidth: curmaxWidth, maxHeight: curmaxHeight, @@ -36,7 +36,8 @@ class OverflowBoxDefault extends StatelessWidget { * * */ height: curHeight, width: curWidth, - color: Colors.red, + child: Text("$curmaxWidth * $curmaxHeight",style: TextStyle(color: Colors.white),), + color: Color(0xfff48fb1), ), ); } diff --git a/lib/widgets/elements/Frame/Box/OverflowBox/index.dart b/lib/widgets/elements/Frame/Box/OverflowBox/index.dart index a2458df9..b0f49279 100644 --- a/lib/widgets/elements/Frame/Box/OverflowBox/index.dart +++ b/lib/widgets/elements/Frame/Box/OverflowBox/index.dart @@ -5,12 +5,11 @@ * @Last Modified time: 2019-01-08 15:56:31 */ import 'package:flutter/material.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; import '../../../../../common/widget_demo.dart'; import './demo.dart' as overflowBox; const String Text0 = """### **OverflowBox简介** -> 它对子进程施加的约束不同于从其父进程获得的约束,可能允许子进程溢出父进程. +> 它对child施加的约束不同于从其父控件获得的约束,可能允许child溢出父控件的空间. - 当OverflowBox的最大尺寸大于child的时候,child可以完整显示,当其小于child的时候,则以最大尺寸为基准,当然,这个尺寸都是可以突破父节点的 """; @@ -39,51 +38,59 @@ class _DemoState extends State { contentList: [ Text0, Text1, - _OverflowBoxCreate(), + _overflowBoxCreate(), ], ); } - Row _OverflowBoxCreate() { - return Row( + Column _overflowBoxCreate() { + return Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Text("宽高都小于最小限制"), Container( width: 100.0, height: 100.0, - color: Colors.yellow, + color: Color(0xfff8bbd0), child: overflowBox.OverflowBoxDefault( - curmaxHeight: 50.0, - curmaxWidth: 50.0, - curHeight: 100.0, - curWidth: 100.0, - curalignment: Alignment.center, + curmaxHeight: 150.0, + curmaxWidth: 150.0, + //宽高都小于最小限制 + curHeight: 50.0, + curWidth: 50.0, + curalignment: Alignment.bottomLeft, ), ), + SizedBox(height: 20), + Text("在限制之内"), Container( width: 100.0, height: 100.0, - color: Colors.yellow, + color: Color(0xfff8bbd0), child: overflowBox.OverflowBoxDefault( curmaxHeight: 150.0, curmaxWidth: 150.0, - curHeight: 50.0, - curWidth: 50.0, - curalignment: Alignment.bottomLeft, + curHeight: 80.0, + curWidth: 80.0, + curalignment: Alignment.topRight, ), ), + SizedBox(height: 20), + SizedBox(height: 50,child: Text("宽高都大于最大限制"),), Container( width: 100.0, height: 100.0, - color: Colors.yellow, + color: Color(0xfff8bbd0), child: overflowBox.OverflowBoxDefault( curmaxHeight: 150.0, curmaxWidth: 150.0, - curHeight: 40.0, - curWidth: 40.0, - curalignment: Alignment.topRight, + //宽高大于最大限制 + curHeight: 200.0, + curWidth: 200.0, + curalignment: Alignment.center, ), ), + ], ); } diff --git a/lib/widgets/elements/Frame/Box/RenderBox/index.dart b/lib/widgets/elements/Frame/Box/RenderBox/index.dart index 58539a94..df740656 100644 --- a/lib/widgets/elements/Frame/Box/RenderBox/index.dart +++ b/lib/widgets/elements/Frame/Box/RenderBox/index.dart @@ -6,7 +6,6 @@ */ import 'package:flutter/material.dart'; import '../../../../../common/widget_demo.dart'; -import './demo.dart' as sizeBox; const String _Text = ''' ### **简介** @@ -35,13 +34,13 @@ class _DemoState extends State { codeUrl: 'elements/Frame/Box/RenderBox/demo.dart', contentList: [ _Text, - _SizeBoxCreate(), + _sizeBoxCreate(), ], docUrl: 'https://docs.flutter.io/flutter/widgets/RenderBox-class.html', ); } - Column _SizeBoxCreate() { + Column _sizeBoxCreate() { return new Column( children: [ /** diff --git a/lib/widgets/elements/Frame/Box/SizeBox/index.dart b/lib/widgets/elements/Frame/Box/SizeBox/index.dart index 36ee028f..dab70e6d 100644 --- a/lib/widgets/elements/Frame/Box/SizeBox/index.dart +++ b/lib/widgets/elements/Frame/Box/SizeBox/index.dart @@ -21,13 +21,13 @@ class _DemoState extends State { title: 'Table', codeUrl: 'elements/Frame/Box/SizedBox/demo.dart', contentList: [ - _SizeBoxCreate(), + _sizeBoxCreate(), ], docUrl: 'https://docs.flutter.io/flutter/widgets/SizedBox-class.html', ); } - Column _SizeBoxCreate() { + Column _sizeBoxCreate() { return new Column( children: [ new Text("SizedBox", diff --git a/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart b/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart index 3eb7f24c..034f9bc4 100644 --- a/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/SizedOverflowBox/demo.dart @@ -8,9 +8,9 @@ class SizeOverflowBoxDefault extends StatelessWidget { SizeOverflowBoxDefault( {Key key, - double this.curSizeWidth, - double this.curSizeHeight, - String this.text}) + this.curSizeWidth, + this.curSizeHeight, + this.text}) : super(key: key); @override @@ -36,7 +36,7 @@ class SizeBoxDefault extends StatelessWidget { final double curWidth; final double curHeight; - SizeBoxDefault({Key key, double this.curHeight, double this.curWidth}) + SizeBoxDefault({Key key, this.curHeight, this.curWidth}) : super(key: key); @override diff --git a/lib/widgets/elements/Frame/Box/TextBox/index.dart b/lib/widgets/elements/Frame/Box/TextBox/index.dart index 75d79d9e..cc48e960 100644 --- a/lib/widgets/elements/Frame/Box/TextBox/index.dart +++ b/lib/widgets/elements/Frame/Box/TextBox/index.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import '../../../../../common/widget_demo.dart'; -import './demo.dart' as TextBox; const String _Text = """### **TextBox简介** > 是一个包含一段文本的矩形 diff --git a/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart b/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart index d724d1bb..9f171c45 100644 --- a/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart +++ b/lib/widgets/elements/Frame/Box/UnconstrainedBox/demo.dart @@ -9,19 +9,16 @@ class UnconstrainedBoxDemo extends StatelessWidget { child: new Row( children: [ Container( - width: 200.0, - height: 200.0, - color: Colors.red, + width: 100.0, + height: 100.0, + color: Color(0xfff48fb1), + child: Text( + "data", + style: TextStyle(color: Colors.white), + ), ), ], ), -// child: Text( -// 'This allows a child to render at the size it would render ' -// 'if it were alone on an infinite canvas with no constraints. ' -// 'This container will then attempt to adopt the same size, within' -// ' the limits of its own constraints. If it ends up with a different size, ' -// 'it will align the child based on alignment. If the box cannot expand enough ' -// 'to accommodate the entire child, the child will be clipped'), ); } } diff --git a/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart b/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart index b82168e1..42f60123 100644 --- a/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart +++ b/lib/widgets/elements/Frame/Box/UnconstrainedBox/index.dart @@ -11,19 +11,15 @@ import './demo.dart'; const String Text0 = """### **简介** > 跟ConstrainedBox相反,是不添加任何约束条件到child上,让child按照其原始的尺寸渲染 - 它的作用就是给child一个尽可能大的空间,不加约束的让其显示。 +- 如果该widget不能扩展到到足够容纳整个child的空间,child将被裁剪 """; const String Text1 = """ ### **基本用法** -mainAxisSize 属性 -- 一行的高度是有mainAxisSize属性控制,默认是max +- alignment 属性:控制child对齐方式 +- textDirection 属性:控制文本对齐 +- constrainedAxis 属性:如果有,就使用 -mainAxisAlignment属性 -- 将children放置在主轴某位置 - -CrossAxisAlignment 属性 -- crossAxisAlignment: crossAxisAlignment.center/end/start, -- 即,根据设定的位置交叉对齐 """; class Demo extends StatefulWidget { @@ -44,6 +40,7 @@ class _DemoState extends State { 'https://docs.flutter.io/flutter/widgets/UnconstrainedBox-class.html', contentList: [ Text0, + Text1, UnconstrainedBoxDemo(), ], ); diff --git a/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart b/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart index a56e2db5..398e5333 100644 --- a/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart +++ b/lib/widgets/elements/Frame/Expanded/Expanded/expanded_demo.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; class ExpandedDemo extends StatelessWidget { - TextStyle txtColor = TextStyle(color: Colors.white); + final TextStyle txtColor = TextStyle(color: Colors.white); @override Widget build(BuildContext context) { return Column( diff --git a/lib/widgets/elements/Frame/Layout/Column/demo.dart b/lib/widgets/elements/Frame/Layout/Column/demo.dart index 246e314c..e94c8a78 100644 --- a/lib/widgets/elements/Frame/Layout/Column/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Column/demo.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/11/22 * Email: xiaojia.dxj@alibaba-inc.com diff --git a/lib/widgets/elements/Frame/Layout/Container/demo.dart b/lib/widgets/elements/Frame/Layout/Container/demo.dart index e7853f80..110359ef 100644 --- a/lib/widgets/elements/Frame/Layout/Container/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Container/demo.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/11/22 * Email: xiaojia.dxj@alibaba-inc.com diff --git a/lib/widgets/elements/Frame/Layout/Container/index.dart b/lib/widgets/elements/Frame/Layout/Container/index.dart index 60b48dc6..6fbf8e97 100644 --- a/lib/widgets/elements/Frame/Layout/Container/index.dart +++ b/lib/widgets/elements/Frame/Layout/Container/index.dart @@ -5,8 +5,8 @@ import './demo.dart'; const String Text0 = """### **简介** > 一个常用的widget,它结合了常见的绘画,定位和大小调整 - 该容器首先让child填充绘制,然后再将其他的约束应用于填充范围。 -- 在绘画过程中,容器先应用给定的转换,在绘制装饰以填充的范围,然后绘制child,最后绘制前景,同时填充需要填充的范围 -- 没有child的容器试图尽可能的大,除非传入的约束是无限制的。child的大小会被width,height等约束覆盖。 +- 在绘画过程中,容器先应用给定的转换,再绘制装饰以填充的范围,然后绘制child,最后绘制前景,同时填充需要填充的范围 +- 没有child的容器将尽可能的大,除非传入的约束是无限制的。child的大小会被width,height等约束覆盖。 """; const String Text1 = """ diff --git a/lib/widgets/elements/Frame/Layout/Row/demo.dart b/lib/widgets/elements/Frame/Layout/Row/demo.dart index 0cac6995..8beb078c 100644 --- a/lib/widgets/elements/Frame/Layout/Row/demo.dart +++ b/lib/widgets/elements/Frame/Layout/Row/demo.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/11/22 * Email: xiaojia.dxj@alibaba-inc.com @@ -10,7 +10,7 @@ import 'package:flutter/widgets.dart'; * Describle:Row */ class RowMainAxisAlignment extends StatelessWidget { - /** + /* * > mainAxisAlignment属性 * - MainAxisAlignment.spaceEvenly/spaceAround/spaceBetween, - spaceEvenly:将主轴方向空白区域均分,使得children之间空间相等,包括首尾childre @@ -23,7 +23,7 @@ class RowMainAxisAlignment extends StatelessWidget { */ final MainAxisAlignment status; - /** + /* * > CrossAxisAlignment 属性 - crossAxisAlignment: CrossAxisAlignment.center/end/start, - 即,根据设定的位置交叉对齐 @@ -34,9 +34,7 @@ class RowMainAxisAlignment extends StatelessWidget { final CrossAxisAlignment crossStatus; - const RowMainAxisAlignment( - MainAxisAlignment this.status, CrossAxisAlignment this.crossStatus) - : super(); + const RowMainAxisAlignment(this.status, this.crossStatus) : super(); @override Widget build(BuildContext context) { @@ -63,8 +61,8 @@ class RowMainAxisAlignment extends StatelessWidget { } } -class RowLayout extends StatelessWidget { - const RowLayout() : super(); +class RowLayoutCreate extends StatelessWidget { + const RowLayoutCreate() : super(); @override Widget build(BuildContext context) { diff --git a/lib/widgets/elements/Frame/Layout/Row/index.dart b/lib/widgets/elements/Frame/Layout/Row/index.dart index 119aa3de..a4e0d041 100644 --- a/lib/widgets/elements/Frame/Layout/Row/index.dart +++ b/lib/widgets/elements/Frame/Layout/Row/index.dart @@ -3,10 +3,10 @@ import '../../../../../common/widget_demo.dart'; import './demo.dart'; const String Text0 = """### **简介** -> Row 是一个将其child显示在水平数组的小部件 +> Row 是一个将其child显示在水平数组的widget - 将其child填充可用的横向水平空间,一行高度是childs的最大高度(即:总是满足传入的垂直约束) - 如果你只有一个child,只需要考虑使用对其或者中间位置,如果多个child,注意扩展水平空间(Expanded),可以将child封装在一个扩展部件里面 -- 当我们看到行有黄色和黑色条纹警告时候,说明行已经溢出,当行溢出,行之间当空间将没有任何空间可供扩展。 +- 当我们看到行有黄色和黑色条纹警告时候,说明行已经溢出,当行溢出,行之间空间将没有任何空间可供扩展。 """; @@ -43,15 +43,15 @@ class _DemoState extends State { contentList: [ Text0, Text1, - _RowCreate(), + _rowCreate(), ], ); } - Column _RowCreate() { + Column _rowCreate() { return new Column( children: [ - RowLayout(), + RowLayoutCreate(), Row( children: [ Expanded( diff --git a/lib/widgets/elements/Frame/spacing/AnimatedPadding/animatedPadding_demo.dart b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart similarity index 100% rename from lib/widgets/elements/Frame/spacing/AnimatedPadding/animatedPadding_demo.dart rename to lib/widgets/elements/Frame/Spacing/AnimatedPadding/animatedPadding_demo.dart diff --git a/lib/widgets/elements/Frame/spacing/AnimatedPadding/index.dart b/lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart similarity index 100% rename from lib/widgets/elements/Frame/spacing/AnimatedPadding/index.dart rename to lib/widgets/elements/Frame/Spacing/AnimatedPadding/index.dart diff --git a/lib/widgets/elements/Frame/spacing/Padding/index.dart b/lib/widgets/elements/Frame/Spacing/Padding/index.dart similarity index 100% rename from lib/widgets/elements/Frame/spacing/Padding/index.dart rename to lib/widgets/elements/Frame/Spacing/Padding/index.dart diff --git a/lib/widgets/elements/Frame/spacing/Padding/padding_demo.dart b/lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart similarity index 100% rename from lib/widgets/elements/Frame/spacing/Padding/padding_demo.dart rename to lib/widgets/elements/Frame/Spacing/Padding/padding_demo.dart diff --git a/lib/widgets/elements/Frame/spacing/SliverPadding/index.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart similarity index 100% rename from lib/widgets/elements/Frame/spacing/SliverPadding/index.dart rename to lib/widgets/elements/Frame/Spacing/SliverPadding/index.dart diff --git a/lib/widgets/elements/Frame/spacing/SliverPadding/product_list.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart similarity index 100% rename from lib/widgets/elements/Frame/spacing/SliverPadding/product_list.dart rename to lib/widgets/elements/Frame/Spacing/SliverPadding/product_list.dart diff --git a/lib/widgets/elements/Frame/spacing/SliverPadding/sliverpadding_demo.dart b/lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart similarity index 100% rename from lib/widgets/elements/Frame/spacing/SliverPadding/sliverpadding_demo.dart rename to lib/widgets/elements/Frame/Spacing/SliverPadding/sliverpadding_demo.dart diff --git a/lib/widgets/elements/Frame/spacing/index.dart b/lib/widgets/elements/Frame/Spacing/index.dart similarity index 100% rename from lib/widgets/elements/Frame/spacing/index.dart rename to lib/widgets/elements/Frame/Spacing/index.dart diff --git a/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart b/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart index ba239ad8..bcf289cc 100644 --- a/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart +++ b/lib/widgets/elements/Frame/Stack/IndexedStack/demo.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/11/22 * Email: xiaojia.dxj@alibaba-inc.com @@ -12,7 +12,7 @@ import 'package:flutter/material.dart'; class StackDefault extends StatelessWidget { final int currIndex; - const StackDefault(int this.currIndex) : super(); + const StackDefault( this.currIndex) : super(); @override Widget build(BuildContext context) { @@ -54,7 +54,7 @@ class StackDefault extends StatelessWidget { class StackIndex extends StatelessWidget { final int currIndex; - const StackIndex(int this.currIndex) : super(); + const StackIndex( this.currIndex) : super(); @override Widget build(BuildContext context) { diff --git a/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart b/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart index 6215777b..aac1164c 100644 --- a/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart +++ b/lib/widgets/elements/Frame/Stack/IndexedStack/index.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; import '../../../../../common/widget_demo.dart'; import './demo.dart'; const String _stackText0 = """### **简介** -> 显示来自子项列表的单个子项。 -- 只显示指定位置的窗口小部件,其他的位置的窗口小部件不会显示,所以indexedStack的尺寸永远和最大的子节点一样。 +> 显示一个子项列表的单个子项。 +- 只显示指定位置的widget,其他的位置的widget不会显示,所以indexedStack的尺寸永远和最大的子节点一样。 +- 显示的子项widget是给到了具体的索引选择出来的widget - 如果value 为null,将不显示任何内容 """; const String _stackText1 = """### **基本用法** @@ -22,7 +22,6 @@ class Demo extends StatefulWidget { } class _DemoState extends State { - String _desc = "IndexedStack 使用"; int currIndex = 0; void _indexAdd() { @@ -45,12 +44,12 @@ class _DemoState extends State { contentList: [ _stackText0, _stackText1, - _IndexedStackCreate(), + _indexedStackCreate(), ], ); } - Column _IndexedStackCreate() { + Column _indexedStackCreate() { return new Column( children: [ SizedBox( diff --git a/lib/widgets/elements/Frame/Stack/Stack/demo.dart b/lib/widgets/elements/Frame/Stack/Stack/demo.dart index ea32f633..4af0df05 100644 --- a/lib/widgets/elements/Frame/Stack/Stack/demo.dart +++ b/lib/widgets/elements/Frame/Stack/Stack/demo.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -/** +/* * Author: xiaojia.dxj * Date: 2018/11/22 * Email: xiaojia.dxj@alibaba-inc.com diff --git a/lib/widgets/elements/Frame/Stack/Stack/index.dart b/lib/widgets/elements/Frame/Stack/Stack/index.dart index 165c523f..7cd8f2c1 100644 --- a/lib/widgets/elements/Frame/Stack/Stack/index.dart +++ b/lib/widgets/elements/Frame/Stack/Stack/index.dart @@ -1,12 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; import '../../../../../common/widget_demo.dart'; import './demo.dart'; const String _stackText0 = """### **简介** -> 用于将多个子级相对于其框的边缘定位,多用于以简单方式重叠children +> 用于将多个childs相对于其框的边缘定位,多用于以简单方式重叠children - 当第一个child置于底部时,堆栈按顺序绘制其子项。如果更改子项绘制顺序,可以使用新顺序重新建立堆栈 -- 注意:stack的每一个子节点都已定位或为定位,定位子项必须至少一个非null属性的定位。 +- 注意:stack的每一个子节点都已定位或未定位,定位子项必须至少一个非null属性的定位。 """; const String _stackText1 = """### **基本用法** @@ -36,7 +35,6 @@ class Demo extends StatefulWidget { } class _DemoState extends State { - String _desc = "Stack 使用"; @override Widget build(BuildContext context) { @@ -47,7 +45,7 @@ class _DemoState extends State { docUrl: 'https://docs.flutter.io/flutter/widgets/Stack-class.html', contentList: [ _stackText0, - _StackCreate(), + _stackCreate(), _stackText1, new Container( width: 300.0, @@ -67,7 +65,7 @@ class _DemoState extends State { ); } - Column _StackCreate() { + Column _stackCreate() { return new Column( children: [ Column( diff --git a/lib/widgets/elements/Media/Canvas/index.dart b/lib/widgets/elements/Media/Canvas/index.dart index a47f241e..e3e60ec0 100644 --- a/lib/widgets/elements/Media/Canvas/index.dart +++ b/lib/widgets/elements/Media/Canvas/index.dart @@ -1 +1 @@ -import 'package:flutter/material.dart'; +// import 'package:flutter/material.dart'; diff --git a/lib/widgets/elements/Media/Icon/Icon/demo.dart b/lib/widgets/elements/Media/Icon/Icon/demo.dart index dd023565..6b5d2fc4 100644 --- a/lib/widgets/elements/Media/Icon/Icon/demo.dart +++ b/lib/widgets/elements/Media/Icon/Icon/demo.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; class IconDemo extends StatelessWidget { - Color curColor = Colors.red; + final Color curColor; IconDemo({Key key, this.curColor}) : super(); diff --git a/lib/widgets/elements/Media/Icon/IconData/demo.dart b/lib/widgets/elements/Media/Icon/IconData/demo.dart index 5c7e1b5e..4dae9660 100644 --- a/lib/widgets/elements/Media/Icon/IconData/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconData/demo.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; class IconDataDemo extends StatelessWidget { - Color curColor = Colors.red; + final Color curColor ; IconDataDemo({Key key, this.curColor}) : super(); diff --git a/lib/widgets/elements/Media/Icon/IconTheme/demo.dart b/lib/widgets/elements/Media/Icon/IconTheme/demo.dart index b7a309bf..53fa28a0 100644 --- a/lib/widgets/elements/Media/Icon/IconTheme/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconTheme/demo.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; class IconThemeDemo extends StatelessWidget { - Color curColor = Colors.white; + final Color curColor ; IconThemeDemo({Key key, this.curColor}) : super(); @@ -25,7 +25,7 @@ class IconThemeDemo extends StatelessWidget { } class IconThemeDemo2 extends StatelessWidget { - Color curColor = Colors.white; + final Color curColor ; final double curSize; IconThemeDemo2({Key key, this.curColor, this.curSize}) : super(); diff --git a/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart b/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart index 41b54267..4fb49517 100644 --- a/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart +++ b/lib/widgets/elements/Media/Icon/IconThemeData/demo.dart @@ -8,8 +8,8 @@ import 'package:flutter/material.dart'; class IconThemeDemo extends StatelessWidget { - Color curColor = Colors.white; - double curOpacity; + final Color curColor ; + final double curOpacity; IconThemeDemo({Key key, this.curColor, this.curOpacity}) : super(); @@ -29,7 +29,7 @@ class IconThemeDemo extends StatelessWidget { } class IconThemeDemo2 extends StatelessWidget { - Color curColor = Colors.white; + final Color curColor ; final double curSize; IconThemeDemo2({Key key, this.curColor, this.curSize}) : super(); diff --git a/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart b/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart index 1037a169..9aabe6fe 100644 --- a/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart +++ b/lib/widgets/elements/Media/Image/DecorationImagePainter/index.dart @@ -6,8 +6,6 @@ */ import 'package:flutter/material.dart'; import '../../../../../common/widget_demo.dart'; -import './decoration_image_painter_demo.dart'; -import 'dart:ui'; const contentText0 = ''' ### **简介** diff --git a/lib/widgets/elements/Media/Image/paintImage/index.dart b/lib/widgets/elements/Media/Image/paintImage/index.dart index da9eae7a..51faa110 100644 --- a/lib/widgets/elements/Media/Image/paintImage/index.dart +++ b/lib/widgets/elements/Media/Image/paintImage/index.dart @@ -6,7 +6,6 @@ */ import 'package:flutter/material.dart'; import '../../../../../common/widget_demo.dart'; -import './paint_image_demo.dart'; const String contentText0 = ''' ### **非Widget 待删除** diff --git a/lib/widgets/elements/Media/Image/precacheImage/index.dart b/lib/widgets/elements/Media/Image/precacheImage/index.dart index 814decb7..5d6e832f 100644 --- a/lib/widgets/elements/Media/Image/precacheImage/index.dart +++ b/lib/widgets/elements/Media/Image/precacheImage/index.dart @@ -5,7 +5,6 @@ * @Last Modified time: 2018-11-16 15:09:12 */ import 'package:flutter/material.dart'; -import '../../../../../common/widget-demo.dart'; class Demo extends StatefulWidget { static const String routeName = '/element/Media/Image/precacheImage'; diff --git a/lib/widgets/themes/Material/MaterialColor/demo.dart b/lib/widgets/themes/Material/MaterialColor/demo.dart index 003163b3..393524ba 100644 --- a/lib/widgets/themes/Material/MaterialColor/demo.dart +++ b/lib/widgets/themes/Material/MaterialColor/demo.dart @@ -14,7 +14,7 @@ class Palette { final String name; final MaterialColor primary; - /** + /* * MaterialAccentColor:定义单一的色滴,颜色的阴影用索引表示, * 索引比较小的颜色比较浅,较大的索引较暗 */