minimals_state_manager 1.0.6 copy "minimals_state_manager: ^1.0.6" to clipboard
minimals_state_manager: ^1.0.6 copied to clipboard

A minimalist study project for state management, lifecycle, and observables in Flutter, but not recommended for production due to alpha status.

example/lib/main.dart

import 'package:example/routes/delegate.dart';
import 'package:flutter/material.dart';

import 'package:url_strategy/url_strategy.dart';

// with 2.0 navigation
//complex example
void main() {
  setPathUrlStrategy();
  runApp(MaterialApp.router(
    routerConfig: GoRootDelegate.router,
  ));
}

/******************
 * uncomment the rest of the file to use this 
 * simpler example, comment out the previous main
 * simple example
******************/
// void main() {
//   runApp(MaterialApp(
//     home: MinProvider(controller: MyController(), child: MyPage()),
//   ));
//   // runApp(const MaterialApp()); //normal navigation
// }

// 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 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) => Column(
//                       children: [
//                         $(controller.user,
//                           (user) => Text('${user.name}'),
//                         ),
//                         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) => $(
//                           controller.count,
//                           (count) => Text(
//                             'Count $count',
//                             style: const TextStyle(
//                               fontSize: 24.0,
//                               fontWeight: FontWeight.w600,
//                             ),
//                           ),
//                           
//                         ),
//                       ),
//                     ],
//                   ),
//                 ],
//               ),
//             ],
//           ),
//         ),
//       );
// }

// class User {
//   User({this.name});
//   String? name;
// }
copied to clipboard
11
likes
140
points
136
downloads

Publisher

verified publisherdeebx.tech

Weekly Downloads

2024.06.09 - 2024.12.22

A minimalist study project for state management, lifecycle, and observables in Flutter, but not recommended for production due to alpha status.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on minimals_state_manager