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 :: speedometer in flutter 
Dart :: dart static method 
Dart :: how to update listview in flutter 
Dart :: difference between hot reload and hot restart in flutter 
Dart :: install fvm in flutter using pub package 
Dart :: dart inherit from generic 
Dart :: flutter row vertical direction 
Dart :: crossaxisalignment.stretch row in column flutter 
Dart :: create and validate flutter forms 
Dart :: tab splash hide flutter 
Dart :: tab color in flutter 
Dart :: proportion in flutter 
Dart :: rectangualr fab in flutter 
Dart :: how to perform a text search over json data in flutter 
Dart :: const issue on new flutter version 
Dart :: app bar for chat flutter 
Dart :: parse string to datetime 
Swift :: How do I check if a string contains another string in Swift 
Swift :: swift has Top Notch 
Swift :: xcode hide keyboard when touch background storyboard 
Swift :: pushviewcontroller swift autolayout 
Swift :: get current unix timestamp swift ios 
Swift :: Return different data types swift 
Swift :: swiftui circle 
Swift :: post API Call in swift 
Swift :: swift initialize a view 
Swift :: uiimage to data swift 
Swift :: add navigation bar button swiftui 
Swift :: swift close view 
Swift :: Equatable Function Swift 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =