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 video thumbnail from url 
Dart :: dartlang group array by key 
Dart :: flutter capture image from camera 
Dart :: space around in flutter 
Dart :: get one document firestore flutter dart 
Dart :: retrieve shared preferences flutter map 
Dart :: dart init Map 
Dart :: flutter iOS & Android chnage package name & app name 
Dart :: Send Form Data in HTTP POST request in Flutter 
Dart :: declaring and initializing a list in dart 
Dart :: flutter column min height screen sixe 
Dart :: flutter random true false 
Dart :: DioError (DioError [DioErrorType.DEFAULT]: Converting object to an encodable object failed: Instance of 
Dart :: convert list in set dart 
Dart :: how to display current date time in flutter 
Dart :: snackbar flutter 
Dart :: base64encode flutter 
Dart :: flutter textfield align center text 
Dart :: how to blur container in flutter 
Dart :: dart time 
Dart :: flutter overflow 
Dart :: flutter slider 
Dart :: Flutter list of strings to one String 
Dart :: loop map flutter 
Dart :: odd even in dart 
Dart :: DateFormat local fr flutter 
Dart :: dart get return value of future function 
Dart :: flutter unhandled exception 
Dart :: what is the difference between runapp() and main() in flutter 
Dart :: hive dart type adapter 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =