Mvvm_flutter

Build MVVM App for Android and IOS with Flutter
Alternatives To Mvvm_flutter
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Androidproject5,116
7 months ago1apache-2.0Java
Android 技术中台,但愿人长久,搬砖不再有
Flutter Architecture Blueprints1,308
a year ago30mitDart
Flutter Architecture Blueprints is a project that introduces MVVM architecture and project structure approaches to developing Flutter apps.
Android Learning Resources1,289
3 years ago2
Android学习资源网站索引大全
Androidproject Kotlin677
5 months ago3apache-2.0Kotlin
Android 技术中台 Kotlin 版本,但愿人长久,搬砖不再有
Jetpack_github355
a year agomitRoff
基于Kotlin + Jetpack全家桶 + Coroutines(协程) + Flutter等架构实现的一款精简版Github客户端项目,望与广大小伙伴一起成长,欢迎start or fork!
Mvvm_flutter261
5 days ago1otherDart
Build MVVM App for Android and IOS with Flutter
Flawless Ios222
3 years ago
Awesome iOS guides from the community, shared on Flawless iOS Medium blog 👉
Mood Example176
12 days agobsd-3-clauseDart
🐦 Flutter 3 心情记录 样例工程 - 国际化 i18n、uni 小程序、深色模式、多主题、本地数据管理、路由管理、状态管理、无障碍(Semantics)、异步 FFI、集成测试、图表统计、Excel 导入导出、游戏……
Flutter Architecture112
3 years ago1Dart
Clean Architecture with MVVM for Flutter using Get_It, State management, SQFlite, Dio, StorageHelper, ConnectionHelper, custom widgets and more
Flutter Elementary107
5 days ago20August 14, 20222mitDart
This is a home to a family of Elementary library packages.
Alternatives To Mvvm_flutter
Select To Compare


Alternative Project Comparisons
Readme

MVVM-Flutter

Build MVVM App for Android and IOS with Flutter。

The Structure seems like MVVM-Android

DownLoad

dependencies

PS:each layer connected by rx, use responsive thinking and rxdart operators for logical processing.Finally, update the view with provider.

ScreenShot

Code

//remote
class GithubService{
  Observable<dynamic> login()=> get("user");
}
//repo
class GithubRepo {
  final GithubService _remote;

  GithubRepo(this._remote);

  Observable login(String username, String password) {
    token = "basic " + base64Encode(utf8.encode('$username:$password'));
    return _remote.login();
  }
}
//viewmodel
class HomeViewModel extends ChangeNotifier {
  final GithubRepo _repo; 
  String username = ""; 
  String password = ""; 
  bool _loading = false; 
  String _response = ""; 
  //...
  HomeViewModel(this._repo);

   /**
   * call the model layer 's method to login
   * doOnData : handle response when success
   * doOnError : handle error when failure
   * doOnListen : show loading when listen start
   * doOnDone : hide loading when complete
   */
  Observable login() => _repo
      .login(username, password)
      .doOnData((r) => response = r.toString())
      .doOnError((e, stacktrace) {
        if (e is DioError) {
          response = e.response.data.toString();
        }
      })
      .doOnListen(() => loading = true)
      .doOnDone(() => loading = false);
}

/// View :HomePage
///
/// 获取其它页面传递来的参数
class HomePage extends PageProvideNode<HomeProvide> {
  /// 提供
  ///
  /// 获取参数 [title] 并生成一个[HomeProvide]对象
  HomePage(String title) : super(params: [title]);

  @override
  Widget buildContent(BuildContext context) {
    return _HomeContentPage(mProvider);
  }
}
// ...
class _HomeContentPageState extends State<_HomeContentPage> implements Presenter{
   //...
  _HomeState(this._viewModel) {
    providers.provideValue(_viewModel);
  }
	
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appbar://...,
        body://...
       
        CupertinoButton(
            onPressed: ()=>onClick(ACTION_LOGIN),
            //...
         ),
         Container(
                //...
                child: Provide<HomeViewModel>(
                  builder: (BuildContext context, Widget child,
                          HomeViewModel value) =>
                      Text(value.response),
                ),
              ),
        //...
        
        );
  }
  
  /// 通过[action]进行事件处理
  @override
  void onClick(String action) {
    print("onClick:" + action);
    if (ACTION_LOGIN == action) {
      _login();
    }
  }
  
    
  _login()=>_viewModel.login().doOnListen(() {
      _controller.forward();
    }).doOnDone(() {
      _controller.reverse();
    }).listen((_) {
      //success
      Toast.show("login success",context,type: Toast.SUCCESS);
    }, onError: (e) {
      //error
      dispatchFailure(context, e);
    });
 
}

LICENSE

the Apache License

Popular Flutter Projects
Popular Mvvm Projects
Popular User Interface Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Dart
Flutter
Dependency Injection
Mvvm
Mvvm Architecture