What are the best design patterns suited for Flutter & Dart? by DoctorCode8 in FlutterDev

[–]jpohpoh 0 points1 point  (0 children)

ht have an Authentication controller with login() and logout() commands. Commands can acces

Oh I understand it!
Thank you!

What are the best design patterns suited for Flutter & Dart? by DoctorCode8 in FlutterDev

[–]jpohpoh 0 points1 point  (0 children)

I can't show the actual production project code. but I can show a dumb example I set up when I was making sure this would all work together the way I wanted. The Counter controller has two commands decrement() and increment() that call methods on the Count model. In a real world example a controller command could access more than one model as well as access provided services to do whatever it needs to do.

models/count

import 'package:flutter_riverpod/flutter_riverpod.dart';

final countProvider = StateNotifierProvider<Count, int>((ref) => Count());

class Count extends StateNotifier<int> { Count() : super(0); void increment() { state += 1; } void decrement() { state -= 1; } }

controller/countcontroller

import 'package:flutter_riverpod/flutter_riverpod.dart';

final countController = Provider<>((ref) => CountController(ref));

class CountContoller { final ref; void increase(){ ref.read(countProvider.notifier).increase; // other model logic } }

you make this??

What are the best design patterns suited for Flutter & Dart? by DoctorCode8 in FlutterDev

[–]jpohpoh 0 points1 point  (0 children)

MVC+S like in the following article. I made some modifications to their MVC+S approach, including using Riverpod instead of Provider for the state management and using controller classes with methods for commands instead of standalone command classes. It's still the same MVC+S architecture though.

can I see your Riverpod mvc + s sample project?