collection_box 0.0.1 copy "collection_box: ^0.0.1" to clipboard
collection_box: ^0.0.1 copied to clipboard

A simple widget where user input is turned into a list of text widgets.

example/lib/main.dart

import 'package:collection_box/collection_box.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Collection Box',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Collection Box'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<String> _currentCollection = [];
  void getList(List<String> collection) {
    _currentCollection = collection;
    debugPrint("some thing ");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            const Spacer(flex: 1),
            CollectionBox(
              onCollectionChanged: getList,
              limit: 5,
            ),
            const Spacer(flex: 1),
            ElevatedButton(
              onPressed: () {
                setState(() {
                  setState(() {});
                });
              },
              child: const Text("Check collection box length"),
            ),
            const Spacer(flex: 1),
            Text('Collection box length: ${_currentCollection.length}'),
            const Spacer(flex: 1),
          ],
        ),
      ),
    );
  }
}
3
likes
150
pub points
0%
popularity

Publisher

unverified uploader

A simple widget where user input is turned into a list of text widgets.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on collection_box