0% found this document useful (0 votes)
11 views1 page

My Home Page-1

The document is a Flutter Dart code for a stateful widget named MyHomePage that utilizes Riverpod for state management. It features an AppBar, a centered column with text widgets and an ApiDataWidget, and a FloatingActionButton that triggers data loading when pressed. The MyHomePage class takes a title as a parameter and displays it in the AppBar.

Uploaded by

rizwns219
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

My Home Page-1

The document is a Flutter Dart code for a stateful widget named MyHomePage that utilizes Riverpod for state management. It features an AppBar, a centered column with text widgets and an ApiDataWidget, and a FloatingActionButton that triggers data loading when pressed. The MyHomePage class takes a title as a parameter and displays it in the AppBar.

Uploaded by

rizwns219
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import 'package:flutter/material.

dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import
'package:riverpod_2_practice/pages/MyHomePage/controller/api_controller.dart';
import 'package:riverpod_2_practice/pages/MyHomePage/widgets/api_data_widget.dart';
import 'package:riverpod_2_practice/pages/MyHomePage/widgets/buttons.dart';
import 'package:riverpod_2_practice/pages/MyHomePage/widgets/text_widgets.dart';

class MyHomePage extends ConsumerStatefulWidget {


const MyHomePage({super.key, required this.title});

final String title;

@override
ConsumerState<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends ConsumerState<MyHomePage> {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
HardcodeText(),
CounterText(),
SizedBox(height: 30,) ,
ApiDataWidget()
],
),
),
floatingActionButton: FloatingActionButton(onPressed:() {
ref.read(apiDataStateProvider.notifier).loadData();
}, child: const Icon(Icons.abc),)
);
}
}

You might also like