SliverGrid. count constructor.

Search Results

Featured snippet from the web

SliverGridcount constructor. Creates a sliver that places multiple box children in a two dimensional arrangement with a fixed number of tiles in the cross axis. Uses a SliverGridDelegateWithFixedCrossAxisCount as the gridDelegate, and a SliverChildListDelegate as the delegate



import 'package:flutter/material.dart';


void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final appTitle = 'Drawer Demo';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: appTitle,
      home: MyHomePage(title: appTitle),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {

    
    
    return Scaffold(
        appBar: AppBar(title: Text(title)),
        body: Center(
        child:CustomScrollView(
        primary: false,
        
          
          
        slivers: <Widget>[
        SliverPadding( 
        padding: const EdgeInsets.all(20),
        sliver: SliverGrid.count(
        crossAxisSpacing: 10,
        mainAxisSpacing: 10,
        crossAxisCount: 2,
        
          children: <Widget>[

            Container(
            padding: const EdgeInsets.all(8),
            child: const Text('He\'d have you all unravel at the'),
            color: Colors.green[100],
          ),
          
            
            
            Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Heed not the rabble'),
            color: Colors.green[200],
          ),
          
            
            Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Sound of screams but the'),
            color: Colors.green[300],
          ),
          
            
            
            Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Who scream'),
            color: Colors.green[400],
          ),
          
            
            Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Revolution is coming...'),
            color: Colors.green[500],
          ),
          
            
            Container(
            padding: const EdgeInsets.all(8),
            child: const Text('Revolution, they...'),
            color: Colors.green[600],),
                
          
          ],
         ),
        ),
       ],
      )
     )
   );
  }
}

Comments

Popular posts from this blog

Auto slide image with indicator in flutter

Flutter Architecture | Flutter - Architecture Application

Automatic Scrolling Image in flutter