如何用扑朔迷离的颤音甚至铁轨构建移动应用程序



我是Rails Web Back&前开发人员,我想构建一个移动应用程序。一个简单的应用程序,带有产品,用户,地理定位以及可能的付款(带有第三部分的条纹)。

我认为Flutter Framework是一个不错的选择,看起来很简单。

,但我不知道飞镖语言(或移动本地开发)是如何开始的,也不知道从哪里开始。

我想到了一个系统:

  • 产品和用户的后端导轨
  • flutter Framework应用程序用于动作和地理定位
  • 他们之间接收和发送数据的API

您有一些建议吗?从哪里开始,替代方案?

非常感谢!

您的问题绝对不应该如此广泛,因为对此没有正确的答案,但我会尝试的。我仅使用文档就学会了几天之内的颤音。

我学习了设置,安装并编写了我的第一个应用程序。

我通过查看此网站来学习体系结构,并仅阅读有关正在实施的特定体系结构的更多信息。

为了在布局本身方面变得更好,这是非常简单且很好地处理的,我在Instagram上遇到了我的旧设计挑战,我每天使用一个UI实施了几天,使用了fllutter。大约一个星期后,我也可以建立我想要的任何布局。

我已经在此处所述使用示波器模型和大型应用中的redux进行了解决。太棒了。

这就是我所使用的,然后每周我将在Google开发人员YouTube页面上观看本周的小部件,仅此而已。Flutter的中型社区非常活跃,应该是一个很好的信息来源,但是除非我需要学习新知识,否则我几乎从不阅读博客。

将导轨API连接到flutter UI非常简单,有关州管理方面有几个注意事项,但是Google建议使用Bloc模式,并且与Rails非常有效。p>现在,我不会详细介绍实现集团模式,但我将在该主题底部留下一些链接。

第一步是检查颤音文档,它们有一些不错的食谱,我将在下面使用Rails Generator适应一个食谱。https://flutter.dev/docs/cookbook/networking/fetch-data

  1. 创建一个文章资源:
rails g resource post title:string body:string
  1. 运行rails db:migrate
  2. 使用Rails Console创建帖子
  3. 在您的flutter应用程序(main.dart)中,我假设这是一个全新的应用程序:
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
Future<Post> fetchPost() async {
  final response =
      await http.get('http://10.0.2.2:3000/posts/1');
  if (response.statusCode == 200) {
    // If the call to the server was successful, parse the JSON.
    return Post.fromJson(json.decode(response.body));
  } else {
    // If that call was not successful, throw an error.
    throw Exception('Failed to load post');
  }
}
class Post {
  final int id;
  final String title;
  final String body;
  Post({this.id, this.title, this.body});
  factory Post.fromJson(Map<String, dynamic> json) {
    return Post(
      id: json['id'],
      title: json['title'],
      body: json['body'],
    );
  }
}
void main() => runApp(MyApp(post: fetchPost()));
class MyApp extends StatelessWidget {
  final Future<Post> post;
  MyApp({Key key, this.post}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Fetch Data Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text('Fetch Data Example'),
        ),
        body: Center(
          child: FutureBuilder<Post>(
            future: post,
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                return Text(snapshot.data.title);
              } else if (snapshot.hasError) {
                return Text("${snapshot.error}");
              }
              // By default, show a loading spinner.
              return CircularProgressIndicator();
            },
          ),
        ),
      ),
    );
  }
}
  1. 启动在端口3000上运行的导轨服务器
  2. 启动Flutter App

确实如此。轨道和颤音绝对很棒,并且随着颤抖的网络出现...在某个时候...我真的很兴奋。

其他一些资源:颤音和轨道CLI(仍然非常wip,但到达那里)https://rubygems.org/gems/frap

国家管理:https://www.didierboelens.com/2018/08/reactive-programming--streams--bloc/https://medium.com/flutterpub/architecting-your-flutter-project-bd04e144a8f1

一堆示例https://github.com/flutter/samples/blob/master/index.md

最新更新