Skip to content

Commit

Permalink
applying migration tool
Browse files Browse the repository at this point in the history
  • Loading branch information
trashfeed committed Nov 7, 2021
1 parent ba4575b commit 2853c86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions lib/memo_page.dart
Expand Up @@ -3,12 +3,12 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:notepad/memo.dart';

class MemoPage extends HookWidget {
class MemoPage extends HookConsumerWidget {
const MemoPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(appBar: _appBar(), body: _body());
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(appBar: _appBar(), body: _body(ref));
}

PreferredSizeWidget _appBar() {
Expand All @@ -17,33 +17,33 @@ class MemoPage extends HookWidget {
);
}

Widget _body() {
Widget _body(WidgetRef ref) {
return Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
_header(),
_editor(),
_header(ref),
_editor(ref),
],
),
);
}

Widget _header() {
return HookBuilder(builder: (BuildContext context) {
Widget _header(WidgetRef ref) {
return HookConsumer(builder: (BuildContext context, ref, child) {
return Align(
alignment: Alignment.centerRight,
child: Text(
useProvider(
memoStateNotifierProvider.select((state) => state.wordCount)),
ref.watch(
memoStateNotifierProvider.select<String>((state) => state.wordCount)),
style: TextStyle(color: Theme.of(useContext()).disabledColor),
),
);
});
}

Widget _editor() {
var notifier = useProvider(memoStateNotifierProvider.notifier);
Widget _editor(WidgetRef ref) {
var notifier = ref.watch(memoStateNotifierProvider.notifier);
return Expanded(
child: TextField(
maxLines: null,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Expand Up @@ -30,7 +30,7 @@ dependencies:
flutter:
sdk: flutter
flutter_hooks: ^0.16.0-nullsafety.0
hooks_riverpod: ^0.14.0+3
hooks_riverpod: ^1.0.0


# The following adds the Cupertino Icons font to your application.
Expand Down

0 comments on commit 2853c86

Please sign in to comment.