changeif 1.0.0 copy "changeif: ^1.0.0" to clipboard
changeif: ^1.0.0 copied to clipboard

Flutter Hook's useMemoized as dot notation.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:niku/niku.dart';

import 'package:flutter_hooks/flutter_hooks.dart';

import 'package:changeif/changeif.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ChangeIf Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Home(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: NikuColumn([
        WithoutChangeIf(),
        Divider(),
        WithChangeIf(),
      ]).mainCenter().crossCenter().niku().fullWidth(),
    );
  }
}

class WithoutChangeIf extends HookWidget {
  build(context) {
    final counter = useState(0);

    final headline6 = Theme.of(context).textTheme.headline6;

    return NikuColumn([
      NikuText("Without ChangeIf").style(headline6),
      NikuText("Last rebuild: ${counter.value}"),
      NikuButton(Text("Counter: ${counter.value}"))
        ..onPressed(() {
          counter.value++;
        }),
    ]);
  }
}

class WithChangeIf extends HookWidget {
  build(context) {
    final counter = useState(0);

    final headline6 = Theme.of(context).textTheme.headline6;

    return NikuColumn([
      NikuText("With ChangeIf").style(headline6).changeIf(),
      NikuText("Last rebuild: ${counter.value}").changeIf(),
      NikuButton(Text("Counter: ${counter.value}"))
        ..onPressed(() {
          counter.value++;
        }),
    ]);
  }
}
0
likes
100
pub points
0%
popularity

Publisher

unverified uploader

Flutter Hook's useMemoized as dot notation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, flutter_hooks, niku

More

Packages that depend on changeif