string_manager_flutter 0.0.2 copy "string_manager_flutter: ^0.0.2" to clipboard
string_manager_flutter: ^0.0.2 copied to clipboard

outdated

A Flutter Package for Managing App Strings in flutter applications on all platforms particularly internationalization.

A Flutter Package for Managing App Strings in flutter applications on all platforms particularly internationalization

Features #

  • keep your app strings DRY
  • easy internationalization
  • supports all platforms

https://user-images.githubusercontent.com/89414401/173678119-8bd4f10b-7dc2-46c8-a1bd-e412925720ec.mp4

Getting started #

dependencies:
  flutter:
    sdk: flutter
  string_manager_flutter:

Usage #

import 'package:flutter/material.dart';
import 'package:string_manager_flutter/string_manager_flutter.dart';
import 'package:intl/intl.dart';

final StringManager str = StringManager.instance;

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  ///factory constructor for the singleton instance
  StringManager(language: Intl.defaultLocale);

  await str.initialize();

  ///you must initialize the stringManager first
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) =>
      const MaterialApp(
        home: MyHomePage(),
      );
}

class MyHomePage extends StatefulWidget {


  const MyHomePage({
    Key? key,
  }) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  void dispose() {
    ///do not forget to close or save your strings
    str.save();
    str.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              str.reg('You have pushed the button this many times'),

              ///str.reg(String text) registers the string in stringManger and returns it to be used
            ),
            Text(
              '$_counter',
              style: Theme
                  .of(context)
                  .textTheme
                  .headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: CounterFab(
        onPressed1: _incrementCounter,
        onPressed2: () async {
          await str.translate(to: 'yo');
          await str.save();

          ///you have the freedom to use whatever stateManagement you wish
          setState(() {});
        },
        text2: str.reg('change language'),
      ),
    );
  }
}

Additional information #

If you face any errors kindly create an issue, and if you wish to add a feature I will be more than happy to merge your PR

Enjoy your internationalization redefined. 😃 #

11
likes
0
points
3
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter Package for Managing App Strings in flutter applications on all platforms particularly internationalization.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, hive, hive_flutter, intl, translator

More

Packages that depend on string_manager_flutter