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'),
    // );
    // }
    // },
    // );
    // }
    //}
  • 相关阅读:
    Postman安装出错.NET Framework 4.5 failed to install
    给小白的资源
    windows update自启动解决方法
    Fragment简介及使用
    samba修复
    我的Android知识结构图——20200507停止更新,后续通过标签或分类继续完善结构图
    Android_适配器(adapter)之BaseAdapter
    Android_适配器(adapter)之SimpleAdapter
    Android_适配器(adapter)之ArrayAdapter
    Linux部分场景非常有用的命令集1_chattr&ldd&xargs&screen&ssh&磁盘&du
  • 原文地址:https://www.cnblogs.com/pythonClub/p/10658703.html
Copyright © 2011-2022 走看看