zoukankan      html  css  js  c++  java
  • sliver

    import 'package:flutter/material.dart';
    import 'package:xxx/bloc/bloc.dart';
    import 'package:xxx/model/model.dart';

    class ArticlePage extends StatelessWidget {
    ArticlePage(this.bloc);

    final ArticleBloc bloc;

    @override
    Widget build(BuildContext context) {
    bloc.addContent();
    return StreamBuilder(
    stream: bloc.dataBloc.stream,
    builder: (context, snapshot) {
    if (snapshot.hasData) {
    ContentModel content = snapshot.data;
    print(content.mainPost);
    return Scaffold(
    appBar: AppBar(
    title: Text(content.title, style: TextStyle(fontSize: 14.0),),
    ),
    body: CustomScrollView(
    slivers: <Widget>[

    SliverPadding(
    padding: EdgeInsets.all(8.0),
    sliver: SliverGrid(
    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
    crossAxisCount: 2,
    mainAxisSpacing: 10.0,
    crossAxisSpacing: 10.0,
    childAspectRatio: 4.0,
    ),
    delegate: SliverChildBuilderDelegate(
    (context, int index) {
    return Container(
    color: Colors.grey,
    child: Text('hello'),
    );
    },
    childCount: 20,
    ),
    ),
    ),

    SliverFixedExtentList(
    itemExtent: 50.0,
    delegate: SliverChildBuilderDelegate((context, int index) {
    return Container(
    color: Colors.blueGrey,
    child: Text('hello2'),
    );
    }),
    ),
    ],
    ),
    floatingActionButton: FloatingActionButton(
    child: Icon(Icons.add),
    onPressed: (){}
    ),
    floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
    bottomNavigationBar: BottomNavigationBar(
    items: [
    BottomNavigationBarItem(
    icon: Icon(Icons.home),
    title: Text('home')
    ),
    BottomNavigationBarItem(
    icon: Icon(Icons.map),
    title: Text('My')
    ),
    ]
    ),
    );
    } else {
    return Scaffold(
    appBar: AppBar(
    title: Text('has no data'),
    ),
    body: Text('has no data'),
    );
    }
    },
    );
    }
    }
    //
    //class ArticlePage extends StatelessWidget {
    // ArticlePage(this.bloc);
    //
    // final ArticleBloc bloc;
    //
    // @override
    // Widget build(BuildContext context) {
    // bloc.addContent();
    // return StreamBuilder(
    // stream: bloc.dataBloc.stream,
    // builder: (context, snapshot) {
    // if (snapshot.hasData) {
    // ContentModel content = snapshot.data;
    // print(content.mainPost);
    // return Scaffold(
    // appBar: AppBar(
    // title: Text(content.title),
    // ),
    // body: Column(
    // children: <Widget>[
    // //main area
    // Text('post owner: ${content.owner}'),
    // Text('post owner: ${content.ownerAvatar}'),
    // Container(
    // double.infinity,
    // color: Colors.red,
    // child: Column(
    // children: content.mainPost,
    // ),
    // ),
    // Text(content.mainPostTime),
    // //replies
    //
    //
    // ],
    // ),
    // );
    // } else {
    // return Scaffold(
    // appBar: AppBar(
    // title: Text('has no data'),
    // ),
    // body: Text('has no data'),
    // );
    // }
    // },
    // );
    // }
    //}
  • 相关阅读:
    微服务-分解应用程序从而实现更好的部署特性及可伸缩性
    <HTML5和CSS3响应式WEB设计指南>译者序
    使用亚马逊的Route53服务
    Java中测试异常的多种方式
    跑在路上的程序员随想
    使用ruby过程中遇到安装gem失败的一些通用解决方案
    Spring-Context之九:在bean定义中使用继承
    Spring-Context之八:一些依赖注入的小技巧
    配置ngnix
    PHP程序员进阶学习书籍参考指南
  • 原文地址:https://www.cnblogs.com/pythonClub/p/10658703.html
Copyright © 2011-2022 走看看