russian_words 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

russian_words #

Pub

A package containing ~33000 the most common Russian words and some utility functions.

Usage #

Printing the top 50 most used nouns, adjectives, verbs in the Russian language:


import 'package:russian_words/russian_words.dart';

void main() {
  nouns.take(50).forEach(print);
  adjectives.take(50).forEach(print);
  verbs.take(50).forEach(print);
  
  ///all words
  allWords.take(50).forEach(print);
}

Generating 5 interesting word combinations:


generateWordPairs().take(5).forEach(print);

///create 5 verb + noun combination
generateWordPairs(typeOfPair: TypeOfPair.verbNoun).take(5).forEach(print);

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Inspired project #

https://github.com/filiph/english_words

0.1.0 #

  • update

0.0.1 #

  • Initial version

example/lib/main.dart

import 'dart:math';

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

enum Category { any, adjective, noun, verb }

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'russian_words demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Russian Words'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

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

  List<Widget> _widgetOptions = [
    SingleWord(),
    RandomPair(),
  ];

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text(widget.title),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
              icon: Icon(Icons.looks_one), title: Text('Single word')),
          BottomNavigationBarItem(
              icon: Icon(Icons.looks_two), title: Text("Random pair"))
        ],
        currentIndex: _selectedIndex,
        onTap: _onItemTapped,
      ),
      body: Center(child: _widgetOptions.elementAt(_selectedIndex)),
    );
  }
}

class SingleWord extends StatefulWidget {
  @override
  _SingleWordState createState() => _SingleWordState();
}

class _SingleWordState extends State<SingleWord> {
  Category _category = Category.any;
  String _word;

  @override
  void initState() {
    super.initState();
    _word ??= _randomWord();
  }

  String _randomWord() {
    switch (_category) {
      case Category.any:
        return allWords[Random().nextInt(allWords.length)];
        break;
      case Category.adjective:
        return adjectives[Random().nextInt(adjectives.length)];
        break;
      case Category.noun:
        return nouns[Random().nextInt(nouns.length)];
        break;
      case Category.verb:
        return verbs[Random().nextInt(verbs.length)];
        break;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: <Widget>[
        Text(
          "Random single word is",
          textAlign: TextAlign.center,
        ),
        Container(
          padding: EdgeInsets.all(8),
          decoration:
              BoxDecoration(border: Border.all(), color: Colors.blue.shade50),
          width: MediaQuery.of(context).size.width,
          child: Text(
            _word,
            style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
            textAlign: TextAlign.center,
          ),
        ),
        Column(
          children: <Widget>[
            Text('Choose category'),
            Row(
              children: <Widget>[
                Radio(
                  value: Category.any,
                  groupValue: _category,
                  onChanged: (category) => setState(() {
                    _category = category;
                    _word = _randomWord();
                  }),
                ),
                Text('any'),
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: Category.adjective,
                  groupValue: _category,
                  onChanged: (category) => setState(() {
                    _category = category;
                    _word = _randomWord();
                  }),
                ),
                Text('adjective')
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: Category.noun,
                  groupValue: _category,
                  onChanged: (category) => setState(() {
                    _category = category;
                    _word = _randomWord();
                  }),
                ),
                Text('noun')
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: Category.verb,
                  groupValue: _category,
                  onChanged: (category) => setState(() {
                    _category = category;
                    _word = _randomWord();
                  }),
                ),
                Text('verb')
              ],
            ),
          ],
        ),
        RaisedButton(
          child: Text("change word"),
          onPressed: () => setState(() => _word = _randomWord()),
        )
      ],
    );
  }
}

class RandomPair extends StatefulWidget {
  @override
  _RandomPairState createState() => _RandomPairState();
}

class _RandomPairState extends State<RandomPair> {
  String _pair;
  TypeOfPair _typeOfPair = TypeOfPair.randomPair;

  @override
  void initState() {
    super.initState();
    _pair ??= WordPair.random(typeOfPair: _typeOfPair).asPascalCase;
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: <Widget>[
        Text(
          "Random pair is",
          textAlign: TextAlign.center,
        ),
        Container(
          padding: EdgeInsets.all(8),
          decoration:
              BoxDecoration(border: Border.all(), color: Colors.blue.shade50),
          width: MediaQuery.of(context).size.width,
          child: Text(
            _pair,
            style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
            textAlign: TextAlign.center,
          ),
        ),
        Column(
          children: <Widget>[
            Text('Choose type of pair'),
            Row(
              children: <Widget>[
                Radio(
                  value: TypeOfPair.randomPair,
                  groupValue: _typeOfPair,
                  onChanged: (type) => setState(() {
                    _typeOfPair = type;
                    _pair =
                        WordPair.random(typeOfPair: _typeOfPair).asPascalCase;
                  }),
                ),
                Text('RandomPair'),
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: TypeOfPair.adjectiveAdjective,
                  groupValue: _typeOfPair,
                  onChanged: (type) => setState(() {
                    _typeOfPair = type;
                    _pair =
                        WordPair.random(typeOfPair: _typeOfPair).asPascalCase;
                  }),
                ),
                Text('AdjectiveAdjective')
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: TypeOfPair.nounNoun,
                  groupValue: _typeOfPair,
                  onChanged: (type) => setState(() {
                    _typeOfPair = type;
                    _pair =
                        WordPair.random(typeOfPair: _typeOfPair).asPascalCase;
                  }),
                ),
                Text('NounNoun')
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: TypeOfPair.verbVerb,
                  groupValue: _typeOfPair,
                  onChanged: (type) => setState(() {
                    _typeOfPair = type;
                    _pair =
                        WordPair.random(typeOfPair: _typeOfPair).asPascalCase;
                  }),
                ),
                Text('VerbVerb')
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: TypeOfPair.adjectiveNoun,
                  groupValue: _typeOfPair,
                  onChanged: (type) => setState(() {
                    _typeOfPair = type;
                    _pair =
                        WordPair.random(typeOfPair: _typeOfPair).asPascalCase;
                  }),
                ),
                Text('AdjectiveNoun')
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: TypeOfPair.verbAdjective,
                  groupValue: _typeOfPair,
                  onChanged: (type) => setState(() {
                    _typeOfPair = type;
                    _pair =
                        WordPair.random(typeOfPair: _typeOfPair).asPascalCase;
                  }),
                ),
                Text('VerbAdjective')
              ],
            ),
            Row(
              children: <Widget>[
                Radio(
                  value: TypeOfPair.verbNoun,
                  groupValue: _typeOfPair,
                  onChanged: (type) => setState(() {
                    _typeOfPair = type;
                    _pair =
                        WordPair.random(typeOfPair: _typeOfPair).asPascalCase;
                  }),
                ),
                Text('VerbNoun')
              ],
            ),
          ],
        ),
        RaisedButton(
          child: Text("change word"),
          onPressed: () => setState(() =>
              _pair = WordPair.random(typeOfPair: _typeOfPair).asPascalCase),
        )
      ],
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  russian_words: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:russian_words/russian_words.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
42
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on May 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
test ^1.11.1