minimals_state_manager 0.0.1-alpha.0.0.1 copy "minimals_state_manager: ^0.0.1-alpha.0.0.1" to clipboard
minimals_state_manager: ^0.0.1-alpha.0.0.1 copied to clipboard

The minimals_state_manager package is a study project on state management, observables, lifecycle, and best practices for Flutter applications. It provides a minimalist implementation of state managem [...]

example/lib/main.dart

import 'package:example/app/my_app.dart';
import 'package:flutter/material.dart';

import 'package:url_strategy/url_strategy.dart';

// with 2.0 navigation
void main() {
  setPathUrlStrategy();
  runApp(const MyApp());
  // runApp(const MaterialApp()); //normal navigation
}


// void main() {
//   runApp(MaterialApp(
//     home: MinProvider(controller: MyController(), child: MyPage()),
//   ));
//   // runApp(const MaterialApp()); //normal navigation
// }

// class MyPage extends StatelessWidget {
//   final GlobalKey<FormState> formKey = GlobalKey<FormState>();
//   MyPage({super.key});

//   @override
//   Widget build(BuildContext context) => Scaffold(
//         floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
//         floatingActionButton: MinX<MyController>(
//           builder: (context, controller) => Column(
//             mainAxisAlignment: MainAxisAlignment.end,
//             children: [
//               FloatingActionButton(
//                 backgroundColor: Colors.lightGreen,
//                 onPressed: () => controller.increment(),
//                 child: const Icon(Icons.add),
//               ),
//               const SizedBox(
//                 height: 16.0,
//               ),
//               FloatingActionButton(
//                 backgroundColor: Colors.redAccent,
//                 onPressed: () => controller.decrement(),
//                 child: const Icon(Icons.remove),
//               ),
//               const SizedBox(
//                 height: 16.0,
//               ),
//               FloatingActionButton(
//                 onPressed: () => controller.refresh(),
//                 child: const Icon(Icons.refresh),
//               ),
//             ],
//           ),
//         ),
//         body: SafeArea(
//           child: Column(
//             mainAxisAlignment: MainAxisAlignment.center,
//             children: [
//               const Text('check out the full example in the example folder'),
//               Container(
//                 margin: const EdgeInsets.only(
//                     left: 32.0, right: 32.0, bottom: 32.0),
//                 child: Form(
//                   key: formKey,
//                   child: MinX<MyController>(
//                     builder: (context, controller) => TextFormField(
//                       onChanged: (value) => controller.onChangedName(value),
//                       validator: (value) => controller.validateName(value),
//                       onSaved: (newValue) => controller.onSaveName(newValue),
//                     ),
//                   ),
//                 ),
//               ),
//               Column(
//                 mainAxisAlignment: MainAxisAlignment.center,
//                 children: [
//                   Row(
//                     mainAxisAlignment: MainAxisAlignment.center,
//                     children: [
//                       MinX<MyController>(
//                         builder: (context, controller) => $(
//                           (count) => Text(
//                             'Count $count',
//                             style: const TextStyle(
//                               fontSize: 24.0,
//                               fontWeight: FontWeight.w600,
//                             ),
//                           ),
//                           listener: controller.count,
//                         ),
//                       ),
//                     ],
//                   ),
//                 ],
//               ),
//             ],
//           ),
//         ),
//       );
// }

// class MyController extends MinController {
//   @override
//   void onInit() {
//     print('init controller');
//     super.onInit();
//   }

//   final count = 0.minx;
//   ValueNotifier<User> user = User().minx;

//   increment() => count.value++;
//   decrement() => count.value--;
//   refresh() => count.value = 0;

//   onChangedName(str) => user.update((val) => val.name = str);
//   onSaveName(str) => user.update((val) => val.name = str);
//   validateName(str) => str.length < 2 ? 'insert valid name' : null;
// }

// class User {
//   User({this.name});
//   String? name;
// }
11
likes
0
points
128
downloads

Publisher

verified publisherdeebx.tech

Weekly Downloads

The minimals_state_manager package is a study project on state management, observables, lifecycle, and best practices for Flutter applications. It provides a minimalist implementation of state management using only native Flutter packages such as InheritedWidget, ChangeNotifier, ValueNotifier, ValueNotifierBuilder, and WidgetsBindingObserver. Please note that it is not recommended for production use as it is still in an alpha version.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on minimals_state_manager