mburger 2.1.0 copy "mburger: ^2.1.0" to clipboard
mburger: ^2.1.0 copied to clipboard

MBurger Dart client. You can use this package to interact with the MBurger headless CMS (https://www.mburger.cloud).

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:mburger/mburger.dart';

void main() {
  MBManager.shared.apiToken = 'YOUR_API_TOKEN';
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MBurger Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MBurgerExample(),
    );
  }
}

class MBurgerExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('MBurger Example'),
      ),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            MaterialButton(
              child: Text('Get project'),
              onPressed: () => _getProject(),
            ),
            MaterialButton(
              child: Text('Get block'),
              onPressed: () => _getBlock(),
            ),
            MaterialButton(
              child: Text('Get section'),
              onPressed: () => _getSection(),
            )
          ],
        ),
      ),
    );
  }

  /// Retrieves the project connected to the token
  void _getProject() async {
    try {
      MBProject project = await MBManager.shared.getProject();
      print(project);
    } catch (error) {
      debugPrint(error.toString());
    }
  }

  /// Retrieves all the sections of a block with the id passed
  void _getBlock() async {
    try {
      MBBlock block = await MBManager.shared.getBlock(
        blockId: 1,
        includeElements: true,
      );

      print(block);
    } catch (error) {
      debugPrint(error.toString());
    }
  }

  /// Retrieves a sections with the id passed
  void _getSection() async {
    try {
      MBSection section = await MBManager.shared.getSection(
        sectionId: 1,
        includeElements: true,
      );
      print(section);
    } catch (error) {
      debugPrint(error.toString());
    }
  }
}
10
likes
0
pub points
66%
popularity

Publisher

verified publishermburger.cloud

MBurger Dart client. You can use this package to interact with the MBurger headless CMS (https://www.mburger.cloud).

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

android_id, collection, device_info_plus, flutter, flutter_secure_storage, http, http_parser, intl, mime, shared_preferences

More

Packages that depend on mburger