Revert "add widget SliderNew"

This commit is contained in:
hanxu317317
2019-08-13 15:16:21 +08:00
committed by GitHub
parent adf5dba183
commit 3e7daebe79
160 changed files with 832 additions and 10771 deletions

View File

@ -6,28 +6,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_go/components/cate_card.dart';
import 'package:flutter_go/routers/application.dart';
import 'package:flutter_go/model/cat.dart';
class WidgetPage extends StatefulWidget {
final db;
final CatControlModel catModel;
WidgetPage(this.db)
: catModel = new CatControlModel(),
super();
@override
SecondPageState createState() => new SecondPageState();
SecondPageState createState() => new SecondPageState(catModel);
}
class SecondPageState extends State<WidgetPage> with AutomaticKeepAliveClientMixin{
SecondPageState() : super();
CatControlModel catModel;
SecondPageState(this.catModel) : super();
TextEditingController controller;
String active = 'test';
String data = '';
List<Cat> categories = [];
@override
bool get wantKeepAlive => true;
@ -35,16 +35,25 @@ class SecondPageState extends State<WidgetPage> with AutomaticKeepAliveClientMix
@override
void initState() {
super.initState();
renderCats();
}
void renderCats() {
catModel.getList().then((List data) {
if (data.isNotEmpty) {
setState(() {
categories = data;
});
}
});
}
Widget buildGrid() {
// 存放最后的widget
List<Widget> tiles = [];
Application.widgetTree.children.forEach((dynamic item) {
for (Cat item in categories) {
tiles.add(new CateCard(category: item));
});
}
return new ListView(
children: tiles,
);
@ -53,6 +62,11 @@ class SecondPageState extends State<WidgetPage> with AutomaticKeepAliveClientMix
@override
Widget build(BuildContext context) {
super.build(context);
if (categories.length == 0) {
return ListView(
children: <Widget>[new Container()],
);
}
return Container(
color: Theme.of(context).backgroundColor,
child: this.buildGrid(),