taboola_sdk 0.0.2+3

Flutter Android iOS

Taboola Flutter project.

example/lib/main.dart

import 'package:flutter/material.dart';

// import screens
import 'package:taboola_sdk_example/screens/single_child_scroll_view_test.dart';
import 'package:taboola_sdk_example/screens/taboola_listview_screen.dart';
import 'package:taboola_sdk_example/screens/taboola_tabs_screen.dart';
import 'package:taboola_sdk_example/screens/taboola_pageview_screen.dart';
import 'package:taboola_sdk_example/DefaultProperties.dart' as PublisherProperties;
import 'package:flutter/gestures.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Widget displayedScreen;

  @override
  void initState() {
    super.initState();

    // Set default screen
    displayedScreen = TaboolaPageViewScreen(PublisherProperties.publisher, PublisherProperties.pageUrl, PublisherProperties.pageType, PublisherProperties.placement, PublisherProperties.mode);

    // Allow gesture debugging
    debugPrintGestureArenaDiagnostics = true;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('TaboolaFlutterDemo'),
        ),
        body: Center(
          child: displayedScreen,
        ),
        drawer: Drawer(
          // Add a ListView to the drawer. This ensures the user can scroll
          // through the options in the drawer if there isn't enough vertical
          // space to fit everything.
          child: ListView(
            // Important: Remove any padding from the ListView.
            padding: EdgeInsets.zero,
            children: <Widget>[
              DrawerHeader(
                child: Text('Taboola Sample Screens'),
                decoration: BoxDecoration(
                  color: Colors.blue,
                ),
              ),
              ListTile(
                title: Text('SingleChildScrollView'),
                trailing: Icon(Icons.arrow_forward),
                onTap: () {
                  // Update the state of the app.
                  setState(() {
                    displayedScreen = SingleChildScrollViewTest();
                  });
                  // Close the drawer
                  Navigator.pop(context);
                },
              ),
              ListTile(
                title: Text('TaboolaStandard | ListView w/ Feed'),
                trailing: Icon(Icons.arrow_forward),
                onTap: () {
                  // Update the state of the app.
                  setState(() {
                    displayedScreen = TaboolaListViewScreen(PublisherProperties.publisher, PublisherProperties.pageUrl, PublisherProperties.pageType, PublisherProperties.placement, PublisherProperties.mode);
                  });
                  // Close the drawer
                  Navigator.pop(context);
                },
              ),
              ListTile(
                title: Text('TaboolaStandard | Tabs w/ Feed'),
                trailing: Icon(Icons.arrow_forward),
                onTap: () {
                  // Update the state of the app.
                  setState(() {
                    displayedScreen = TaboolaTabsScreen(PublisherProperties.publisher, PublisherProperties.pageUrl, PublisherProperties.pageType, PublisherProperties.placement, PublisherProperties.mode);
                  });
                  // Close the drawer
                  Navigator.pop(context);
                },
              ),
              ListTile(
                title: Text('TaboolaStandard | PageView w/ Feed'),
                trailing: Icon(Icons.arrow_forward),
                onTap: () {
                  // Update the state of the app.
                  setState(() {
                    displayedScreen = TaboolaPageViewScreen(PublisherProperties.publisher, PublisherProperties.pageUrl, PublisherProperties.pageType, PublisherProperties.placement, PublisherProperties.mode);
                  });
                  // Close the drawer
                  Navigator.pop(context);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}