r13n 0.1.0-dev.3 copy "r13n: ^0.1.0-dev.3" to clipboard
r13n: ^0.1.0-dev.3 copied to clipboard

A package that enables region-specific configurations (regionalization). Built by Very Good Ventures.

example/lib/main.dart

import 'package:example/r13n/r13n.dart';
import 'package:flutter/material.dart';
import 'package:r13n/r13n.dart';

void main() {
  runApp(
    const MaterialApp(home: _ExamplePage()),
  );
}

class _ExamplePage extends StatefulWidget {
  const _ExamplePage();

  @override
  State<_ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<_ExamplePage> {
  var _region = Region.fromPlatform();

  @override
  Widget build(BuildContext context) {
    return Regionalizations(
      region: _region,
      delegates: const [AppRegionalizations.delegate],
      child: Builder(
        builder: (context) {
          return Scaffold(
            appBar: AppBar(
              title: Text(context.r13n.region.regionalCode),
            ),
            body: Center(
              child: Column(
                children: [
                  DropdownButton<Region>(
                    value: context.r13n.region,
                    items: const [
                      DropdownMenuItem(
                        value: Region(regionalCode: 'es'),
                        child: Text('Spain'),
                      ),
                      DropdownMenuItem(
                        value: Region(regionalCode: 'gb'),
                        child: Text('Great Britain'),
                      ),
                      DropdownMenuItem(
                        value: Region(regionalCode: 'us'),
                        child: Text('Unites States'),
                      ),
                    ],
                    onChanged: (value) {
                      if (value == null) return;
                      setState(() => _region = value);
                    },
                  ),
                  Text('Support email: ${context.r13n.supportEmail}'),
                ],
              ),
            ),
          );
        },
      ),
    );
  }
}
35
likes
160
pub points
65%
popularity

Publisher

verified publisherverygood.ventures

A package that enables region-specific configurations (regionalization). Built by Very Good Ventures.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on r13n