barnabasbartha / shared_preferences_settings

Flutter Settings Screen with Shared Preferences
MIT License
71 stars 34 forks source link

How I can use onStringChanged with RadioPickerSettingsTile #13

Open nodermann2 opened 4 years ago

nodermann2 commented 4 years ago

I can't figure out where to add the function to get data. Could you provide a full example?

nodermann2 commented 4 years ago

I need to get a change event to call notifyListeners()

barnabasbartha commented 4 years ago

See #11 and readme for example.

nodermann2 commented 4 years ago

Yes, I saw it I believe a full-fledged example would be better because #11 is also given an incomplete answer. How do I change this code so that the void selected(String item) method is called every time the user changes the value?

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

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

  void selected(String item) {
    print('selected: $item');
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: RadioPickerSettingsTile(
        settingKey: 'hello-key',
        title: 'Welcome',
        values: {
          'a': 'Hello',
          'b': 'World',
        },
      ),
    );
  }
}
barnabasbartha commented 4 years ago

I see. Unfortunately, this is not supported atm. I'll add an onChange callback parameter soon.

koteezy commented 4 years ago

I see. Unfortunately, this is not supported atm. I'll add an onChange callback parameter soon.

Any news?

nodermann2 commented 4 years ago

I see. Unfortunately, this is not supported atm. I'll add an onChange callback parameter soon.

Any news?

I didn't wait and made my own implementation without this dependency.