jonataslaw / get_server

A backend server that makes it possible to program with Flutter syntax and reuse existing code
Apache License 2.0
477 stars 42 forks source link

How can I use it in a normal flutter app? #24

Closed yingshaoxo closed 3 years ago

yingshaoxo commented 4 years ago

For example, if I have the following codes:

Future<void> main(List<String> args) async {
  WidgetsFlutterBinding.ensureInitialized();

  // if I put it here, the UI won't start, I guess
  /*
  runApp(GetServer(
    getPages: [
      GetPage(name: '/', page:()=> Home()),
    ],
  ));
  */

  runApp(MultiProvider(
    providers: [
      ChangeNotifierProvider(create: (context) => AppModel()),
    ],
    child: MaterialApp(
      title: TITLE,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyApp(),
    ),
  ));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

How can I run the server in the background while still have the UI working properly?

Katekko commented 3 years ago

You are missing somethings, the server and the app are two different applications, two different projects.

Think about your server it will be some API that you will be consuming on your app.

yingshaoxo commented 3 years ago

OK, the dart is a programming language.

Not a frontend framework.