live_game_lib 0.0.4 copy "live_game_lib: ^0.0.4" to clipboard
live_game_lib: ^0.0.4 copied to clipboard

A Game Libary for creating live multiplayergames with flutter and firebase very fast and easy.

Live Game Library #

A Flutter Library for creating Games fast

Getting Started #

  1. Setup your Firebase project and add it to project
  2. Setup you real time database real time database
  3. Import this library and create your list of games
import 'package:example/games/guess_the_word.dart';
import 'package:live_game_lib/backend/game_prefab.dart';
Map<String, Game> games = {

    "my first game": Game(
        "my first game",
        myFirstGameScreen,
        usesLobby: true,
        canPostjoin: true,
    ),
};
  1. Create your First Game Call Function in another File
import 'package:flutter/material.dart';
import 'package:live_game_lib/backend/room.dart';
Widget myFirstGameScreen(BuildContext context, Room r) {
    String textDatabase = r.getString("syncedString") ?? "";
    return return Scaffold(
        appBar: AppBar(
        title: const Text("Synced Text Field"),
        ),
        body: Center (
            TextFormField(
                initialValue: textDatabase,
                onChanged: (text) {
                    r.set("syncedString", text);
                },
            )
        )   
    )
}
  1. Create Your Game Manager in your main file
import 'package:example/firebase_options.dart';
import 'package:example/gamelist.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:live_game_lib/backend/gamemanager.dart';


GameManager? inst;
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  inst = GameManager(games: games);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Live Games Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      initialRoute: '/',
      routes: inst?.routes
    );

  }
}
  1. For more examples, see the example project in the example folder
2
likes
0
pub points
23%
popularity

Publisher

unverified uploader

A Game Libary for creating live multiplayergames with flutter and firebase very fast and easy.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

firebase, firebase_auth, firebase_core, firebase_database, flutter, playing_cards

More

Packages that depend on live_game_lib