“Flutter Sliver Grid” Ответ

Flutter Sliver Grid

 //Shohel Rana Shanto
         SliverGrid(
           
           delegate: SliverChildBuilderDelegate(
        
           (context,index){
             
             return Card(
               color: Colors.green[100*(index%9+1)],
               child: ListTile(title: Text("shohel$index"),),
             );
           },
           childCount: 100,
         ),
         gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
         ),
Angry Alpaca

Flutter Sliver Grid

import 'package:flutter/material.dart';  
  
void main() => runApp(MyApp());  
  
class MyApp extends StatelessWidget {  
  @override  
  Widget build(BuildContext context) {  
    return MaterialApp(  
      home: Scaffold(  
        body: CustomScrollView(  
          slivers: <Widget>[  
            SliverAppBar(  
              actions: <Widget>[  
                Icon(Icons.camera_front, size: 40,)  
            ],  
              title: Text("SliverGrid Example"),  
              leading: Icon(Icons.menu),  
              backgroundColor: Colors.green,  
              expandedHeight: 100.0,  
              floating: true,  
              pinned: true  
            ),  
            SliverGrid(  
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(  
                crossAxisCount: 4,  
              ) ,  
              delegate: SliverChildBuilderDelegate((BuildContext context, int index) {  
                return new Container(  
                    color: _randomPaint(index),  
                    height: 150.0  
                );  
              }),  
            ),  
          ],  
        ),  
      ),  
    );  
  }  
}  
Color _randomPaint(int index) {  
  if (index % 3 == 0) {  
    return Colors.orange;  
  } else if (index % 3 == 1) {  
    return Colors.blue;  
  }  
  return Colors.red;  
}  
Helpless Hummingbird

Ответы похожие на “Flutter Sliver Grid”

Вопросы похожие на “Flutter Sliver Grid”

Больше похожих ответов на “Flutter Sliver Grid” по Dart

Смотреть популярные ответы по языку

Смотреть другие языки программирования