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 :: Flutter For In loop explained 
Dart :: flutter sliver TabBar 
Dart :: flutter appbar default padding 
Dart :: border radius to card flutter dart 
Dart :: media query flutter 
Dart :: flutter concat lists 
Dart :: set minus padding in flutter 
Dart :: elevated Button Theme background color in flutter 
Dart :: flutter block rotation 
Dart :: getting internet connectivity in flutter with getx 
Dart :: message yes or not in dart 
Dart :: scroll with mouse in flutter 
Dart :: flutter icon 
Dart :: filter duplicates in dart 
Dart :: how to use future Dropownitem list in flutter 
Dart :: assign hex to color dart 
Dart :: internal shadow flutter 
Dart :: platform brightness flutter 
Dart :: convert datetime to TZDateTimeflutter 
Dart :: add a button that changes the text in flutter 
Dart :: dart function syntax 
Dart :: how to format timeofday in custom format flutter 
Dart :: install fvm in flutter using pub package 
Dart :: flutter appbar is still grey 
Dart :: how to set device into autorotate in flutter 
Dart :: how to change primary color in flutter 
Dart :: allow background service in flutter app 
Dart :: Should I learn Dart for Flutter? 
Swift :: swift 5 get current year 
Swift :: delete padding list swiftui 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =