home_page_provider 1.2.1 home_page_provider: ^1.2.1 copied to clipboard
A Flutter package project that gives the option to have a separate home page for web and mobile
home_page_provider #
The HomePageProvider class gives the option to have a separate home page for web and mobile
Getting started #
Installation #
In the dependencies:
section of your pubspec.yaml
, add the following line:
dependencies:
home_page_provider: ^1.2.0
Than import the package via:
import 'package:home_page_provider/home_page_provider.dart';
Usage #
Instead of passing your home page widget to, for example, MaterialApp, you would pass 2 versions of it instead, one for web and one for mobile.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Home Page Provider package demo',
home: HomePageProvider().getWebOrMobileHomePage(
const HomePageWeb(),
const HomePageMobile(),
),
);
}
Additional information #
This package relies on the idea that the following imports are mutually exclusive:
if (dart.library.io) 'home_page_provider_mobile.dart'
if (dart.library.html) 'home_page_provider_web.dart' ;
Take a look at the package source.