n_dimensional_array 1.0.5 copy "n_dimensional_array: ^1.0.5" to clipboard
n_dimensional_array: ^1.0.5 copied to clipboard

Allows for the creation and easy manipulation of n-dimensional arrays in Dart.

example/lib/main.dart

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

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

class ArrayExample extends StatefulWidget {
  const ArrayExample({super.key});

  @override
  State<ArrayExample> createState() => _ArrayExampleState();
}

class _ArrayExampleState extends State<ArrayExample> {
  NdArray _array = NdArray.fromList([
    [1, 2],
    [3, 4],
  ]);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'n-Dimensional Array',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text('n-Dimensional Array')),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text('Shape: ${_array.shape}'),
              Text('Data: ${_array.data}'),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () => setState(() => _array[0][0] += 1),
                child: const Text('Increment [0][0]'),
              ),
              ElevatedButton(
                onPressed: () => setState(
                  () => _array.reshape([-1, _array.shape.last + 1]),
                ),
                child: const Text('Add column'),
              ),
              ElevatedButton(
                onPressed: () => setState(() {
                  _array = NdArray.fromList([
                    [1, 2],
                    [3, 4],
                  ]);
                }),
                child: const Text('Reset'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
23
likes
160
points
84
downloads

Documentation

API reference

Publisher

verified publisherhexcat.dev

Weekly Downloads

Allows for the creation and easy manipulation of n-dimensional arrays in Dart.

Repository (GitHub)
View/report issues

Topics

#multidimensional-array #nested-list

Funding

Consider supporting this project:

www.buymeacoffee.com
paypal.me
venmo.com

License

MIT (license)

Dependencies

collection

More

Packages that depend on n_dimensional_array