nanna 1.0.2 copy "nanna: ^1.0.2" to clipboard
nanna: ^1.0.2 copied to clipboard

A comprehensive set of utilities, extensions, widgets, and services for Flutter development.

example/lib/main.dart

import 'package:flutter/widgets.dart';

import 'package:nanna/nanna.dart';

/// Esempio di utilizzo della libreria Nanna.
Future main() async {
  // Initialize secure storage
  naSecureStorageInit();

  // Esegue un metodo asincrono di test
  await _testStorageAsync();
}

/// Metodo asincrono privato per testare lo storage.
Future _testStorageAsync() async {
  final bool isFirstLaunch = await naSecureStorageReadBoolAsync('first_launch') ?? true;

  if (isFirstLaunch) {
    print('First launch!');
    await naSecureStorageWriteBoolAsync('first_launch', false);
  }else {
    print('Not first launch.');
  }

  // Lista fittizia per testare le estensioni
  final Iterable<String> fruitList = ['apple', 'banana', 'cherry'];
  final int index = NaIterableExtensions(fruitList).indexWhere((item) => item == 'banana');
  
  if (index >= 0) {
    print('Banana is at index: $index');
  }
}

/// Esempio di Widget Stateful che rispetta tutte le linee guida
class NannaExampleWidget extends StatefulWidget {
  final String title;

  const NannaExampleWidget({
    required this.title,
    super.key,
  });

  @override
  State<NannaExampleWidget> createState() => _NannaExampleWidgetState();
}

class _NannaExampleWidgetState extends State<NannaExampleWidget> {
  String _message = 'Init';

  @override
  void initState() {
    super.initState();
    _message = widget.title;
  }

  /// Metodo asincrono che non usa `this.` per variabili private
  Future updateMessageAsync() async {
    await Future.delayed(const Duration(seconds: 1));
    setState(() {
      _message = 'Updated: ${widget.title}';
    });
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Text(_message),
    );
  }
}
0
likes
160
points
126
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A comprehensive set of utilities, extensions, widgets, and services for Flutter development.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_secure_storage, toastification

More

Packages that depend on nanna