Search
 
SCRIPT & CODE EXAMPLE
 

DART

flutter listview space between items

// Use ListView.separated()

ListView.separated(
	separatorBuilder: (BuildContext context, int index) {
		return SizedBox(
				height: 5,
                );
		},
	itemCount: zones.length,
	itemBuilder: (_, i) => cardStyleZone(zones[i]),
),
Comment

listview space between items flutter

Container(
          height: 110,
          child: ListView.builder(
            scrollDirection: Axis.horizontal,
            itemCount: 20,
            itemBuilder: (context, index) {
            return Container(
              margin: EdgeInsets.all(10),
              // height: 95,
              width: 100,
              color: Colors.red,
              
            );
          },),
        )
Comment

how to create space between list on flutter

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: const MyStatefulWidget(),
      ),
    );
  }
}

class MyStatefulWidget extends StatefulWidget {
  const MyStatefulWidget({Key? key}) : super(key: key);

  @override
  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  final List<int> _items = List<int>.generate(50, (int index) => index);

  @override
  Widget build(BuildContext context) {
    final ColorScheme colorScheme = Theme.of(context).colorScheme;
    final Color oddItemColor = colorScheme.primary.withOpacity(0.05);
    final Color evenItemColor = colorScheme.primary.withOpacity(0.15);

    return ReorderableListView(
      padding: const EdgeInsets.symmetric(horizontal: 40),
      children: <Widget>[
        for (int index = 0; index < _items.length; index++)
          Column(
            key: Key('$index'),
            children: [
              ListTile(
                tileColor: _items[index].isOdd ? oddItemColor : evenItemColor,
                title: Text('Item ${_items[index]}'),
              ),
              SizedBox(
                height: 5,
              ),
            ],
          ),
      ],
      onReorder: (int oldIndex, int newIndex) {
        setState(() {
          if (oldIndex < newIndex) {
            newIndex -= 1;
          }
          final int item = _items.removeAt(oldIndex);
          _items.insert(newIndex, item);
        });
      },
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Dart :: dart jsonEncode 
Dart :: keyboard push view up flutter 
Dart :: how to disable switch in flutter 
Dart :: flutter display widget based on device orientation 
Dart :: flutter popupmenubutton 
Dart :: alertdialog flutter press outside to disappera 
Dart :: six_ft_apart 
Dart :: install getx 
Dart :: change password firebase flutter 
Dart :: flutter radio buttons in alert dialoug 
Dart :: random colors for container flutter 
Dart :: flutter ignorepointer 
Dart :: dart date add month 
Dart :: sort list bool dart 
Dart :: dart variable in string 
Dart :: dart split string 
Dart :: how to convert text to double flutter 
Dart :: dispose in flutter widget 
Dart :: dart filter by attribute 
Dart :: print dart 
Dart :: flutter snackbar 
Dart :: flutter tooltip 
Dart :: flutter firebase personal user data 
Dart :: flutter define type 
Dart :: how to get image file size in flutter 
Dart :: flutter scrollable columne 
Dart :: dart anonymous function 
Dart :: flutter flip card 
Dart :: Find string index inside a list flutter 
Dart :: create a row with two child in flutter 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =