Chizy
Chizy

Reputation: 147

What is the best way to do nothing here, where I am using a consumer widget?

I am trying to write keep the override part to do nothing since I don't want to implement anything. How would I do it with a consumer widget.

I know in stateful widget it is something like this:

_MyAppState createState() => _MyAppState();

How can I do same for consumer widget below:

  const SignInWithGoogleButton({Key? key}) : super(key: key);

  void signInWithGoogle(BuildContext context, WidgetRef ref) {
    ref.read(authControllerProvider).signInWithGoogle();
  }

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    // TODO: implement build
    throw UnimplementedError();
  }
} 

Upvotes: 1

Views: 308

Answers (1)

MendelG
MendelG

Reputation: 20088

If you don't want to do anything within your build method, you can just return a SizedBox.shrink() widget:

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SizedBox.shrink();
  }
}

Upvotes: 2

Related Questions